iCub-main
Loading...
Searching...
No Matches
DragonflyDeviceDriver2.cpp
Go to the documentation of this file.
1// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2
3/*
4 * Copyright (C) 2007 RobotCub Consortium
5 * Author: Alessandro Scalzo alessandro.scalzo@iit.it
6 * CopyPolicy: Released under the terms of the GNU GPL v2.0.
7 *
8 */
9
11
12#include <yarp/os/Stamp.h>
13#include <yarp/dev/DeviceDriver.h>
14#include <yarp/os/Log.h>
15#include <yarp/os/LogStream.h>
16
17using namespace yarp::os;
18using namespace yarp::dev;
19
20#include "FirewireCameraDC1394-DR2_2.h"
21
23inline CFWCamera_DR2_2* RES(void *res) { return (CFWCamera_DR2_2*)res; }
25
26bool DragonflyDeviceDriver2Rgb::getImage(yarp::sig::ImageOf<yarp::sig::PixelRgb>& image)
27{
28 return RES(system_resources)->CaptureImage(image);
29}
30
31bool DragonflyDeviceDriver2Rgb::getImage(yarp::sig::ImageOf<yarp::sig::PixelMono>& image)
32{
33 return RES(system_resources)->CaptureImage(image);
34}
35
37{
38 return RES(system_resources)->width();
39}
40
42{
43 return RES(system_resources)->height();
44}
45
46bool DragonflyDeviceDriver2Raw::getImage(yarp::sig::ImageOf<yarp::sig::PixelMono>& image)
47{
48 return RES(system_resources)->CaptureImage(image);
49}
50
52{
53 return RES(system_resources)->width();
54}
55
57{
58 return RES(system_resources)->height();
59}
60
62
63DragonflyDeviceDriver2::DragonflyDeviceDriver2(bool raw) :
64 raw(raw), system_resources(NULL)
65{
66}
67
76
77bool DragonflyDeviceDriver2::open(yarp::os::Searchable& config)
78{
79 if(config.check("pixelType"))
80 {
81 if(config.find(("pixelType")).asVocab32()==VOCAB_PIXEL_MONO)
82 raw=true;
83 else if((config.find(("pixelType")).asVocab32()==VOCAB_PIXEL_RGB))
84 raw=false;
85 else
86 {
87 yError()<<"DragonflyDeviceDriver2: invalid pixelType:"<<yarp::os::Vocab32::decode(config.find(("pixelType")).asVocab32());
88 return false;
89 }
90 }
91
93 if (!RES(system_resources)->Create(config))
94 {
95 fprintf(stderr,"DragonflyDeviceDriver2: can't open camera\n");
96 return false;
97 }
98
99 return true;
100}
101
103{
105 {
106 RES(system_resources)->Close();
107 return true;
108 }
109
110 return false;
111}
112
114{
115 return RES(system_resources)->getLastInputStamp();
116}
117
118// SET
119
121{
122 return RES(system_resources)->setBrightness(value);
123}
125{
126 return RES(system_resources)->setExposure(value);
127}
129{
130 return RES(system_resources)->setSharpness(value);
131}
132bool DragonflyDeviceDriver2::setWhiteBalance(double blue, double red)
133{
134 return RES(system_resources)->setWhiteBalance(blue,red);
135}
137{
138 return RES(system_resources)->setHue(value);
139}
141{
142 return RES(system_resources)->setSaturation(value);
143}
145{
146 return RES(system_resources)->setGamma(value);
147}
149{
150 return RES(system_resources)->setShutter(value);
151}
153{
154 return RES(system_resources)->setGain(value);
155}
157{
158 return RES(system_resources)->setIris(value);
159}
160
161// GET
162
164{
165 return RES(system_resources)->getBrightness();
166}
168{
169 return RES(system_resources)->getExposure();
170}
172{
173 return RES(system_resources)->getSharpness();
174}
175bool DragonflyDeviceDriver2::getWhiteBalance(double &blue, double &red)
176{
177 return RES(system_resources)->getWhiteBalance(blue,red);
178}
180{
181 return RES(system_resources)->getHue();
182}
184{
185 return RES(system_resources)->getSaturation();
186}
188{
189 return RES(system_resources)->getGamma();
190}
192{
193 return RES(system_resources)->getShutter();
194}
196{
197 return RES(system_resources)->getGain();
198}
200{
201 return RES(system_resources)->getIris();
202}
203
205// DC1394
207
210{
211 return RES(system_resources)->hasFeatureDC1394(feature);
212}
213bool DragonflyDeviceDriver2::setFeatureDC1394(int feature,double value)
214{
215 return RES(system_resources)->setFeatureDC1394(feature,value);
216}
218{
219 return RES(system_resources)->getFeatureDC1394(feature);
220}
222{
223 return RES(system_resources)->hasOnOffDC1394(feature);
224}
225bool DragonflyDeviceDriver2::setActiveDC1394(int feature, bool onoff)
226{
227 return RES(system_resources)->setActiveDC1394(feature,onoff);
228}
230{
231 return RES(system_resources)->getActiveDC1394(feature);
232}
234{
235 return RES(system_resources)->hasAutoDC1394(feature);
236}
238{
239 return RES(system_resources)->hasManualDC1394(feature);
240}
242{
243 return RES(system_resources)->hasOnePushDC1394(feature);
244}
245bool DragonflyDeviceDriver2::setModeDC1394(int feature, bool auto_onoff)
246{
247 return RES(system_resources)->setModeDC1394(feature,auto_onoff);
248}
250{
251 return RES(system_resources)->getModeDC1394(feature);
252}
254{
255 return RES(system_resources)->setOnePushDC1394(feature);
256}
258{
259 return RES(system_resources)->getVideoModeMaskDC1394();
260}
262{
263 return RES(system_resources)->setVideoModeDC1394(video_mode);
264}
266{
267 return RES(system_resources)->getVideoModeDC1394();
268}
270{
271 return RES(system_resources)->getFPSMaskDC1394();
272}
274{
275 return RES(system_resources)->getFPSDC1394();
276}
278{
279 return RES(system_resources)->setFPSDC1394(fps);
280}
282{
283 return RES(system_resources)->getISOSpeedDC1394();
284}
286{
287 return RES(system_resources)->setISOSpeedDC1394(speed);
288}
289unsigned int DragonflyDeviceDriver2::getColorCodingMaskDC1394(unsigned int video_mode)
290{
291 return RES(system_resources)->getColorCodingMaskDC1394(video_mode);
292}
294{
295 return RES(system_resources)->getColorCodingDC1394();
296}
298{
299 return RES(system_resources)->setColorCodingDC1394(coding);
300}
302{
303 return RES(system_resources)->setWhiteBalanceDC1394(b,r);
304}
306{
307 return RES(system_resources)->getWhiteBalanceDC1394(b,r);
308}
309bool DragonflyDeviceDriver2::getFormat7MaxWindowDC1394(unsigned int &xdim,unsigned int &ydim,unsigned int &xstep,unsigned int &ystep,unsigned int &xoffstep,unsigned int &yoffstep)
310{
311 return RES(system_resources)->getFormat7MaxWindowDC1394(xdim,ydim,xstep,ystep,xoffstep,yoffstep);
312}
313bool DragonflyDeviceDriver2::setFormat7WindowDC1394(unsigned int xdim,unsigned int ydim,int x0,int y0)
314{
315 return RES(system_resources)->setFormat7WindowDC1394(xdim,ydim,x0,y0);
316}
317bool DragonflyDeviceDriver2::getFormat7WindowDC1394(unsigned int &xdim,unsigned int &ydim,int &x0,int &y0)
318{
319 return RES(system_resources)->getFormat7WindowDC1394(xdim,ydim,x0,y0);
320}
322{
323 return RES(system_resources)->setOperationModeDC1394(b1394b);
324}
326{
327 return RES(system_resources)->getOperationModeDC1394();
328}
330{
331 return RES(system_resources)->setTransmissionDC1394(bTxON);
332}
334{
335 return RES(system_resources)->getTransmissionDC1394();
336}
337/*
338bool DragonflyDeviceDriver2::setBayerDC1394(bool bON)
339{
340 return RES(system_resources)->setBayerDC1394(bON);
341}
342bool DragonflyDeviceDriver2::getBayerDC1394()
343{
344 return RES(system_resources)->getBayerDC1394();
345}
346*/
348{
349 return RES(system_resources)->setBroadcastDC1394(onoff);
350}
352{
353 return RES(system_resources)->setDefaultsDC1394();
354}
356{
357 return RES(system_resources)->setResetDC1394();
358}
360{
361 return RES(system_resources)->setPowerDC1394(onoff);
362}
364{
365 return RES(system_resources)->setCaptureDC1394(bON);
366}
368{
369 return RES(system_resources)->setBytesPerPacketDC1394(bpp);
370}
372{
373 return RES(system_resources)->getBytesPerPacketDC1394();
374}
375
376//IVisualParams
377
379 return RES(system_resources)->getRgbHeight();
380}
381
383 return RES(system_resources)->getRgbWidth();
384}
385
386bool DragonflyDeviceDriver2::getRgbSupportedConfigurations(yarp::sig::VectorOf<CameraConfig> &configurations)
387{
388 return RES(system_resources)->getRgbSupportedConfigurations(configurations);
389}
390
391bool DragonflyDeviceDriver2::getRgbResolution(int &width, int &height)
392{
393 return RES(system_resources)->getRgbResolution(width,height);
394}
395
397 if(width<=0 || height<=0){
398 yError()<<"DragonflyDeviceDriver: invalid width or height";
399 return false;
400 }
401 return RES(system_resources)->setRgbResolution(width,height);
402}
403
404bool DragonflyDeviceDriver2::getRgbFOV(double &horizontalFov, double &verticalFov){
405 return RES(system_resources)->getRgbFOV(horizontalFov, verticalFov);
406}
407
408bool DragonflyDeviceDriver2::setRgbFOV(double horizontalFov, double verticalFov){
409 return RES(system_resources)->setRgbFOV(horizontalFov, verticalFov);
410}
411
412bool DragonflyDeviceDriver2::getRgbIntrinsicParam(yarp::os::Property &intrinsic){
413 return RES(system_resources)->getRgbIntrinsicParam(intrinsic);
414}
415
417 return RES(system_resources)->getRgbMirroring(mirror);
418
419}
420
422 return RES(system_resources)->setRgbMirroring(mirror);
423}
424
426// IFrameGrabberControl2 //
428
430{
431 camera->busType = BUS_FIREWIRE;
432 camera->deviceDescription = "DragonFly2";
433 return true;
434}
435
436bool DragonflyDeviceDriver2::getActive(int feature, bool* isActive)
437{
438 *isActive = RES(system_resources)->getActiveDC1394(feature);
439 return true;
440}
441
442bool DragonflyDeviceDriver2::getFeature(int feature, double* values)
443{
444 *values = RES(system_resources)->getFeatureDC1394(feature);
445 return true;
446}
447
448bool DragonflyDeviceDriver2::getMode(int feature, FeatureMode* mode)
449{
450 *mode = TRANSL_MODE( RES(system_resources)->getModeDC1394(feature) );
451 return true;
452}
453
454bool DragonflyDeviceDriver2::hasAuto(int feature, bool* hasAuto)
455{
456 *hasAuto = RES(system_resources)->hasAutoDC1394(feature);
457 return true;
458}
459
460bool DragonflyDeviceDriver2::hasFeature(int feature, bool* hasFeature)
461{
462 *hasFeature = RES(system_resources)->hasFeatureDC1394(feature);
463 return true;
464}
465
466bool DragonflyDeviceDriver2::hasManual(int feature, bool* hasManual)
467{
468 *hasManual = RES(system_resources)->hasManualDC1394(feature);
469 return true;
470}
471
472bool DragonflyDeviceDriver2::hasOnePush(int feature, bool* hasOnePush)
473{
474 *hasOnePush = RES(system_resources)->hasOnePushDC1394(feature);
475 return true;
476}
477
478bool DragonflyDeviceDriver2::hasOnOff(int feature, bool* HasOnOff)
479{
480 *HasOnOff = RES(system_resources)->hasOnOffDC1394(feature);
481 return true;
482}
483
484bool DragonflyDeviceDriver2::setActive(int feature, bool onoff)
485{
486 return RES(system_resources)->setActiveDC1394(feature,onoff);
487}
488
489bool DragonflyDeviceDriver2::setFeature(int feature, double value)
490{
491 return RES(system_resources)->setFeatureDC1394(feature, value);
492}
493
494bool DragonflyDeviceDriver2::getFeature(int feature, double* value1, double* value2)
495{
496 if(feature == YARP_FEATURE_WHITE_BALANCE)
497 return RES(system_resources)->getWhiteBalanceDC1394(*value1, *value2);
498 else
499 return false;
500}
501
502bool DragonflyDeviceDriver2::setFeature(int feature, double value1, double value2)
503{
504 if(feature == YARP_FEATURE_WHITE_BALANCE)
505 return RES(system_resources)->setWhiteBalanceDC1394(value1, value2);
506 else
507 return false;
508}
509
510bool DragonflyDeviceDriver2::setMode(int feature, FeatureMode mode)
511{
512 return RES(system_resources)->setModeDC1394(feature, TRANSL_MODE(mode));
513}
514
516{
517 return RES(system_resources)->setOnePushDC1394(feature);
518}
519
CanBusResources & RES(void *res)
CFWCamera_DR2_2 * RES(void *res)
virtual int width() const
Return the width of each frame.
virtual int height() const
Return the height of each frame.
bool getImage(yarp::sig::ImageOf< yarp::sig::PixelMono > &image)
FrameGrabber image interface, returns the last acquired frame as an rgb image.
virtual int height() const
Return the height of each frame.
bool getImage(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image)
FrameGrabber image interface, returns the last acquired frame as an rgb image.
virtual int width() const
Return the width of each frame.
virtual bool setColorCodingDC1394(int coding)
Set image color coding.
virtual bool setActiveDC1394(int feature, bool onoff)
Switch feature on/off.
virtual bool setPowerDC1394(bool onoff)
Switch camera power ON/OFF.
virtual bool getActiveDC1394(int feature)
Is feature ON or OFF?
virtual bool setMode(int feature, FeatureMode mode)
virtual unsigned int getColorCodingDC1394()
Get image color coding.
virtual bool setWhiteBalance(double blue, double red)
Set White Balance.
virtual unsigned int getVideoModeDC1394()
Get camera acquisition mode.
virtual unsigned int getFPSMaskDC1394()
Get supported framerates mask.
virtual bool getTransmissionDC1394()
Is image transmission ON or OFF?
virtual bool hasOnOff(int feature, bool *HasOnOff)
virtual bool close(void)
Closes the device driver.
virtual bool hasManualDC1394(int feature)
Has feature Manual mode?
virtual bool getRgbFOV(double &horizontalFov, double &verticalFov)
Get the field of view (FOV) of the rgb camera.
virtual double getBrightness()
Get Brightness.
virtual bool getFormat7WindowDC1394(unsigned int &xdim, unsigned int &ydim, int &x0, int &y0)
Get image dimensions in Format 7 mode.
virtual bool setDefaultsDC1394()
Set camera features to default.
virtual double getExposure()
Get Exposure.
virtual bool setCaptureDC1394(bool bON)
Switch image capture ON/OFF.
virtual double getSharpness()
Get Sharpness.
virtual bool setVideoModeDC1394(int video_mode)
Set camera acquisition mode.
virtual bool setBroadcastDC1394(bool onoff)
Set feature commands propagation ON/OFF.
virtual bool getFormat7MaxWindowDC1394(unsigned int &xdim, unsigned int &ydim, unsigned int &xstep, unsigned int &ystep, unsigned int &xoffstep, unsigned int &yoffstep)
Get maximum image dimensions in Format 7 mode.
virtual double getFeatureDC1394(int feature)
Get feature value.
virtual unsigned int getBytesPerPacketDC1394()
Get Firewire communication packet size.
virtual bool setOnePushDC1394(int feature)
Trigger feature One Push adjust.
virtual bool getModeDC1394(int feature)
Is feature mode Auto or Manual?
virtual bool hasAutoDC1394(int feature)
Has feature Auto mode?
virtual bool setTransmissionDC1394(bool bTxON)
Set image transmission ON/OFF.
virtual bool setIris(double v)
Set Iris.
virtual bool hasFeatureDC1394(int feature)
Is feature present?
virtual bool setRgbResolution(int width, int height)
Set the resolution of the rgb image from the camera.
virtual bool setModeDC1394(int feature, bool auto_onoff)
Switch feature Auto/Manual.
virtual bool setFPSDC1394(int fps)
Set camera framerate.
virtual int getRgbWidth()
Return the width of each frame.
virtual double getSaturation()
Get Saturation.
virtual bool setWhiteBalanceDC1394(double b, double r)
Set White Balance.
virtual bool setActive(int feature, bool onoff)
virtual bool getOperationModeDC1394()
Get Operation Mode.
virtual bool getFeature(int feature, double *values)
virtual bool getRgbSupportedConfigurations(yarp::sig::VectorOf< yarp::dev::CameraConfig > &configurations)
Get the possible configurations of the camera.
virtual yarp::os::Stamp getLastInputStamp()
Implements the IPreciselyTimed interface.
virtual unsigned int getFPSDC1394()
Get camera framerate.
virtual bool setOperationModeDC1394(bool b1394b)
Set Operation Mode.
virtual bool hasManual(int feature, bool *hasManual)
virtual bool getWhiteBalanceDC1394(double &b, double &r)
Get White Balance.
virtual bool hasOnePush(int feature, bool *hasOnePush)
virtual bool hasAuto(int feature, bool *hasAuto)
virtual bool setGain(double v)
Set Gain.
virtual bool hasOnOffDC1394(int feature)
Can be feature turned on/off?
virtual bool setBytesPerPacketDC1394(unsigned int bpp)
Set Firewire communication packet size.
virtual unsigned int getISOSpeedDC1394()
Get camera Firewire ISO speed.
virtual bool setGamma(double v)
Set Gamma.
virtual bool setRgbFOV(double horizontalFov, double verticalFov)
Set the field of view (FOV) of the rgb camera.
virtual bool setShutter(double v)
Set Shutter.
virtual bool setFormat7WindowDC1394(unsigned int xdim, unsigned int ydim, int x0, int y0)
Set image dimensions in Format 7 mode.
virtual bool getActive(int feature, bool *isActive)
virtual unsigned int getVideoModeMaskDC1394()
Get supported video mode mask.
virtual bool hasOnePushDC1394(int feature)
Has feature Manual mode?
virtual bool setHue(double v)
Set Hue.
virtual bool setExposure(double v)
Set Exposure.
virtual bool setFeature(int feature, double values)
virtual bool setISOSpeedDC1394(int speed)
Set camera Firewire ISO speed.
virtual bool setSharpness(double v)
Set Sharpness.
virtual bool setSaturation(double v)
Set Saturation.
virtual bool getCameraDescription(CameraDescriptor *camera)
virtual int getRgbHeight()
Return the height of each frame.
virtual bool getRgbIntrinsicParam(yarp::os::Property &intrinsic)
Get the intrinsic parameters of the rgb camera.
virtual bool getWhiteBalance(double &blue, double &red)
Get White Balance.
virtual bool open(yarp::os::Searchable &config)
Open the device driver.
virtual bool hasFeature(int feature, bool *hasFeature)
virtual unsigned int getColorCodingMaskDC1394(unsigned int video_mode)
Get supported color coding mask.
virtual bool getRgbMirroring(bool &mirror)
Get the mirroring setting of the sensor.
virtual double getShutter()
Get Shutter.
virtual bool getMode(int feature, FeatureMode *mode)
virtual bool getRgbResolution(int &width, int &height)
Get the resolution of the rgb image from the camera.
virtual bool setBrightness(double v)
Set Brightness.
virtual bool setFeatureDC1394(int feature, double value)
Set feature value.
virtual bool setRgbMirroring(bool mirror)
Set the mirroring setting of the sensor.
fprintf(fid,'\n')