#include <murphy/common.h>
-#ifdef USE_QT_CORE
+/*#ifdef USE_QT_CORE
#include <murphy/qt/qt-glue.h>
-#else
+#else*/
+
#include <murphy/glib/glib-glue.h>
-#endif
+//#endif
// #include <vehicleproperty.h>
// #include <abstractpropertytype.h>
// main loop integration
-#ifdef USE_QT_CORE
+/*#ifdef USE_QT_CORE
m_ml = mrp_mainloop_qt_get();
debugOut("Murphy plugin initialized using QT mainloop!");
-#else
+#else*/
GMainLoop *g_ml = g_main_loop_new(NULL, TRUE);
m_ml = mrp_mainloop_glib_get(g_ml);
debugOut("Murphy plugin initialized using glib mainloop!");
-#endif
+//#endif
setConfiguration(config);
}
remove_definitions(-DCUDA)
endif(cuda)
-include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${OpenCV_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
+find_package(Qt5Core REQUIRED)
+
+if(Qt5Core_FOUND)
+ message(STATUS "using Qt5")
+
+ set(QT_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} )
+ set(QT_LIBRARIES ${Qt5Core_LIBRARIES} )
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
+ message(STATUS "size of void_p: ${CMAKE_SIZEOF_VOID_P}")
+ if(CMAKE_SIZEOF_VOID_P MATCHES "8")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcmodel=large")
+ endif(CMAKE_SIZEOF_VOID_P MATCHES "8")
+ add_definitions(${Qt5Core_DEFINITIONS})
+
+endif(Qt5Core_FOUND)
+set(CMAKE_AUTOMOC ON)
+
+include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${OpenCV_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${QT_INCLUDE_DIRS})
set(opencvluxplugin_headers opencvluxplugin.h)
set(opencvluxplugin_sources opencvluxplugin.cpp)
-add_library(opencvluxplugin MODULE ${opencvluxplugin_sources} ${opencvluxplugin_headers_moc})
+add_library(opencvluxplugin MODULE ${opencvluxplugin_sources})
set_target_properties(opencvluxplugin PROPERTIES PREFIX "")
-target_link_libraries(opencvluxplugin amb -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries} ${OpenCV_LIBS} ${Boost_LIBRARIES})
+target_link_libraries(opencvluxplugin amb -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries} ${OpenCV_LIBS} ${Boost_LIBRARIES} ${QT_LIBRARIES})
install(TARGETS opencvluxplugin LIBRARY DESTINATION lib${LIB_SUFFIX}/automotive-message-broker)
#include <iostream>
#include <opencv2/imgproc/imgproc.hpp>
+#include <QFuture>
+#include <QFutureWatcher>
+#include <QtConcurrent/QtConcurrent>
+
#ifdef OPENCL
#include <opencv2/ocl/ocl.hpp>
#endif
*(shared->m_capture) >> m_image;
}
- /*if(shared->threaded)
+ if(shared->threaded)
{
+ QFutureWatcher<uint> *watcher = new QFutureWatcher<uint>();
+ QObject::connect(watcher, &QFutureWatcher<uint>::finished, shared->parent, &OpenCvLuxPlugin::imgProcResult);
+ QFuture<uint> future = QtConcurrent::run( evalImage, m_image, shared);
+ watcher->setFuture(future);
}
- else*/
+ else
{
- int lux = evalImage(m_image,shared);
+ int lux = evalImage(m_image, shared);
detectLight(m_image,shared);
shared->parent->updateProperty(lux);
}
{
VehicleProperty::ExteriorBrightnessType l(lux);
- for(auto itr = replyQueue.begin(); itr != replyQueue.end(); itr++)
+ for(auto reply : replyQueue)
{
- AsyncPropertyReply* reply = *itr;
reply->value = &l;
reply->success = true;
try{
}
+void OpenCvLuxPlugin::imgProcResult()
+{
+ QFutureWatcher<uint> *watcher = dynamic_cast<QFutureWatcher<uint>* >(sender());
+ uint lux = watcher->result();
+ shared->parent->updateProperty(lux);
+}
TrafficLight::Color detectLight(cv::Mat img, OpenCvLuxPlugin::Shared *shared)
{
#include <opencv/cv.h>
#include <opencv2/highgui/highgui.hpp>
+#include <QObject>
+
using namespace std;
-class OpenCvLuxPlugin: public AbstractSource
+class OpenCvLuxPlugin: public QObject, public AbstractSource
{
-
+Q_OBJECT
public:
struct Shared
void updateProperty(uint lux);
-
+public slots:
+ void imgProcResult();
private: /// methods: