stubbed in threading using boost::future
authorKevron Rees <tripzero.kev@gmail.com>
Mon, 11 Nov 2013 17:58:27 +0000 (09:58 -0800)
committerKevron Rees <tripzero.kev@gmail.com>
Mon, 11 Nov 2013 17:58:27 +0000 (09:58 -0800)
plugins/opencvlux/CMakeLists.txt
plugins/opencvlux/opencvluxplugin.cpp

index 17ebedb..64a8d65 100644 (file)
@@ -8,6 +8,9 @@ else(OpenCV_LIBS)
         message(FATAL_ERROR "opencv missing.  please install opencv")
 endif(OpenCV_LIBS)
 
+find_package(Boost COMPONENTS thread REQUIRED)
+find_package(Threads REQUIRED)
+
 #find opencv ocl headers:
 find_path(ocl ocl.hpp PATH_SUFFIXES opencv/ocl opencv2/ocl DOC "opencv ocl headers")
 
@@ -27,14 +30,14 @@ else(cuda)
        message(STATUS "no opencv cuda headers found.  no cuda support")
 endif(cuda)
 
-include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${OpenCV_INCLUDE_DIRS})
+include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${OpenCV_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
 
 set(opencvluxplugin_headers opencvluxplugin.h)
 set(opencvluxplugin_sources opencvluxplugin.cpp)
 
 add_library(opencvluxplugin MODULE ${opencvluxplugin_sources} ${opencvluxplugin_headers_moc})
 set_target_properties(opencvluxplugin PROPERTIES PREFIX "")
-target_link_libraries(opencvluxplugin amb -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries} ${OpenCV_LIBS})
+target_link_libraries(opencvluxplugin amb -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries} ${OpenCV_LIBS} ${Boost_LIBRARIES})
 
 install(TARGETS opencvluxplugin LIBRARY DESTINATION lib${LIB_SUFFIX}/automotive-message-broker)
 
index d2181f0..545a017 100644 (file)
@@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include <iostream>
 #include <boost/assert.hpp>
+#include <boost/thread/future.hpp>
 
 #ifdef OPENCL
 #include <opencv/ocl/ocl.hpp>
@@ -229,9 +230,16 @@ static int grabImage(void *data)
                *(shared->m_capture) >> m_image;
        }
 
-       uint lux = evalImage(m_image,shared);
-
-       shared->parent->updateProperty(lux);
+       /*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*/
+       {
+               int lux = evalImage(m_image,shared);
+               shared->parent->updateProperty(lux);
+       }
 
        if(shared->mRequests.size())
        {