Debian Codegraph @

cvd_src/Linux/dvbuffer3_dc1394v1.cc

raw symbols SCIP
1 // -*- c++ -*-
2
3 #include <algorithm>
4 #include <cvd/Linux/dvbuffer.h>
5 #include <cvd/Linux/dvbuffer3.h>
6 #include <cvd/byte.h>
7 #include <vector>
8
9 using namespace CVD;
10 using namespace DV3;
11 using CVD::Exceptions::DVBuffer3::All;
12
13 namespace CVD
14 {
15
16 namespace DV3
17 {
18
19 struct LibDCParams
20 {
21 DC::RawDCVideo* pRawDCV;
22 };
23
24 static unsigned int DC_from_DV3_Feature(DV3Feature f)
25 {
26 switch(f)
27 {
28 case BRIGHTNESS:
29 return FEATURE_BRIGHTNESS;
30 case EXPOSURE:
31 return FEATURE_EXPOSURE;
32 case SHARPNESS:
33 return FEATURE_SHARPNESS;
34 case WHITE_BALANCE:
35 return FEATURE_WHITE_BALANCE;
36 case HUE:
37 return FEATURE_HUE;
38 case SATURATION:
39 return FEATURE_SATURATION;
40 case GAMMA:
41 return FEATURE_GAMMA;
42 case SHUTTER:
43 return FEATURE_SHUTTER;
44 case GAIN:
45 return FEATURE_GAIN;
46 case IRIS:
47 return FEATURE_IRIS;
48 case FOCUS:
49 return FEATURE_FOCUS;
50 case ZOOM:
51 return FEATURE_ZOOM;
52 case PAN:
53 return FEATURE_PAN;
54 case TILT:
55 return FEATURE_TILT;
56 case FRAME_RATE:
57 return FEATURE_FRAME_RATE;
58 }
59 return -1;
60 }
61
62 RawDVBuffer3::RawDVBuffer3(DV3ColourSpace colourspace,
63 int nCamNumber,
64 uint64_t,
65 int,
66 bool,
67 bool,
68 ImageRef,
69 float fFrameRate,
70 ImageRef)
71 {
72
73 int mode;
74 double fps;
75 // Mode and FPS selection are VERY HACKY
76 // Basically this does what DVBuffer 2 would do
77 // And in doing so completely ignores the requested values
78 if(colourspace == YUV411)
79 {
80 mode = MODE_640x480_YUV411;
81 fps = 30.0;
82 }
83 else if(colourspace == RGB8)
84 {
85 mode = MODE_640x480_RGB;
86 fps = 15.0;
87 }
88 else if(colourspace == MONO8)
89 {
90 mode = MODE_640x480_MONO;
91 fps = 30.0;
92 }
93 else
94 throw CVD::Exceptions::DVBuffer3::All("Non-implemented colourspace for DVBuffer2's RawDCVideo.");
95
96 if(fFrameRate > 0 && fFrameRate != fps)
97 std::cout << "! Warning: DVBuffer3/libdc1394v1: Ignoring requested frame-rate, you're getting " << fps << " instead." << std::endl;
98
99 mpLDCP = new LibDCParams;
100 mpLDCP->pRawDCV = NULL;
101 mpLDCP->pRawDCV = new DC::RawDCVideo(nCamNumber,
102 4,
103 -1, -1,
104 mode, fps);
105
106 mirSize = mpLDCP->pRawDCV->size();
107 mdFramerate = mpLDCP->pRawDCV->frame_rate();
108 }
109
110 RawDVBuffer3::~RawDVBuffer3()
111 {
112 if(mpLDCP->pRawDCV)
113 delete(mpLDCP->pRawDCV);
114 delete mpLDCP;
115 }
116
117 bool RawDVBuffer3::frame_pending()
118 {
119 return mpLDCP->pRawDCV->frame_pending();
120 }
121
122 VideoFrame<byte>* RawDVBuffer3::get_frame()
123 {
124 return mpLDCP->pRawDCV->get_frame();
125 }
126
127 void RawDVBuffer3::put_frame(VideoFrame<byte>* pVidFrame)
128 {
129 mpLDCP->pRawDCV->put_frame(pVidFrame);
130 }
131
132 unsigned int RawDVBuffer3::get_feature_value(DV3Feature nFeature)
133 {
134 return mpLDCP->pRawDCV->get_feature_value(DC_from_DV3_Feature(nFeature));
135 }
136
137 void RawDVBuffer3::set_feature_value(DV3Feature nFeature, unsigned int nValue)
138 {
139 mpLDCP->pRawDCV->set_feature_value(DC_from_DV3_Feature(nFeature), nValue);
140 }
141
142 std::pair<unsigned int, unsigned int> RawDVBuffer3::get_feature_min_max(DV3Feature nFeature)
143 {
144 return mpLDCP->pRawDCV->get_feature_min_max(DC_from_DV3_Feature(nFeature));
145 }
146
147 void RawDVBuffer3::auto_on_off(DV3Feature nFeature, bool bValue)
148 {
149 mpLDCP->pRawDCV->auto_on_off(DC_from_DV3_Feature(nFeature), bValue);
150 }
151
152 void RawDVBuffer3::power_on_off(DV3Feature, bool)
153 {
154 // not implemented
155 std::cout << "! Warning: DVBuffer3/libdc1394v1 power_on_off is only implemented for V2!" << std::endl;
156 }
157 }
158
159 }