cleaned up super_resolution sample from old OCL
authorIlya Lavrenov <ilya.lavrenov@itseez.com>
Fri, 31 Jan 2014 17:00:16 +0000 (21:00 +0400)
committerIlya Lavrenov <ilya.lavrenov@itseez.com>
Tue, 4 Feb 2014 20:28:10 +0000 (00:28 +0400)
.project [deleted file]
modules/core/include/opencv2/core/mat.hpp
modules/core/src/directx.cpp
modules/core/src/matrix.cpp
modules/core/src/ocl.cpp
modules/core/src/opencl/mulspectrums.cl
modules/ts/include/opencv2/ts/ocl_perf.hpp
samples/gpu/super_resolution.cpp

diff --git a/.project b/.project
deleted file mode 100644 (file)
index bf2777f..0000000
--- a/.project
+++ /dev/null
@@ -1,100 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>opencv</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <buildCommand>
-                       <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
-                       <triggers>clean,full,incremental,</triggers>
-                       <arguments>
-                               <dictionary>
-                                       <key>?children?</key>
-                                       <value>?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|?name?=entry\\\\\\\|\\\|\||</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>?name?</key>
-                                       <value></value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.append_environment</key>
-                                       <value>true</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
-                                       <value>all</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.buildArguments</key>
-                                       <value></value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.buildCommand</key>
-                                       <value>make</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.buildLocation</key>
-                                       <value>/home/ilya/Documents/Programming/Builds/opencv_debug/bin</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
-                                       <value>clean</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.contents</key>
-                                       <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
-                                       <value>false</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
-                                       <value>true</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.enableFullBuild</key>
-                                       <value>true</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
-                                       <value>all</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.stopOnError</key>
-                                       <value>true</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
-                                       <value>true</value>
-                               </dictionary>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
-                       <triggers>full,incremental,</triggers>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.cdt.codan.core.codanBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-       </buildSpec>
-       <natures>
-               <nature>org.eclipse.cdt.core.cnature</nature>
-               <nature>org.eclipse.cdt.core.ccnature</nature>
-               <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
-               <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
-               <nature>org.eclipse.cdt.codan.core.codanNature</nature>
-       </natures>
-       <linkedResources>
-               <link>
-                       <name>bin</name>
-                       <type>2</type>
-                       <location>/home/ilya/Documents/Programming/Builds/opencv_debug/bin</location>
-               </link>
-       </linkedResources>
-</projectDescription>
index 8099520..6409222 100644 (file)
@@ -85,10 +85,9 @@ public:
         OPENGL_BUFFER     = 7 << KIND_SHIFT,
         CUDA_MEM          = 8 << KIND_SHIFT,
         GPU_MAT           = 9 << KIND_SHIFT,
-        OCL_MAT           =10 << KIND_SHIFT,
-        UMAT              =11 << KIND_SHIFT,
-        STD_VECTOR_UMAT   =12 << KIND_SHIFT,
-        UEXPR             =13 << KIND_SHIFT
+        UMAT              =10 << KIND_SHIFT,
+        STD_VECTOR_UMAT   =11 << KIND_SHIFT,
+        UEXPR             =12 << KIND_SHIFT
     };
 
     _InputArray();
index 23addbf..4d9fd6c 100644 (file)
@@ -736,7 +736,7 @@ void convertToD3D11Texture2D(InputArray src, ID3D11Texture2D* pD3D11Texture2D)
 
     cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ);
 
-    cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr();
+    cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
     status = clEnqueueAcquireD3D11ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
     if (status != CL_SUCCESS)
         CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D11ObjectsKHR failed");
@@ -795,7 +795,7 @@ void convertFromD3D11Texture2D(ID3D11Texture2D* pD3D11Texture2D, OutputArray dst
 
     cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ);
 
-    cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr();
+    cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
     status = clEnqueueAcquireD3D11ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
     if (status != CL_SUCCESS)
         CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D11ObjectsKHR failed");
@@ -884,7 +884,7 @@ void convertToD3D10Texture2D(InputArray src, ID3D10Texture2D* pD3D10Texture2D)
 
     cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ);
 
-    cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr();
+    cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
     status = clEnqueueAcquireD3D10ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
     if (status != CL_SUCCESS)
         CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D10ObjectsKHR failed");
@@ -943,7 +943,7 @@ void convertFromD3D10Texture2D(ID3D10Texture2D* pD3D10Texture2D, OutputArray dst
 
     cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ);
 
-    cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr();
+    cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
     status = clEnqueueAcquireD3D10ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
     if (status != CL_SUCCESS)
         CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D10ObjectsKHR failed");
@@ -1038,7 +1038,7 @@ void convertToDirect3DSurface9(InputArray src, IDirect3DSurface9* pDirect3DSurfa
 
     cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ);
 
-    cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr();
+    cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
     status = clEnqueueAcquireDX9MediaSurfacesKHR(q, 1, &clImage, 0, NULL, NULL);
     if (status != CL_SUCCESS)
         CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireDX9MediaSurfacesKHR failed");
