diff --git include/bob/daq/Camera.h include/bob/daq/Camera.h
index c989732..e40f747 100644
|
|
public: |
35 | 35 | /** |
36 | 36 | * Pixel format |
37 | 37 | */ |
38 | | enum PixelFormat { |
| 38 | enum CamPixFormat { |
39 | 39 | OTHER, |
40 | 40 | YUYV, |
41 | 41 | MJPEG, |
… |
… |
public: |
61 | 61 | * @param frameNb frame number |
62 | 62 | * @param timestamp frame timestamp (in seconds) |
63 | 63 | */ |
64 | | virtual void imageReceived(unsigned char* image, PixelFormat pixelFormat, int width, int height, int stride, int size, int frameNb, double timestamp) = 0; |
| 64 | virtual void imageReceived(unsigned char* image, CamPixFormat pixelFormat, int width, int height, int stride, int size, int frameNb, double timestamp) = 0; |
65 | 65 | }; |
66 | 66 | |
67 | 67 | /** |
… |
… |
public: |
134 | 134 | * @param[out] pixelFormats supported pixel formats |
135 | 135 | * @return 0 on success |
136 | 136 | */ |
137 | | virtual int getSupportedPixelFormats(std::vector<PixelFormat>& pixelFormats) = 0; |
| 137 | virtual int getSupportedCamPixFormats(std::vector<CamPixFormat>& pixelFormats) = 0; |
138 | 138 | |
139 | 139 | /** |
140 | 140 | * Get the list of supported frame sizes for a pixel format |
… |
… |
public: |
143 | 143 | * @param[out] frameSizes supported frame sizes |
144 | 144 | * @return 0 on success |
145 | 145 | */ |
146 | | virtual int getSupportedFrameSizes(PixelFormat pixelFormat, std::vector<FrameSize>& frameSizes) = 0; |
| 146 | virtual int getSupportedFrameSizes(CamPixFormat pixelFormat, std::vector<FrameSize>& frameSizes) = 0; |
147 | 147 | |
148 | 148 | /** |
149 | 149 | * Get the list of supported frame intervals for a pixel format and a frame size |
… |
… |
public: |
153 | 153 | * @param[out] frameIntervals supported frame intervals |
154 | 154 | * @return 0 on success |
155 | 155 | */ |
156 | | virtual int getSupportedFrameIntervals(PixelFormat pixelFormat, FrameSize& frameSize, std::vector<FrameInterval>& frameIntervals) = 0; |
| 156 | virtual int getSupportedFrameIntervals(CamPixFormat pixelFormat, FrameSize& frameSize, std::vector<FrameInterval>& frameIntervals) = 0; |
157 | 157 | |
158 | | virtual PixelFormat getPixelFormat() const = 0; |
159 | | virtual void setPixelFormat(PixelFormat pixelFormat) = 0; |
| 158 | virtual CamPixFormat getCamPixFormat() const = 0; |
| 159 | virtual void setCamPixFormat(CamPixFormat pixelFormat) = 0; |
160 | 160 | |
161 | 161 | virtual FrameSize getFrameSize() const = 0; |
162 | 162 | virtual void setFrameSize(FrameSize& frameSize) = 0; |
diff --git include/bob/daq/SimpleController.h include/bob/daq/SimpleController.h
index ead7fa7..0c22413 100644
|
|
public: |
34 | 34 | virtual ~SimpleController(); |
35 | 35 | |
36 | 36 | virtual void keyPressed(int key); |
37 | | virtual void imageReceived(unsigned char* image, Camera::PixelFormat pixelformat, int width, int height, int stride, int size, int frameNb, double timestamp); |
| 37 | virtual void imageReceived(unsigned char* image, Camera::CamPixFormat pixelformat, int width, int height, int stride, int size, int frameNb, double timestamp); |
38 | 38 | |
39 | 39 | void stop(); |
40 | 40 | |
diff --git include/bob/daq/V4LCamera.h include/bob/daq/V4LCamera.h
index 5c5e79a..068cbf1 100644
|
|
public: |
43 | 43 | void stop(); |
44 | 44 | void wait(); |
45 | 45 | |
46 | | int getSupportedPixelFormats(std::vector<PixelFormat>& pixelFormats); |
47 | | int getSupportedFrameSizes(PixelFormat pixelFormat, std::vector<FrameSize>& frameSizes); |
48 | | int getSupportedFrameIntervals(PixelFormat pixelFormat, FrameSize& frameSize, std::vector<FrameInterval>& frameIntervals); |
| 46 | int getSupportedCamPixFormats(std::vector<CamPixFormat>& pixelFormats); |
| 47 | int getSupportedFrameSizes(CamPixFormat pixelFormat, std::vector<FrameSize>& frameSizes); |
| 48 | int getSupportedFrameIntervals(CamPixFormat pixelFormat, FrameSize& frameSize, std::vector<FrameInterval>& frameIntervals); |
49 | 49 | |
50 | | PixelFormat getPixelFormat() const; |
51 | | void setPixelFormat(PixelFormat pixelFormat); |
| 50 | CamPixFormat getCamPixFormat() const; |
| 51 | void setCamPixFormat(CamPixFormat pixelFormat); |
52 | 52 | |
53 | 53 | FrameSize getFrameSize() const; |
54 | 54 | void setFrameSize(FrameSize& frameSize); |
diff --git include/bob/daq/VideoReaderCamera.h include/bob/daq/VideoReaderCamera.h
index a88a0c5..31b597c 100644
|
|
public: |
40 | 40 | void stop(); |
41 | 41 | void wait(); |
42 | 42 | |
43 | | int getSupportedPixelFormats(std::vector<PixelFormat>& pixelFormats); |
44 | | int getSupportedFrameSizes(PixelFormat pixelFormat, std::vector<FrameSize>& frameSizes); |
45 | | int getSupportedFrameIntervals(PixelFormat pixelFormat, FrameSize& frameSize, std::vector<FrameInterval>& frameIntervals); |
| 43 | int getSupportedCamPixFormats(std::vector<Camera::CamPixFormat>& pixelFormats); |
| 44 | int getSupportedFrameSizes(Camera::CamPixFormat pixelFormat, std::vector<FrameSize>& frameSizes); |
| 45 | int getSupportedFrameIntervals(Camera::CamPixFormat pixelFormat, FrameSize& frameSize, std::vector<FrameInterval>& frameIntervals); |
46 | 46 | |
47 | | PixelFormat getPixelFormat() const; |
48 | | void setPixelFormat(PixelFormat pixelFormat); |
| 47 | Camera::CamPixFormat getCamPixFormat() const; |
| 48 | void setCamPixFormat(Camera::CamPixFormat pixelFormat); |
49 | 49 | |
50 | 50 | FrameSize getFrameSize() const; |
51 | 51 | void setFrameSize(FrameSize& frameSize); |
diff --git src/daq/cxx/SimpleController.cc src/daq/cxx/SimpleController.cc
index 9689cb9..3899a59 100644
|
|
static void jpeg_mem_src(j_decompress_ptr cinfo, void* buffer, long nbytes) |
247 | 247 | } |
248 | 248 | ////////////////////////////////////////////////////////////////////////////// |
249 | 249 | |
250 | | void SimpleController::imageReceived(unsigned char* image, Camera::PixelFormat pixelFormat, |
| 250 | void SimpleController::imageReceived(unsigned char* image, Camera::CamPixFormat pixelFormat, |
251 | 251 | int width, int height, int stride, int size, int frameNb, double timestamp) { |
252 | 252 | ControllerCallback::CaptureStatus status; |
253 | 253 | status.totalSessionTime = length + recordingDelay; |
diff --git src/daq/cxx/V4LCamera.cc src/daq/cxx/V4LCamera.cc
index 531b547..6a56e05 100644
|
|
int V4LCamera::open() { |
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
295 | | * Convert v4l2 pixel format to Camera::PixelFormat |
| 295 | * Convert v4l2 pixel format to Camera::CamPixFormat |
296 | 296 | */ |
297 | | Camera::PixelFormat convertPixelFormat(unsigned int v4l2_pixelFormat) { |
| 297 | Camera::CamPixFormat convertCamPixFormat(unsigned int v4l2_pixelFormat) { |
298 | 298 | switch (v4l2_pixelFormat) { |
299 | 299 | case V4L2_PIX_FMT_YUYV: |
300 | 300 | return Camera::YUYV; |
… |
… |
Camera::PixelFormat convertPixelFormat(unsigned int v4l2_pixelFormat) { |
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
311 | | * Convert Camera::PixelFormat to v4l2 pixel format |
| 311 | * Convert Camera::CamPixFormat to v4l2 pixel format |
312 | 312 | */ |
313 | | unsigned int convertPixelFormat(Camera::PixelFormat pixelFormat) { |
| 313 | unsigned int convertCamPixFormat(Camera::CamPixFormat pixelFormat) { |
314 | 314 | switch (pixelFormat) { |
315 | 315 | case Camera::YUYV: |
316 | 316 | return V4L2_PIX_FMT_YUYV; |
… |
… |
unsigned int convertPixelFormat(Camera::PixelFormat pixelFormat) { |
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
330 | | int V4LCamera::getSupportedPixelFormats(std::vector<PixelFormat>& pixelFormats) { |
| 330 | int V4LCamera::getSupportedCamPixFormats(std::vector<CamPixFormat>& pixelFormats) { |
331 | 331 | if (v4lstruct->opened) { |
332 | 332 | pixelFormats.clear(); |
333 | 333 | |
… |
… |
int V4LCamera::getSupportedPixelFormats(std::vector<PixelFormat>& pixelFormats) |
337 | 337 | fmtdesc.index = 0; |
338 | 338 | |
339 | 339 | while (xioctl(v4lstruct->device, VIDIOC_ENUM_FMT, &fmtdesc) != -1) { |
340 | | pixelFormats.push_back(convertPixelFormat(fmtdesc.pixelformat)); |
| 340 | pixelFormats.push_back(convertCamPixFormat(fmtdesc.pixelformat)); |
341 | 341 | fmtdesc.index++; |
342 | 342 | } |
343 | 343 | } |
… |
… |
int V4LCamera::getSupportedPixelFormats(std::vector<PixelFormat>& pixelFormats) |
345 | 345 | return 0; |
346 | 346 | } |
347 | 347 | |
348 | | int V4LCamera::getSupportedFrameSizes(PixelFormat pixelFormat, std::vector<FrameSize>& frameSizes) { |
| 348 | int V4LCamera::getSupportedFrameSizes(CamPixFormat pixelFormat, std::vector<FrameSize>& frameSizes) { |
349 | 349 | if (v4lstruct->opened) { |
350 | 350 | frameSizes.clear(); |
351 | 351 | |
352 | 352 | v4l2_frmsizeenum frmsizeenum; |
353 | 353 | memset(&frmsizeenum, 0, sizeof(v4l2_frmsizeenum)); |
354 | | frmsizeenum.pixel_format = convertPixelFormat(pixelFormat); |
| 354 | frmsizeenum.pixel_format = convertCamPixFormat(pixelFormat); |
355 | 355 | frmsizeenum.index = 0; |
356 | 356 | |
357 | 357 | while (xioctl(v4lstruct->device, VIDIOC_ENUM_FRAMESIZES, &frmsizeenum) != -1) { |
… |
… |
int V4LCamera::getSupportedFrameSizes(PixelFormat pixelFormat, std::vector<Frame |
369 | 369 | return 0; |
370 | 370 | } |
371 | 371 | |
372 | | int V4LCamera::getSupportedFrameIntervals(PixelFormat pixelFormat, FrameSize& frameSize, |
| 372 | int V4LCamera::getSupportedFrameIntervals(CamPixFormat pixelFormat, FrameSize& frameSize, |
373 | 373 | std::vector<FrameInterval>& frameIntervals) { |
374 | 374 | if (v4lstruct->opened) { |
375 | 375 | v4l2_frmivalenum frmivalenum; |
376 | 376 | memset(&frmivalenum, 0, sizeof(v4l2_frmivalenum)); |
377 | | frmivalenum.pixel_format = convertPixelFormat(pixelFormat); |
| 377 | frmivalenum.pixel_format = convertCamPixFormat(pixelFormat); |
378 | 378 | frmivalenum.height = frameSize.height; |
379 | 379 | frmivalenum.width = frameSize.width; |
380 | 380 | frmivalenum.index = 0; |
… |
… |
int V4LCamera::getSupportedFrameIntervals(PixelFormat pixelFormat, FrameSize& fr |
394 | 394 | return 0; |
395 | 395 | } |
396 | 396 | |
397 | | Camera::PixelFormat V4LCamera::getPixelFormat() const { |
| 397 | Camera::CamPixFormat V4LCamera::getCamPixFormat() const { |
398 | 398 | if (v4lstruct->opened) { |
399 | | return convertPixelFormat(v4lstruct->format.pixelformat); |
| 399 | return convertCamPixFormat(v4lstruct->format.pixelformat); |
400 | 400 | } |
401 | 401 | else { |
402 | 402 | return Camera::OTHER; |
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
406 | | void V4LCamera::setPixelFormat(PixelFormat pixelFormat) { |
| 406 | void V4LCamera::setCamPixFormat(CamPixFormat pixelFormat) { |
407 | 407 | if (v4lstruct->opened) { |
408 | 408 | v4l2_format format; |
409 | 409 | memset(&format, 0, sizeof(v4l2_format)); |
410 | 410 | format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
411 | 411 | format.fmt.pix = v4lstruct->format; |
412 | 412 | |
413 | | format.fmt.pix.pixelformat = convertPixelFormat(pixelFormat); |
| 413 | format.fmt.pix.pixelformat = convertCamPixFormat(pixelFormat); |
414 | 414 | |
415 | 415 | if (xioctl(v4lstruct->device, VIDIOC_S_FMT, &format) == -1) { |
416 | 416 | perror("Error setting parameters (VIDIOC_S_FMT)"); |
… |
… |
int V4LCamera::start() { |
601 | 601 | |
602 | 602 | |
603 | 603 | void V4LCamera::captureLoop() { |
604 | | const PixelFormat pixelformat = getPixelFormat(); |
| 604 | const CamPixFormat pixelformat = getCamPixFormat(); |
605 | 605 | |
606 | 606 | while(!mustStop) { |
607 | 607 | // Select manpage say that we can't trust the value of timeout after |
diff --git src/daq/cxx/VideoReaderCamera.cc src/daq/cxx/VideoReaderCamera.cc
index f87d5d0..7682a0e 100644
|
|
void VideoReaderCamera::printSummary() { |
105 | 105 | bob::core::info << videoReader->info().c_str() << std::endl; |
106 | 106 | } |
107 | 107 | |
108 | | Camera::PixelFormat VideoReaderCamera::getPixelFormat() const { |
109 | | return RGB24; |
| 108 | Camera::CamPixFormat VideoReaderCamera::getCamPixFormat() const { |
| 109 | return Camera::RGB24; |
110 | 110 | } |
111 | 111 | |
112 | | void VideoReaderCamera::setPixelFormat(Camera::PixelFormat pixelFormat) { |
| 112 | void VideoReaderCamera::setCamPixFormat(Camera::CamPixFormat pixelFormat) { |
113 | 113 | return; |
114 | 114 | } |
115 | 115 | |
… |
… |
void VideoReaderCamera::setFrameInterval(Camera::FrameInterval& frameInterval) { |
129 | 129 | return; |
130 | 130 | } |
131 | 131 | |
132 | | int VideoReaderCamera::getSupportedPixelFormats(std::vector<PixelFormat>& pixelFormats) { |
| 132 | int VideoReaderCamera::getSupportedCamPixFormats(std::vector<Camera::CamPixFormat>& pixelFormats) { |
133 | 133 | pixelFormats.clear();; |
134 | | pixelFormats.push_back(getPixelFormat()); |
| 134 | pixelFormats.push_back(getCamPixFormat()); |
135 | 135 | |
136 | 136 | return 0; |
137 | 137 | } |
138 | 138 | |
139 | | int VideoReaderCamera::getSupportedFrameSizes(PixelFormat pixelFormat, std::vector<FrameSize>& frameSizes) { |
| 139 | int VideoReaderCamera::getSupportedFrameSizes(Camera::CamPixFormat pixelFormat, std::vector<FrameSize>& frameSizes) { |
140 | 140 | frameSizes.clear(); |
141 | | if (pixelFormat == getPixelFormat()) { |
| 141 | if (pixelFormat == getCamPixFormat()) { |
142 | 142 | frameSizes.push_back(getFrameSize()); |
143 | 143 | } |
144 | 144 | |
145 | 145 | return 0; |
146 | 146 | } |
147 | 147 | |
148 | | int VideoReaderCamera::getSupportedFrameIntervals(PixelFormat pixelFormat, FrameSize& frameSize, |
| 148 | int VideoReaderCamera::getSupportedFrameIntervals(Camera::CamPixFormat pixelFormat, FrameSize& frameSize, |
149 | 149 | std::vector<FrameInterval>& frameIntervals) { |
150 | 150 | frameIntervals.clear(); |
151 | | if (pixelFormat == getPixelFormat() && frameSize == getFrameSize()) { |
| 151 | if (pixelFormat == getCamPixFormat() && frameSize == getFrameSize()) { |
152 | 152 | frameIntervals.push_back(getFrameInterval()); |
153 | 153 | } |
154 | 154 | |
diff --git src/daq/python/all.cc src/daq/python/all.cc
index 640e47b..3b4c4fa 100644
|
|
|
45 | 45 | |
46 | 46 | using namespace bob::daq; |
47 | 47 | |
48 | | static boost::python::object getSupportedPixelFormats(Camera& cam) { |
49 | | std::vector<Camera::PixelFormat> pfs; |
50 | | cam.getSupportedPixelFormats(pfs); |
| 48 | static boost::python::object getSupportedCamPixFormats(Camera& cam) { |
| 49 | std::vector<Camera::CamPixFormat> pfs; |
| 50 | cam.getSupportedCamPixFormats(pfs); |
51 | 51 | |
52 | 52 | boost::python::list l; |
53 | 53 | |
… |
… |
static boost::python::object getSupportedPixelFormats(Camera& cam) { |
58 | 58 | return l; |
59 | 59 | } |
60 | 60 | |
61 | | static boost::python::object getSupportedFrameSizes(Camera& cam, Camera::PixelFormat pf) { |
| 61 | static boost::python::object getSupportedFrameSizes(Camera& cam, Camera::CamPixFormat pf) { |
62 | 62 | std::vector<Camera::FrameSize> vec; |
63 | 63 | cam.getSupportedFrameSizes(pf, vec); |
64 | 64 | |
… |
… |
static boost::python::object getSupportedFrameSizes(Camera& cam, Camera::PixelFo |
71 | 71 | return l; |
72 | 72 | } |
73 | 73 | |
74 | | static boost::python::object getSupportedFrameIntervals(Camera& cam, Camera::PixelFormat pf, Camera::FrameSize& fs) { |
| 74 | static boost::python::object getSupportedFrameIntervals(Camera& cam, Camera::CamPixFormat pf, Camera::FrameSize& fs) { |
75 | 75 | std::vector<Camera::FrameInterval> vec; |
76 | 76 | cam.getSupportedFrameIntervals(pf, fs, vec); |
77 | 77 | |
… |
… |
void bind_daq_all() { |
169 | 169 | .def("on_detection", &FaceLocalizationCallback::onDetection, (arg("boundingbox"))); |
170 | 170 | |
171 | 171 | /// Cameras |
172 | | enum_<Camera::PixelFormat>("PixelFormat") |
| 172 | enum_<Camera::CamPixFormat>("PixelFormat") |
173 | 173 | .value("YUYV", Camera::YUYV) |
174 | 174 | .value("MJPEG", Camera::MJPEG) |
175 | 175 | .value("RGB24", Camera::RGB24) |
… |
… |
void bind_daq_all() { |
192 | 192 | .def("start", &Camera_start, (arg("self"))) |
193 | 193 | .def("add_camera_callback", &Camera::addCameraCallback, (arg("self"), arg("callback"))) |
194 | 194 | .def("remove_camera_callback", &Camera::removeCameraCallback, (arg("self"), arg("callback"))) |
195 | | .def("get_supported_pixel_formats", &getSupportedPixelFormats, (arg("self")), "Get the list of supported pixel formats") |
| 195 | .def("get_supported_pixel_formats", &getSupportedCamPixFormats, (arg("self")), "Get the list of supported pixel formats") |
196 | 196 | .def("get_supported_frame_sizes", &getSupportedFrameSizes, (arg("self"), arg("pixel_format")), "Get the list of supported frame sizes for a pixel format") |
197 | 197 | .def("get_supported_frame_intervals", &getSupportedFrameIntervals, (arg("self"), arg("pixel_format"), arg("frame_size")), "Get the list of supported frame intervals for a pixel format and a frame size") |
198 | | .add_property("pixel_format", &Camera::getPixelFormat, &Camera::setPixelFormat) |
| 198 | .add_property("pixel_format", &Camera::getCamPixFormat, &Camera::setCamPixFormat) |
199 | 199 | .add_property("frame_size", &Camera::getFrameSize, &Camera::setFrameSize) |
200 | 200 | .add_property("frame_interval", &Camera::getFrameInterval, &Camera::setFrameInterval) |
201 | 201 | .def("print_summary", &Camera::printSummary, (arg("self")), "Print information about the device"); |