close Warning: Can't use blame annotator:
svn blame failed on trunk/lib/FlairSensorActuator/src/V4LCamera.cpp: 200029 - Couldn't perform atomic initialization

source: flair-src/trunk/lib/FlairSensorActuator/src/V4LCamera.cpp@ 352

Last change on this file since 352 was 352, checked in by Sanahuja Guillaume, 4 years ago

v4lcamera: use pimpl

File size: 4.4 KB
RevLine 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// created: 2014/07/17
6// filename: V4LCamera.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: base class for V4l camera
14//
15//
16/*********************************************************************/
17
18#include "V4LCamera.h"
19#include "V4LCamera_impl.h"
20#include <Image.h>
21#include <FrameworkManager.h>
22
23using std::string;
24using namespace flair::core;
25
26namespace flair {
27namespace sensor {
28
29V4LCamera::V4LCamera(string name,uint8_t camera_index, uint16_t width, uint16_t height,
30 Image::Type::Format format, uint8_t priority)
31 : Thread(getFrameworkManager(), name, priority),
32 Camera(name, width, height, format) {
33
34 pimpl_=new V4LCamera_impl(this,name,camera_index,width,height,format);
35}
36
37V4LCamera::~V4LCamera() {
38 SafeStop();
39 Join();
40 delete pimpl_;
41}
42
43void V4LCamera::Run(void) {
44 pimpl_->Run();
45 /*
46 Time cam_time, new_time, fpsNow, fpsPrev;
47 int fpsCounter = 0;
48
49 cam_time = GetTime();
50 fpsPrev = cam_time;
51
52 while (!ToBeStopped()) {
53 // fps counter
54 fpsCounter++;
55 if (fpsCounter == 100) {
56 fpsNow = GetTime();
57 fps->SetText("fps: %.1f",
58 fpsCounter / ((float)(fpsNow - fpsPrev) / 1000000000.));
59 fpsCounter = 0;
60 fpsPrev = fpsNow;
61 }
62
63 // cam properties
64 if (gain->ValueChanged() == true && autogain->Value() == false)
65 SetGain(gain->Value());
66 if (exposure->ValueChanged() == true && autoexposure->Value() == false)
67 SetExposure(exposure->Value());
68 if (bright->ValueChanged() == true)
69 SetBrightness(bright->Value());
70 if (sat->ValueChanged() == true)
71 SetSaturation(sat->Value());
72 if (contrast->ValueChanged() == true)
73 SetContrast(contrast->Value());
74 if (hue->ValueChanged() == true)
75 SetHue(hue->Value());
76 //if (sharpness->ValueChanged() == true)
77 // cvSetCaptureProperty(capture, CV_CAP_PROP_SHARPNESS, sharpness->Value());
78 if (autogain->ValueChanged() == true) {
79 if (autogain->Value() == true) {
80 gain->setEnabled(false);
81 } else {
82 gain->setEnabled(true);
83 SetGain(gain->Value());
84 }
85 SetAutoGain(autogain->Value());
86 }
87 if (autoexposure->ValueChanged() == true) {
88 if (autoexposure->Value() == true) {
89 exposure->setEnabled(false);
90 } else {
91 exposure->setEnabled(true);
92 SetExposure(exposure->Value());
93 }
94 SetAutoExposure(autoexposure->Value());
95 }
96 //if (awb->ValueChanged() == true)
97 // cvSetCaptureProperty(capture, CV_CAP_PROP_AWB, awb->Value());
98
99 // cam pictures
100 if (!GrabFrame()) {
101 Printf("Could not grab a frame\n");
102 }
103
104 //check for ps3eye deconnection in hds uav
105 new_time = GetTime();
106 if(new_time-cam_time>100*1000*1000) {
107 Thread::Warn("delta t trop grand\n");
108 hasProblems=true;
109 }
110
111 //select buffer
112 if(useMemoryUsrPtr) {//buffers are already in CMEM
113 imageData=(char*)buffers[dQueuedBuffer.index];
114 //dequeue it latter (buffer used by ProcessUpdate)
115 } else {//copy to CMEM allocated buffer
116 memcpy(imageData,(char *)buffers[dQueuedBuffer.index],output->GetDataType().GetSize());
117 QueueBuffer(&dQueuedBuffer);//we can do it right now
118 }
119
120 output->GetMutex();
121 output->buffer=imageData;
122 output->ReleaseMutex();
123
124 output->SetDataTime(cam_time);
125 ProcessUpdate(output);
126 cam_time = new_time;
127
128 if(useMemoryUsrPtr) {
129 QueueBuffer(&dQueuedBuffer);//now it is possible to dequeue
130 }
131 }
132 */
133}
134
135bool V4LCamera::HasProblems(void) {
136 return pimpl_->hasProblems;
137}
138
139void V4LCamera::SetAutoGain(bool value) {
140 pimpl_->SetAutoGain(value);
141}
142
143void V4LCamera::SetAutoExposure(bool value) {
144 Thread::Warn("not implemented\n");
145}
146
147void V4LCamera::SetGain(float value) {
148 pimpl_->SetGain(value);
149}
150
151void V4LCamera::SetExposure(float value) {
152 pimpl_->SetExposure(value);
153}
154
155void V4LCamera::SetBrightness(float value) {
156 pimpl_->SetBrightness(value);
157}
158
159void V4LCamera::SetSaturation(float value) {
160 pimpl_->SetSaturation(value);
161}
162
163void V4LCamera::SetHue(float value) {
164 pimpl_->SetHue(value);
165}
166
167void V4LCamera::SetContrast(float value) {
168 pimpl_->SetContrast(value);
169}
170
171} // end namespace sensor
172} // end namespace flair
Note: See TracBrowser for help on using the repository browser.