From: Ilya Lavrenov Date: Fri, 31 Jan 2014 17:00:16 +0000 (+0400) Subject: cleaned up super_resolution sample from old OCL X-Git-Tag: submit/tizen_ivi/20141117.190038~2^2~642^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e8579fe9b91a1186f41fca348ed351f1d6f4307;p=profile%2Fivi%2Fopencv.git cleaned up super_resolution sample from old OCL --- diff --git a/.project b/.project deleted file mode 100644 index bf2777f..0000000 --- a/.project +++ /dev/null @@ -1,100 +0,0 @@ - - - opencv - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?children? - ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|?name?=entry\\\\\\\|\\\|\|| - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - /home/ilya/Documents/Programming/Builds/opencv_debug/bin - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - org.eclipse.cdt.codan.core.codanBuilder - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.eclipse.cdt.codan.core.codanNature - - - - bin - 2 - /home/ilya/Documents/Programming/Builds/opencv_debug/bin - - - diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 8099520..6409222 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -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(); diff --git a/modules/core/src/directx.cpp b/modules/core/src/directx.cpp index 23addbf..4d9fd6c 100644 --- a/modules/core/src/directx.cpp +++ b/modules/core/src/directx.cpp @@ -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"); diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 8a11d09..6e5acee 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -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; } diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 43a96a2..331a9ba 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -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); diff --git a/modules/core/src/opencl/mulspectrums.cl b/modules/core/src/opencl/mulspectrums.cl index 65f0edf..248ff00 100644 --- a/modules/core/src/opencl/mulspectrums.cl +++ b/modules/core/src/opencl/mulspectrums.cl @@ -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. diff --git a/modules/ts/include/opencv2/ts/ocl_perf.hpp b/modules/ts/include/opencv2/ts/ocl_perf.hpp index 8a92faa..8e5b4d0 100644 --- a/modules/ts/include/opencv2/ts/ocl_perf.hpp +++ b/modules/ts/include/opencv2/ts/ocl_perf.hpp @@ -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 diff --git a/samples/gpu/super_resolution.cpp b/samples/gpu/super_resolution.cpp index 67d0532..23f9c6f 100644 --- a/samples/gpu/super_resolution.cpp +++ b/samples/gpu/super_resolution.cpp @@ -10,14 +10,10 @@ #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 createOptFlow(const string& name, bool useGpu) else if (name == "pyrlk") return createOptFlow_PyrLK_CUDA(); else - { cerr << "Incorrect Optical Flow algorithm - " << name << endl; - } - return Ptr(); -} -#if defined(HAVE_OPENCV_OCL) -static Ptr 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(); - } - else if (name == "pyrlk") - return createOptFlow_PyrLK_OCL(); - else - { - cerr << "Incorrect Optical Flow algorithm - " << name << endl; - } + return Ptr(); } -#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("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 superRes; - -#if defined(HAVE_OPENCV_OCL) - if(useOcl) - { - Ptr 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 of = createOptFlow(optFlow, useCuda); + Ptr 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;