try-catch some functions that might throw
authorKevron Rees <kevron.m.rees@intel.com>
Mon, 3 Nov 2014 23:10:01 +0000 (15:10 -0800)
committerKevron Rees <kevron.m.rees@intel.com>
Thu, 6 Nov 2014 17:20:45 +0000 (09:20 -0800)
examples/opencvdbusconfig.in
plugins/opencvlux/opencvluxplugin.cpp

index a374398..b85bc4b 100644 (file)
@@ -4,7 +4,7 @@
     {
       "name" : "OpenCV LUX",
       "path" : "@PLUGIN_INSTALL_PATH@/opencvluxplugin.so",
-      "threaded" : "true",
+      "threaded" : "false",
       "cuda" : "false",
       "opencl" : "true",
       "fps" : "30",
index 46fa62e..6938539 100644 (file)
@@ -383,7 +383,16 @@ static int grabImage(void *data)
        }
 
        if(shared->ddd)
-               shared->parent->detectEyes(m_image);
+       {
+               try
+               {
+                       shared->parent->detectEyes(m_image);
+               }
+               catch(...)
+               {
+                       DebugOut(DebugOut::Warning) << "DDD detection exception: "<< endl;
+               }
+       }
 
        if(shared->threaded)
        {
@@ -398,9 +407,18 @@ static int grabImage(void *data)
        else
        {
                shared->parent->writeVideoFrame(m_image);
-               int lux = evalImage(m_image, shared);
+               try
+               {
+                       int lux = evalImage(m_image, shared);
+                       shared->parent->updateProperty(lux);
+               }
+               catch(...)
+               {
+                       DebugOut(DebugOut::Warning) << "Exception caught "<< __FUNCTION__ << endl;
+               }
+
                //detectLight(m_image,shared);
-               shared->parent->updateProperty(lux);
+
        }
 
        if(shared->mRequests.size())
@@ -602,12 +620,19 @@ void OpenCvLuxPlugin::updateProperty(uint lux)
 
 void OpenCvLuxPlugin::imgProcResult()
 {
-       QFutureWatcher<uint> *watcher = dynamic_cast<QFutureWatcher<uint>*>(sender());
+       try
+       {
+               QFutureWatcher<uint> *watcher = dynamic_cast<QFutureWatcher<uint>*>(sender());
 
-       uint lux = watcher->result();
-       shared->parent->updateProperty(lux);
+               uint lux = watcher->result();
+               shared->parent->updateProperty(lux);
 
-       watcher->deleteLater();
+               watcher->deleteLater();
+       }
+       catch(...)
+       {
+               DebugOut(DebugOut::Warning) << "exception caught getting img processing result" << endl;
+       }
 }
 
 TrafficLight::Color detectLight(cv::Mat img, OpenCvLuxPlugin::Shared *shared)