@@ -1104,7 +1104,7 @@ void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9, OutputArr
 
     cl_mem clBuffer = (cl_mem)u.handle(ACCESS_WRITE);
 
-    cl_command_queue q = (cl_command_queue)CommandQueue::getDefault().ptr();
+    cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
     status = clEnqueueAcquireDX9MediaSurfacesKHR(q, 1, &clImage, 0, NULL, NULL);
     if (status != CL_SUCCESS)
         CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireDX9MediaSurfacesKHR failed");
index 8a11d09..6e5acee 100644 (file)
@@ -1496,11 +1496,6 @@ Size _InputArray::size(int i) const
         return d_mat->size();
     }
 
-    if( k == OCL_MAT )
-    {
-        CV_Error(CV_StsNotImplemented, "This method is not implemented for oclMat yet");
-    }
-
     CV_Assert( k == CUDA_MEM );
     //if( k == CUDA_MEM )
     {
@@ -1680,11 +1675,6 @@ int _InputArray::dims(int i) const
         return 2;
     }
 
-    if( k == OCL_MAT )
-    {
-        return 2;
-    }
-
     CV_Assert( k == CUDA_MEM );
     //if( k == CUDA_MEM )
     {
@@ -1842,11 +1832,6 @@ bool _InputArray::empty() const
     if( k == OPENGL_BUFFER )
         return ((const ogl::Buffer*)obj)->empty();
 
-    if( k == OCL_MAT )
-    {
-        CV_Error(CV_StsNotImplemented, "This method is not implemented for oclMat yet");
-    }
-
     if( k == GPU_MAT )
         return ((const cuda::GpuMat*)obj)->empty();
 
@@ -1882,7 +1867,7 @@ bool _InputArray::isContinuous(int i) const
         return vv[i].isContinuous();
     }
 
-    CV_Error(CV_StsNotImplemented, "This method is not implemented for oclMat yet");
+    CV_Error(CV_StsNotImplemented, "Unknown/unsupported array type");
     return false;
 }
 
index 43a96a2..331a9ba 100644 (file)
@@ -3365,7 +3365,7 @@ protected:
     {
         CV_DbgAssert(entry.clBuffer_ == NULL);
         entry.capacity_ = alignSize(size, (int)_allocationGranularity(size));
-        Context2& ctx = Context2::getDefault();
+        Context& ctx = Context::getDefault();
         cl_int retval = CL_SUCCESS;
         entry.clBuffer_ = clCreateBuffer((cl_context)ctx.ptr(), CL_MEM_READ_WRITE, entry.capacity_, 0, &retval);
         CV_Assert(retval == CL_SUCCESS);
index 65f0edf..248ff00 100644 (file)
@@ -25,7 +25,7 @@
 //
 //   * Redistribution's in binary form must reproduce the above copyright notice,
 //     this list of conditions and the following disclaimer in the documentation
-//     and/or other oclMaterials provided with the distribution.
+//     and/or other materials provided with the distribution.
 //
 //   * The name of the copyright holders may not be used to endorse or promote products
 //     derived from this software without specific prior written permission.
index 8a92faa..8e5b4d0 100644 (file)
@@ -119,7 +119,7 @@ CV_EXPORTS void randu(InputOutputArray dst);
 inline void safeFinish()
 {
     if (cv::ocl::useOpenCL())
-        cv::ocl::finish2();
+        cv::ocl::finish();
 }
 
 } // namespace perf
index 67d0532..23f9c6f 100644 (file)
 #include "opencv2/superres/optical_flow.hpp"
 #include "opencv2/opencv_modules.hpp"
 
-#if defined(HAVE_OPENCV_OCL)
-#include "opencv2/ocl/ocl.hpp"
-#endif
-
 using namespace std;
 using namespace cv;
 using namespace cv::superres;
-bool useOclChanged;
+
 #define MEASURE_TIME(op) \
     { \
         TickMeter tm; \
@@ -50,40 +46,11 @@ static Ptr<DenseOpticalFlowExt> createOptFlow(const string& name, bool useGpu)
     else if (name == "pyrlk")
         return createOptFlow_PyrLK_CUDA();
     else
-    {
         cerr << "Incorrect Optical Flow algorithm - " << name << endl;
-    }
-    return Ptr<DenseOpticalFlowExt>();
-}
-#if defined(HAVE_OPENCV_OCL)
-static Ptr<DenseOpticalFlowExt> createOptFlow(const string& name)
-{
-    if (name == "farneback")
-    {
-        return createOptFlow_Farneback_OCL();
-    }
-    else if (name == "simple")
-    {
-        useOclChanged = true;
-        std::cout<<"simple on OpenCL has not been implemented. Use CPU instead!\n";
-        return createOptFlow_Simple();
-    }
-    else if (name == "tvl1")
-        return createOptFlow_DualTVL1_OCL();
-    else if (name == "brox")
-    {
-        std::cout<<"brox has not been implemented!\n";
-        return Ptr<DenseOpticalFlowExt>();
-    }
-    else if (name == "pyrlk")
-        return createOptFlow_PyrLK_OCL();
-    else
-    {
-        cerr << "Incorrect Optical Flow algorithm - " << name << endl;
-    }
+
     return Ptr<DenseOpticalFlowExt>();
 }
