opencl to work with cv 2.4.8
authorKevron Rees <tripzero.kev@gmail.com>
Fri, 17 Jan 2014 19:37:42 +0000 (11:37 -0800)
committerKevron Rees <tripzero.kev@gmail.com>
Fri, 17 Jan 2014 19:39:07 +0000 (11:39 -0800)
plugins/opencvlux/CMakeLists.txt
plugins/opencvlux/opencvluxplugin.cpp

index 3975fb2..b1b4f92 100644 (file)
@@ -8,9 +8,7 @@ else(OpenCV_LIBS)
         message(FATAL_ERROR "opencv missing.  please install opencv")
 endif(OpenCV_LIBS)
 
-#find opencv ocl headers:
-INCLUDE (CheckLibraryExists)
-CHECK_LIBRARY_EXISTS(cl clCreateImage /usr/lib/beignet ocl)
+option(ocl "enable opencl" OFF)
 
 if(ocl)
        message(STATUS "found opencv ocl headers. enabling opencl support. ${ocl}")
@@ -19,13 +17,14 @@ else(ocl)
        message(STATUS "no opencl support")
 endif(ocl)
 
-find_path(cuda gpu.hpp PATH_SUFFIXES opencv/gpu opencv2/gpu DOC "opencv cuda headers")
+option(cuda "enable cuda" OFF)
 
 if(cuda)
        message(STATUS "found opencv cuda headers.  enabling cuda support. ${cuda}")
        add_definitions(-DCUDA)
 else(cuda)
        message(STATUS "no opencv cuda headers found.  no cuda support")
+       remove_definitions(-DCUDA)
 endif(cuda)
 
 include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${OpenCV_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
index 55d0105..f51516e 100644 (file)
@@ -20,8 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 #include "timestamp.h"
 
 #include <iostream>
-#include <boost/assert.hpp>
-#include <boost/thread/future.hpp>
 
 #ifdef OPENCL
 #include <opencv2/ocl/ocl.hpp>
@@ -109,22 +107,34 @@ OpenCvLuxPlugin::OpenCvLuxPlugin(AbstractRoutingEngine* re, map<string, string>
 #ifdef OPENCL
        if(shared->useOpenCl)
        {
-               std::vector<cv::ocl::Info> info;
-               cv::ocl::getDevice(info);
+               cv::ocl::PlatformsInfo platforms;
+               cv::ocl::getOpenCLPlatforms(platforms);
 
-               DebugOut()<<"There are "<<info.size()<<" OpenCL devices on this system"<<endl;
+               for(auto p : platforms)
+               {
+                       DebugOut(1)<<"platform: "<<p->platformName<<" vendor: "<<p->platformVendor<<endl;
+               }
+
+               cv::ocl::DevicesInfo info;
+               cv::ocl::getOpenCLDevices(info, cv::ocl::CVCL_DEVICE_TYPE_ALL);
+
+               DebugOut(1)<<"There are "<<info.size()<<" OpenCL devices on this system"<<endl;
 
                if(!info.size())
                {
-                       DebugOut()<<"No CL devices.  Disabling OpenCL"<<endl;
+                       DebugOut(1)<<"No CL devices.  Disabling OpenCL"<<endl;
                        shared->useOpenCl = false;
                }
+               else
+               {
+                       cv::ocl::setDevice(info[0]);
+               }
 
-               for(cv::ocl::Info i : info)
+               for(auto i : info)
                {
-                       for(auto name : i.DeviceName)
+                       for(auto name : i->deviceName)
                        {
-                               DebugOut()<<"DeviceName: "<<name<<endl;
+                               DebugOut(1)<<"OpenCLDeviceName: "<<name<<endl;
                        }
                }
        }
@@ -248,8 +258,7 @@ static int grabImage(void *data)
 
        /*if(shared->threaded)
        {
-               auto luxFuture = boost::async([m_image, &shared](){ return evalImage(m_image,shared); });
-               luxFuture.then([&shared](boost::shared_future<uint> f) { shared->parent->updateProperty(f.get()); });
+
        }
        else*/
        {