{
/// 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)
{
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);
}
-void OpenCvLuxPlugin::init()
+bool OpenCvLuxPlugin::init()
{
if(shared->m_capture) delete shared->m_capture;
if(!shared->m_capture->isOpened())
{
DebugOut()<<"we failed to open camera device ("<<device<<") or no camera found"<<endl;
- return;
+ return false;
}
DebugOut()<<"camera frame width: "<<shared->m_capture->get(CV_CAP_PROP_FRAME_WIDTH)<<endl;
DebugOut()<<"camera frame height: "<<shared->m_capture->get(CV_CAP_PROP_FRAME_HEIGHT)<<endl;
DebugOut()<<"camera frame fps: "<<shared->m_capture->get(CV_CAP_PROP_FPS)<<endl;
+
+ return true;
}
void OpenCvLuxPlugin::updateProperty(uint lux)