-#endif
+
 int main(int argc, const char* argv[])
 {
     useOclChanged = false;
@@ -94,7 +61,7 @@ int main(int argc, const char* argv[])
         "{ i iterations | 180       | Iteration count }"
         "{ t temporal   | 4         | Radius of the temporal search area }"
         "{ f flow       | farneback | Optical flow algorithm (farneback, simple, tvl1, brox, pyrlk) }"
-        "{ g            | false     | CPU as default device, cuda for CUDA and ocl for OpenCL }"
+        "{ g            | false     | CPU as default device, cuda for CUDA }"
         "{ h help       | false     | Print help message }"
     );
 
@@ -102,7 +69,7 @@ int main(int argc, const char* argv[])
     {
         cout << "This sample demonstrates Super Resolution algorithms for video sequence" << endl;
         cmd.printMessage();
-        return 0;
+        return EXIT_SUCCESS;
     }
 
     const string inputVideoName = cmd.get<string>("video");
@@ -115,60 +82,19 @@ int main(int argc, const char* argv[])
 
     std::transform(gpuOption.begin(), gpuOption.end(), gpuOption.begin(), ::tolower);
 
-    bool useCuda = false;
-    bool useOcl = false;
-
-    if(gpuOption.compare("ocl") == 0)
-        useOcl = true;
-    else if(gpuOption.compare("cuda") == 0)
-        useCuda = true;
-
-#ifndef HAVE_OPENCV_OCL
-    if(useOcl)
-    {
-        {
-            cout<<"OPENCL is not compiled\n";
-            return 0;
-        }
-    }
-#endif
-#if defined(HAVE_OPENCV_OCL)
-    if(useCuda)
-    {
-        CV_Assert(!useOcl);
-    }
-#endif
+    bool useCuda = gpuOption.compare("cuda") == 0;
     Ptr<SuperResolution> superRes;
 
-
-#if defined(HAVE_OPENCV_OCL)
-    if(useOcl)
-    {
-        Ptr<DenseOpticalFlowExt> of = createOptFlow(optFlow);
-        if (of.empty())
-            exit(-1);
-        if(useOclChanged)
-        {
-            superRes = createSuperResolution_BTVL1();
-            useOcl = !useOcl;
-        }else
-            superRes = createSuperResolution_BTVL1_OCL();
-        superRes->set("opticalFlow", of);
-    }
+    if (useCuda)
+        superRes = createSuperResolution_BTVL1_CUDA();
     else
-#endif
-    {
-        if (useCuda)
-            superRes = createSuperResolution_BTVL1_CUDA();
-        else
-            superRes = createSuperResolution_BTVL1();
+        superRes = createSuperResolution_BTVL1();
 
-        Ptr<DenseOpticalFlowExt> of = createOptFlow(optFlow, useCuda);
+    Ptr<DenseOpticalFlowExt> of = createOptFlow(optFlow, useCuda);
 
-        if (of.empty())
-            exit(-1);
-        superRes->set("opticalFlow", of);
-    }
+    if (of.empty())
+        return EXIT_FAILURE;
+    superRes->set("opticalFlow", of);
 
     superRes->set("scale", scale);
     superRes->set("iterations", iterations);
@@ -201,11 +127,7 @@ int main(int argc, const char* argv[])
         cout << "Iterations      : " << iterations << endl;
         cout << "Temporal radius : " << temporalAreaRadius << endl;
         cout << "Optical Flow    : " << optFlow << endl;
-#if defined(HAVE_OPENCV_OCL)
-        cout << "Mode            : " << (useCuda ? "CUDA" : useOcl? "OpenCL" : "CPU") << endl;
-#else
         cout << "Mode            : " << (useCuda ? "CUDA" : "CPU") << endl;
-#endif
     }
 
     superRes->setInput(frameSource);
@@ -217,32 +139,8 @@ int main(int argc, const char* argv[])
         cout << '[' << setw(3) << i << "] : ";
         Mat result;
 
-#if defined(HAVE_OPENCV_OCL)
-        cv::ocl::oclMat result_;
-
-        if(useOcl)
-        {
-            MEASURE_TIME(
-            {
-                superRes->nextFrame(result_);
-                ocl::finish();
-            });
-        }
-        else
-#endif
-        {
-            MEASURE_TIME(superRes->nextFrame(result));
-        }
+        MEASURE_TIME(superRes->nextFrame(result));
 
-#ifdef HAVE_OPENCV_OCL
-        if(useOcl)
-        {
-            if(!result_.empty())
-            {
-                result_.download(result);
-            }
-        }
-#endif
         if (result.empty())
             break;