summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevron Rees <tripzero.kev@gmail.com>2014-10-07 08:16:34 -0400
committerKevron Rees <tripzero.kev@gmail.com>2014-10-07 08:16:34 -0400
commitdd8c4aa58c18868fba3c0864100a30419ff766cb (patch)
tree70869157d24888d42eccb4723efed2c0f85fa781
parent8375a2031d060d1327be8643949be07ff1f19845 (diff)
parent23235772113bcac7926f0b83c2e4d253b6269677 (diff)
downloadautomotive-message-broker-dd8c4aa58c18868fba3c0864100a30419ff766cb.tar.gz
Merge pull request #24 from tripzero/master0.11.903
Version 0.11.903
-rw-r--r--CMakeLists.txt17
-rw-r--r--RELEASE2
-rw-r--r--ambd/CMakeLists.txt2
-rw-r--r--ambd/pluginloader.cpp42
-rw-r--r--ambd/pluginloader.h65
-rw-r--r--docs/amb.idl6
-rw-r--r--lib/abstractpropertytype.h12
-rw-r--r--lib/abstractsink.h36
-rw-r--r--plugins/opencvlux/opencvluxplugin.cpp51
-rw-r--r--plugins/testplugin/CMakeLists.txt2
10 files changed, 120 insertions, 115 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0c7e3fd9..b29475e2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,7 +6,7 @@ set(CMAKE_BUILD_TYPE, Debug)
include(FindPkgConfig)
set(PROJECT_NAME "automotive-message-broker")
-set(PROJECT_VERSION "0.11.902")
+set(PROJECT_VERSION "0.11.903")
set(PROJECT_CODENAME "veyron")
set(PROJECT_QUALITY "beta")
@@ -43,7 +43,7 @@ option(usebluez5 "use bluez 5 API" OFF)
#turn on -fpic/-fpie:
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
-list(APPEND CMAKE_CXX_FLAGS "-fpie -pie -std=c++11")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpie -pie -std=c++11")
if(opencvlux_plugin)
message(STATUS "OpenCV Lux plugin enabled")
@@ -74,15 +74,6 @@ if(DOXYGEN_FOUND)
endif(DOXYGEN_FOUND)
endif(enable_docs)
-find_library(libtool_LIBRARY ltdl DOC "Libtool libraries")
-find_path(libtool_INCLUDE_DIR ltdl.h DOC "Libtool headers")
-
-if(libtool_LIBRARY)
- message(STATUS "libltdl / libtool found")
-else(libtool_LIBRARY)
- message(FATAL_ERROR "libltdl / libtool missing. please install libltdl / libtool")
-endif(libtool_LIBRARY)
-
find_package(Boost REQUIRED)
@@ -92,7 +83,7 @@ pkg_check_modules(json REQUIRED json)
add_definitions(-DDBusServiceName="org.automotive.message.broker")
set(include_dirs ${libtool_INCLUDE_DIR} ${glib_INCLUDE_DIRS} ${gio_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${json_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/lib)
-set(link_libraries -lamb ${libtool_LIBRARY} ${glib_LIBRARIES} ${json_LIBRARIES} -L${CMAKE_CURRENT_BINARY_DIR}/lib)
+set(link_libraries -lamb ${glib_LIBRARIES} ${json_LIBRARIES} -L${CMAKE_CURRENT_BINARY_DIR}/lib)
if(qtmainloop)
message(STATUS "using Qt mainloop")
@@ -122,7 +113,7 @@ if(qtmainloop)
endif(qtmainloop)
if(usebluez5)
- add_definitions(-DUSE_BLUEZ5)
+ add_definitions(-DUSE_BLUEZ5)
endif(usebluez5)
diff --git a/RELEASE b/RELEASE
index de33af81..35689225 100644
--- a/RELEASE
+++ b/RELEASE
@@ -7,6 +7,7 @@ New features:
- New bluetooth spp plugin
- cangen and cansim plugins simulate a real CAN network.
- New priority queue option. properties are routed according to priority.
+- OpenCV plugin video logging: record video with speed overlay
Changes:
- Deprecated and removed the "FooChanged" (where "Foo" is a property like "VehicleSpeed") signal
@@ -22,3 +23,4 @@ Changes:
Fixes:
- database plugin updated to use zones
- obd-II plugin updated to use bluez5 APIs
+- openCV plugin fixed crashes
diff --git a/ambd/CMakeLists.txt b/ambd/CMakeLists.txt
index 38613d8a..184fc4d5 100644
--- a/ambd/CMakeLists.txt
+++ b/ambd/CMakeLists.txt
@@ -15,7 +15,7 @@ endif(qtmainloop)
add_executable(ambd ${ambd_sources})
include_directories(${include_dirs} )
-target_link_libraries(ambd ${link_libraries} amb)
+target_link_libraries(ambd ${link_libraries} dl amb)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.in ${CMAKE_CURRENT_BINARY_DIR}/config @ONLY)
diff --git a/ambd/pluginloader.cpp b/ambd/pluginloader.cpp
index d2470b8c..f821907b 100644
--- a/ambd/pluginloader.cpp
+++ b/ambd/pluginloader.cpp
@@ -45,12 +45,6 @@ std::string get_file_contents(const char *filename)
}
PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(NULL), routingEngine(nullptr), mMainLoop(nullptr)
{
- if(lt_dlinit())
- {
- cerr<<"error initializing libtool: "<<__FILE__<<" - "<<__FUNCTION__<<":"<<__LINE__<<" "<<lt_dlerror()<<endl;
- throw std::runtime_error("Error initializing libtool. Aborting");
- }
-
DebugOut()<<"Loading config file: "<<configFile<<endl;
json_object *rootobject;
json_tokener *tokener = json_tokener_new();
@@ -75,7 +69,7 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N
// Handle extra characters after parsed object as desired.
// e.g. issue an error, parse another object from that point, etc...
}
-
+
json_object *coreobject = json_object_object_get(rootobject,"routingEngine");
if (coreobject)
{
@@ -151,7 +145,7 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N
DebugOut()<<"No mainloop specified in config. Using glib by default."<<endl;
mMainLoop = new GlibMainLoop(argc,argv);
}
-
+
json_object *sourcesobject = json_object_object_get(rootobject,"sources");
if(!sourcesobject)
@@ -159,22 +153,22 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N
DebugOut()<<"Error getting sources member: "<<endl;
throw std::runtime_error("Error getting sources member");
}
-
+
//g_assert(json_reader_is_array(reader));
g_assert(json_object_get_type(sourcesobject)==json_type_array);
-
-
+
+
array_list *sourceslist = json_object_get_array(sourcesobject);
if (!sourceslist)
{
DebugOut() << "Error getting source list" << endl;
throw std::runtime_error("Error getting sources list");
}
-
+
for(int i=0; i < array_list_length(sourceslist); i++)
{
json_object *obj = (json_object*)array_list_get_idx(sourceslist,i); //This is an object
-
+
std::map<std::string, std::string> configurationMap;
json_object_object_foreach(obj, key, val)
{
@@ -186,7 +180,7 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N
string path = configurationMap["path"];
AbstractSource* plugin = loadPlugin<AbstractSource*>(path,configurationMap);
-
+
if(plugin != nullptr)
{
mSources.push_back(plugin);
@@ -195,9 +189,9 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N
//json_object_put(sourcesobject);
///read the sinks:
-
+
json_object *sinksobject = json_object_object_get(rootobject,"sinks");
-
+
if (!sinksobject)
{
DebugOut() << "Error getting sink object" << endl;
@@ -212,8 +206,8 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N
DebugOut() << "Error getting sink list" << endl;
throw std::runtime_error("Error getting sink list");
}
-
-
+
+
for(int i=0; i < array_list_length(sinkslist); i++)
{
json_object *obj = (json_object*)array_list_get_idx(sinkslist,i);
@@ -227,7 +221,7 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N
configurationMap[key] = valstr;
}
-
+
string path = configurationMap["path"];
AbstractSinkManager* plugin = loadPlugin<AbstractSinkManager*>(path, configurationMap);
@@ -262,15 +256,13 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N
PluginLoader::~PluginLoader()
{
- for(auto itr = mSinkManagers.begin(); itr != mSinkManagers.end(); itr++)
+ for(auto i :mSinkManagers)
{
- delete *itr;
+ delete i;
}
- auto handle = openHandles.begin();
- while(handle != openHandles.end())
- lt_dlclose(*handle++);
- lt_dlexit();
+ for(auto handle : openHandles)
+ dlclose(handle);
}
IMainLoop *PluginLoader::mainloop()
diff --git a/ambd/pluginloader.h b/ambd/pluginloader.h
index 224c3501..e92dfb38 100644
--- a/ambd/pluginloader.h
+++ b/ambd/pluginloader.h
@@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <string>
#include <functional>
-#include <ltdl.h>
+#include <dlfcn.h>
#include <iostream>
#include "abstractsource.h"
@@ -49,43 +49,34 @@ public:
IMainLoop* mainloop();
std::string errorString();
-
-
+
+
private: ///methods:
-
+
template<class T>
T loadPlugin(string pluginName, map<string, string> config)
{
DebugOut()<<"Loading plugin: "<<pluginName<<endl;
-
- if(lt_dlinit())
- {
- mErrorString = lt_dlerror();
- DebugOut(DebugOut::Error)<<"error initializing libtool: "<<__FILE__<<" - "<<__FUNCTION__<<":"<<__LINE__<<" "<<mErrorString<<endl;
- return nullptr;
- }
-
- lt_dlerror();
-
- lt_dlhandle handle = lt_dlopenext(pluginName.c_str());
-
+
+ void* handle = dlopen(pluginName.c_str(), RTLD_LAZY);
+
if(!handle)
{
- mErrorString = lt_dlerror();
+ mErrorString = dlerror();
DebugOut(DebugOut::Error)<<"error opening plugin: "<<pluginName<<" in "<<__FILE__<<" - "<<__FUNCTION__<<":"<<__LINE__<<" "<<mErrorString<<endl;
return nullptr;
}
-
- f_create = (create_t *)lt_dlsym(handle, "create");
-
- //mErrorString = lt_dlerror();
-
- if(f_create)
+
+ openHandles.push_back(handle);
+
+ f_create = (create_t *)dlsym(handle, "create");
+
+ if(f_create)
{
void* obj = f_create(routingEngine, config);
return static_cast<T>( obj );
}
-
+
return nullptr;
}
@@ -93,17 +84,18 @@ private: ///methods:
{
DebugOut()<<"Loading plugin: "<<pluginName<<endl;
- lt_dlhandle handle = lt_dlopenext(pluginName.c_str());
+ void* handle = dlopen(pluginName.c_str(), RTLD_LAZY);
if(!handle)
{
- mErrorString = lt_dlerror();
+ mErrorString = dlerror();
DebugOut(DebugOut::Error)<<"error opening plugin: "<<pluginName<<" in "<<__FILE__<<" - "<<__FUNCTION__<<":"<<__LINE__<<" "<<mErrorString<<endl;
return nullptr;
}
+
openHandles.push_back(handle);
- m_create = (create_mainloop_t *)lt_dlsym(handle, "create");
+ m_create = (create_mainloop_t *)dlsym(handle, "create");
if(m_create)
{
@@ -117,17 +109,18 @@ private: ///methods:
{
DebugOut()<<"Loading plugin: "<<pluginName<<endl;
- lt_dlhandle handle = lt_dlopenext(pluginName.c_str());
+ void* handle = dlopen(pluginName.c_str(), RTLD_LAZY);
if(!handle)
{
- mErrorString = lt_dlerror();
+ mErrorString = dlerror();
cerr<<"error opening plugin: "<<pluginName<<" in "<<__FILE__<<" - "<<__FUNCTION__<<":"<<__LINE__<<" "<<mErrorString<<endl;
return nullptr;
}
+
openHandles.push_back(handle);
- r_create = (createRoutingEngine *)lt_dlsym(handle, "create");
+ r_create = (createRoutingEngine *)dlsym(handle, "create");
if(r_create)
{
@@ -137,17 +130,17 @@ private: ///methods:
return nullptr;
}
-
+
private:
-
+
std::string mPluginPath;
std::string mErrorString;
-
+
AbstractRoutingEngine* routingEngine;
-
+
SourceList mSources;
list<AbstractSinkManager*> mSinkManagers;
-
+
create_t * f_create;
create_mainloop_t * m_create;
createRoutingEngine * r_create;
@@ -155,7 +148,7 @@ private:
IMainLoop* mMainLoop;
- std::vector<lt_dlhandle> openHandles;
+ std::vector<void*> openHandles;
};
#endif // PLUGINLOADER_H
diff --git a/docs/amb.idl b/docs/amb.idl
index cea54980..35a7cc5f 100644
--- a/docs/amb.idl
+++ b/docs/amb.idl
@@ -968,7 +968,11 @@ interface org.automotive.AirbagStatus extends VehiclePropertyType {
attribute UInt16 AirbagStatus readonly
}
-enumeration
+enumeration AirbagStatus {
+ inactive = 0,
+ active = 1,
+ deployed = 2
+}
/*!
* Deprecated. Use "Door". Remove in 0.13
diff --git a/lib/abstractpropertytype.h b/lib/abstractpropertytype.h
index c22d2ff5..decc456a 100644
--- a/lib/abstractpropertytype.h
+++ b/lib/abstractpropertytype.h
@@ -144,7 +144,7 @@ public:
*/
Priority priority;
- void setValue(boost::any val)
+ virtual void setValue(boost::any val)
{
mValue = val;
timestamp = amb::currentTime();
@@ -453,6 +453,16 @@ public:
return value<T>();
}
+ void setValue(T val)
+ {
+ AbstractPropertyType::setValue(val);
+ }
+
+ void setValue(boost::any val)
+ {
+ AbstractPropertyType::setValue(val);
+ }
+
private:
//GVariant* mVariant;
diff --git a/lib/abstractsink.h b/lib/abstractsink.h
index 479f2e08..6494adec 100644
--- a/lib/abstractsink.h
+++ b/lib/abstractsink.h
@@ -1,19 +1,19 @@
/*
- Copyright (C) 2012 Intel Corporation
+ Copyright (C) 2012 Intel Corporation
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -43,9 +43,9 @@ class AbstractSink
public:
AbstractSink(AbstractRoutingEngine* engine, map<string, string> config);
virtual ~AbstractSink();
-
+
///Pure virtual methods:
-
+
/*! uuid() is a unique identifier
* @return a guid-style unique identifier
*/
@@ -63,7 +63,7 @@ public:
* @arg supportedProperties the new list of supported properties.
*/
virtual void supportedChanged(const PropertyList & supportedProperties) = 0;
-
+
protected:
/*!
* \brief routingEngine is the core of AMB. It is used to pass plugin and property information to other plugins
@@ -73,14 +73,14 @@ protected:
};
-/// TODO: this class actually serves no purpose.
+/// TODO: deprecate in 0.13.
class AbstractSinkManager
{
public:
-
+
AbstractSinkManager(AbstractRoutingEngine* engine, map<string, string> config);
virtual ~AbstractSinkManager(){}
-
+
protected:
AbstractRoutingEngine* routingEngine;
map<string, string> configuration;
diff --git a/plugins/opencvlux/opencvluxplugin.cpp b/plugins/opencvlux/opencvluxplugin.cpp
index f4433045..d3874014 100644
--- a/plugins/opencvlux/opencvluxplugin.cpp
+++ b/plugins/opencvlux/opencvluxplugin.cpp
@@ -202,6 +202,10 @@ const string OpenCvLuxPlugin::uuid()
void OpenCvLuxPlugin::getPropertyAsync(AsyncPropertyReply *reply)
{
+ reply->timedout = [this](AsyncPropertyReply* reply) {
+ removeOne(&replyQueue, reply);
+ };
+
if(!shared->m_capture || !shared->m_capture->isOpened())
{
/// we want to turn on the camera for one shot to get an image and determine the intensity
@@ -214,18 +218,18 @@ void OpenCvLuxPlugin::getPropertyAsync(AsyncPropertyReply *reply)
{
replyQueue.push_back(reply);
}
- if(reply->property == VideoLogging)
+ else if(reply->property == VideoLogging)
{
BasicPropertyType<bool> tmp(VideoLogging, shared->loggingOn);
reply->value = &tmp;
reply->success = true;
reply->completed(reply);
}
-
else ///We don't support what you are asking for. Reply false
{
- reply->value = NULL;
+ reply->value = nullptr;
reply->success = false;
+ reply->error = AsyncPropertyReply::InvalidOperation;
reply->completed(reply);
}
}
@@ -327,10 +331,10 @@ static int grabImage(void *data)
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);
+ QFuture<uint> future = QtConcurrent::run(evalImage, m_image, shared);
watcher->setFuture(future);
- QtConcurrent::run(shared->parent, &OpenCvLuxPlugin::writeVideoFrame,m_image);
+ QtConcurrent::run(shared->parent, &OpenCvLuxPlugin::writeVideoFrame, m_image);
}
else
{
@@ -345,14 +349,17 @@ static int grabImage(void *data)
return true;
}
- delete shared->m_capture;
- shared->m_capture = NULL;
return false;
-
}
static uint evalImage(cv::Mat qImg, OpenCvLuxPlugin::Shared *shared)
{
+ if(qImg.empty())
+ {
+ DebugOut(DebugOut::Warning)<<"Empty image frame."<<endl;
+ return 0;
+ }
+
cv::Scalar avgPixelIntensity;
@@ -404,29 +411,34 @@ static uint evalImage(cv::Mat qImg, OpenCvLuxPlugin::Shared *shared)
bool OpenCvLuxPlugin::init()
{
- if(shared->m_capture) delete shared->m_capture;
-
- if(shared->kinect)
+ if(!shared->m_capture && shared->kinect)
{
shared->m_capture = new cv::VideoCapture(CV_CAP_OPENNI);
}
- else if(device == "")
- shared->m_capture = new cv::VideoCapture(0);
- else shared->m_capture = new cv::VideoCapture(atoi(device.c_str()));
+ else if(!shared->m_capture)
+ {
+ if(device == "")
+ shared->m_capture = new cv::VideoCapture(0);
+ else
+ shared->m_capture = new cv::VideoCapture(atoi(device.c_str()));
+ }
if(!shared->m_capture->isOpened())
{
DebugOut()<<"we failed to open camera device ("<<device<<") or no camera found"<<endl;
return false;
}
- if(configuration.find("logging") != configuration.end() && configuration["logging"] == "true" && !shared->mWriter || !shared->mWriter->isOpened())
+
+ if(configuration.find("logging") != configuration.end() &&
+ configuration["logging"] == "true" &&
+ (!shared->mWriter || !shared->mWriter->isOpened()))
{
cv::Size s = cv::Size((int) shared->m_capture->get(CV_CAP_PROP_FRAME_WIDTH),
(int) shared->m_capture->get(CV_CAP_PROP_FRAME_HEIGHT));
std::string codec = configuration["codec"];
- if(codec == "" || codec.size() != 4)
+ if(codec.empty() || codec.size() != 4)
{
DebugOut(DebugOut::Warning)<<"Invalid codec. Using default: MJPG"<<endl;
codec = "MJPG";
@@ -434,13 +446,13 @@ bool OpenCvLuxPlugin::init()
std::string filename = configuration["logfile"];
- if(filename == "") filename = "/tmp/video.avi";
+ if(filename.empty()) filename = "/tmp/video.avi";
boost::algorithm::to_upper(codec);
if(shared->mWriter) delete shared->mWriter;
- shared->mWriter = new cv::VideoWriter(filename,CV_FOURCC(codec.at(0),codec.at(1),codec.at(2),codec.at(3)),30,s);
+ shared->mWriter = new cv::VideoWriter(filename, CV_FOURCC(codec.at(0), codec.at(1), codec.at(2), codec.at(3)),30,s);
}
DebugOut()<<"camera frame width: "<<shared->m_capture->get(CV_CAP_PROP_FRAME_WIDTH)<<endl;
@@ -513,7 +525,8 @@ void OpenCvLuxPlugin::updateProperty(uint lux)
reply->value = extBrightness.get();
reply->success = true;
try{
- reply->completed(reply);
+ if(reply->completed)
+ reply->completed(reply);
}
catch(...)
{
diff --git a/plugins/testplugin/CMakeLists.txt b/plugins/testplugin/CMakeLists.txt
index e2750dbf..f39c3423 100644
--- a/plugins/testplugin/CMakeLists.txt
+++ b/plugins/testplugin/CMakeLists.txt
@@ -9,7 +9,7 @@ set(testplugin_headers testplugin.h)
set(testplugin_sources testplugin.cpp)
add_library(testplugin MODULE ${testplugin_sources})
set_target_properties(testplugin PROPERTIES PREFIX "")
-target_link_libraries(testplugin amb -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries})
+target_link_libraries(testplugin -L${CMAKE_CURRENT_BINARY_DIR}/lib)
install(TARGETS testplugin LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH})