From: Kevron Rees Date: Mon, 18 Mar 2013 23:47:13 +0000 (-0700) Subject: do not run opencv plugin if fail to open camera X-Git-Tag: 0.8.1~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2874af233cdd5aa8e30ca3b3af00764e795dfb90;p=profile%2Fivi%2Fautomotive-message-broker.git do not run opencv plugin if fail to open camera --- diff --git a/plugins/opencvlux/opencvluxplugin.cpp b/plugins/opencvlux/opencvluxplugin.cpp index e5ee9fc..9bfcc70 100644 --- a/plugins/opencvlux/opencvluxplugin.cpp +++ b/plugins/opencvlux/opencvluxplugin.cpp @@ -125,8 +125,8 @@ void OpenCvLuxPlugin::getPropertyAsync(AsyncPropertyReply *reply) { /// we want to turn on the camera for one shot to get an image and determine the intensity - init(); - g_timeout_add(1,grabImage,shared); + if(init()) + g_timeout_add(1,grabImage,shared); } if(reply->property == VehicleProperty::ExteriorBrightness) @@ -156,8 +156,8 @@ void OpenCvLuxPlugin::subscribeToPropertyChanges(VehicleProperty::Property prope { if(!shared->mRequests.size()) { - init(); - g_timeout_add(1000 / shared->fps, grabImage, shared); + if(init()) + g_timeout_add(1000 / shared->fps, grabImage, shared); } shared->mRequests.push_back(property); @@ -245,7 +245,7 @@ static uint evalImage(cv::Mat qImg, OpenCvLuxPlugin::Shared *shared) } -void OpenCvLuxPlugin::init() +bool OpenCvLuxPlugin::init() { if(shared->m_capture) delete shared->m_capture; @@ -260,7 +260,7 @@ void OpenCvLuxPlugin::init() if(!shared->m_capture->isOpened()) { DebugOut()<<"we failed to open camera device ("<m_capture->get(CV_CAP_PROP_FRAME_WIDTH)<m_capture->get(CV_CAP_PROP_FRAME_HEIGHT)<m_capture->get(CV_CAP_PROP_FPS)<