Linux1394Capture.cpp
Go to the documentation of this file.
1 // ****************************************************************************
2 // This file is part of the Integrating Vision Toolkit (IVT).
3 //
4 // The IVT is maintained by the Karlsruhe Institute of Technology (KIT)
5 // (www.kit.edu) in cooperation with the company Keyetech (www.keyetech.de).
6 //
7 // Copyright (C) 2014 Karlsruhe Institute of Technology (KIT).
8 // All rights reserved.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are met:
12 //
13 // 1. Redistributions of source code must retain the above copyright
14 // notice, this list of conditions and the following disclaimer.
15 //
16 // 2. Redistributions in binary form must reproduce the above copyright
17 // notice, this list of conditions and the following disclaimer in the
18 // documentation and/or other materials provided with the distribution.
19 //
20 // 3. Neither the name of the KIT nor the names of its contributors may be
21 // used to endorse or promote products derived from this software
22 // without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE KIT AND CONTRIBUTORS “AS IS” AND ANY
25 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 // DISCLAIMED. IN NO EVENT SHALL THE KIT OR CONTRIBUTORS BE LIABLE FOR ANY
28 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 // ****************************************************************************
35 // ****************************************************************************
36 // Filename: Linux1394Capture.cpp
37 // Author: Pedram Azad, Kai Welke
38 // Date: 2005
39 // ****************************************************************************
40 // Changes: 24.08.2006. Kai Welke
41 // * Added YUV411 support
42 // 26.09.2006, Kai Welke
43 // * added support for UIDs and different frame rates
44 // * open multiple captures to allow different rates and formats
45 // ****************************************************************************
46 
47 
48 // ****************************************************************************
49 // Includes
50 // ****************************************************************************
51 
52 #include "Linux1394Capture.h"
53 #include "Image/ByteImage.h"
54 #include "Image/ImageProcessor.h"
55 
56 #include <stdio.h>
57 #include <stdlib.h>
58 #include <stdarg.h>
59 #include <algorithm>
60 
61 
62 // ****************************************************************************
63 // Defines
64 // ****************************************************************************
65 
66 #define DROP_FRAMES 1
67 #define NUM_BUFFERS 8
68 
69 
70 // ****************************************************************************
71 // Static members
72 // ****************************************************************************
73 
79 dc1394_cameracapture CLinux1394Capture::m_cameras[MAX_CAMERAS];
81 
82 
83 using namespace std;
84 
85 
86 
87 // ****************************************************************************
88 // Constructors
89 // ****************************************************************************
90 
91 CLinux1394Capture::CLinux1394Capture(int nCameras, VideoMode mode, ColorMode colorMode, ImageProcessor::BayerPatternType bayerPatternType, FrameRate frameRate) : m_mode(mode), m_colorMode(colorMode), m_bayerPatternType(bayerPatternType), m_frameRate(frameRate)
92 {
93  m_nPorts = MAX_PORTS;
94 
95  m_pTempImageHeader = new CByteImage();
96 
97  m_pTempImage = 0;
98 
99  m_nCameras = nCameras;
100 
101  width = -1;
102  height = -1;
103 
104  m_bUseUIDs = false;
105  m_bFormat7Mode = false;
106 
107  if(m_nInstances == 0)
108  {
109  for(int i = 0 ; i < MAX_CAMERAS ; i++)
110  {
111  m_handles[i] = NULL;
112  m_pCameraOpener[i] = NULL;
113  }
114  }
115 
116  m_nInstances++;
117 }
118 
119 CLinux1394Capture::CLinux1394Capture(VideoMode mode, ColorMode colorMode, ImageProcessor::BayerPatternType bayerPatternType, FrameRate frameRate, int nNumberUIDs, ...) : m_mode(mode), m_colorMode(colorMode), m_bayerPatternType(bayerPatternType), m_frameRate(frameRate)
120 {
121  // fill camera UIDS
122  for(int i = 0 ; i < MAX_CAMERAS ; i++)
123  m_sCameraUID[i] = "";
124 
125  // read variable arguments
126  va_list ap;
127  va_start(ap, nNumberUIDs);
128 
129  for(int u = 0 ; u < nNumberUIDs ; u++)
130  {
131  const char* pch = va_arg(ap, const char*);
132  m_sCameraUID[u] += pch;
133  transform(m_sCameraUID[u].begin(), m_sCameraUID[u].end(), m_sCameraUID[u].begin(), (int(*)(int)) toupper);
134  }
135 
136  va_end(ap);
137 
138  m_nPorts = MAX_PORTS;
139 
140  m_pTempImageHeader = new CByteImage();
141 
142  m_pTempImage = 0;
143 
144  m_nCameras = nNumberUIDs;
145 
146  width = -1;
147  height = -1;
148 
149  m_bUseUIDs = true;
150  m_bFormat7Mode = false;
151 
152  if(m_nInstances == 0)
153  {
154  for(int i = 0 ; i < MAX_CAMERAS ; i++)
155  {
156  m_handles[i] = NULL;
157  m_pCameraOpener[i] = NULL;
158  }
159  }
160 
161  m_nInstances++;
162 }
163 
164 
165 // ****************************************************************************
166 // Constructors for Format7 Modes
167 // ****************************************************************************
168 
169 CLinux1394Capture::CLinux1394Capture(int nCameras, VideoMode mode, int nFormat7PacketSize, int nFormat7MinX, int nFormat7MinY, int nFormat7Width, int nFormat7Height,
170  ColorMode colorMode, ImageProcessor::BayerPatternType bayerPatternType) :
171  m_mode(mode), m_colorMode(colorMode), m_bayerPatternType(bayerPatternType)
172 {
173  m_nPorts = MAX_PORTS;
174 
175  m_pTempImageHeader = new CByteImage();
176 
177  m_pTempImage = 0;
178 
179  m_nCameras = nCameras;
180 
181  width = -1;
182  height = -1;
183 
184  m_bFormat7Mode = true;
185  m_nFormat7PacketSize = nFormat7PacketSize == -1 ? USE_MAX_AVAIL : nFormat7PacketSize;
186  m_nFormat7MinX = nFormat7MinX;
187  m_nFormat7MinY = nFormat7MinY;
188  m_nFormat7Width = nFormat7Width;
189  m_nFormat7Height = nFormat7Height;
190 
191  m_bUseUIDs = false;
192 
193  if (m_nInstances == 0)
194  {
195  for (int i = 0 ; i < MAX_CAMERAS ; i++)
196  {
197  m_handles[i] = NULL;
198  m_pCameraOpener[i] = NULL;
199  }
200  }
201 
202  m_nInstances++;
203 }
204 
205 CLinux1394Capture::CLinux1394Capture(VideoMode mode, int nFormat7PacketSize, int nFormat7MinX, int nFormat7MinY, int nFormat7Width, int nFormat7Height,
206  ColorMode colorMode, ImageProcessor::BayerPatternType bayerPatternType, int nNumberUIDs, ...) :
207  m_mode(mode), m_colorMode(colorMode), m_bayerPatternType(bayerPatternType)
208 {
209  // fill camera UIDS
210  for(int i = 0 ; i < MAX_CAMERAS ; i++)
211  m_sCameraUID[i] = "";
212 
213  // read variable arguments
214  va_list ap;
215  va_start(ap, nNumberUIDs);
216 
217  for(int u = 0 ; u < nNumberUIDs ; u++)
218  {
219  const char* pch = va_arg(ap, const char*);
220  m_sCameraUID[u] += pch;
221  transform(m_sCameraUID[u].begin(), m_sCameraUID[u].end(), m_sCameraUID[u].begin(), (int(*)(int)) toupper);
222  }
223 
224  va_end(ap);
225 
226  m_nPorts = MAX_PORTS;
227 
228  m_pTempImageHeader = new CByteImage();
229 
230  m_pTempImage = 0;
231 
232  m_nCameras = nNumberUIDs;
233 
234  width = -1;
235  height = -1;
236 
237  m_bFormat7Mode = true;
238  m_nFormat7PacketSize = nFormat7PacketSize == -1 ? USE_MAX_AVAIL : nFormat7PacketSize;
239  m_nFormat7MinX = nFormat7MinX;
240  m_nFormat7MinY = nFormat7MinY;
241  m_nFormat7Width = nFormat7Width;
242  m_nFormat7Height = nFormat7Height;
243 
244  m_bUseUIDs = true;
245  m_bFormat7Mode = true;
246 
247  if (m_nInstances == 0)
248  {
249  for (int i = 0 ; i < MAX_CAMERAS ; i++)
250  {
251  m_handles[i] = NULL;
252  m_pCameraOpener[i] = NULL;
253  }
254  }
255 
256  m_nInstances++;
257 }
258 
259 
260 // ****************************************************************************
261 // Destructor
262 // ****************************************************************************
263 
265 {
266  CloseCamera();
267 
268  delete m_pTempImageHeader;
269 
270  if (m_pTempImage)
271  delete m_pTempImage;
272 
273  // clean up if last instance
274  m_nInstances--;
275 
276  if(m_nInstances == 0)
277  {
278  // release camera nodes
279  for(int p = 0 ; p < m_nPorts ; p++)
280  dc1394_free_camera_nodes(m_pCameraNodes[p]);
281 
282  // destroy handles
283  for(int h = 0 ; h < m_nOverallCameras ; h++)
284  dc1394_destroy_handle(m_handles[h]);
285 
286  m_nOverallCameras = 0;
287  }
288 }
289 
290 
292 {
293  CloseCamera();
294 
295  // create temporary images and init modes
296  if(!InitCameraMode())
297  {
298  printf("error: selected camera mode not supported\n");
299  return false;
300  }
301 
302  // retrieve info for all cameras
303  if(!ListCameras())
304  {
305  CloseCamera();
306  return false;
307  }
308 
309  // open cameras
310  if(m_bUseUIDs)
311  {
312  for(int c = 0 ; c < m_nCameras ; c++)
313  {
314  bool bOpened = false;
315  for(int a = 0 ; a < m_nOverallCameras ; a++)
316  {
317  if(m_sCameraUID[c] == m_CameraInfo[a].sUID)
318  {
319  if(m_pCameraOpener[a])
320  {
321  printf("error: camera with UID 0x%s already opened\n", m_sCameraUID[c].c_str());
322  return false;
323  }
324  if(!OpenCamera(a))
325  return false;
326 
327  m_pCameraOpener[a] = this;
328  m_nOpenedCameras[c] = a;
329  bOpened = true;
330  }
331  }
332 
333  if(!bOpened)
334  {
335  printf("error: could not find camera with UID 0x%s\n",m_sCameraUID[c].c_str());
336  CloseCamera();
337  return false;
338  }
339  }
340  } else {
341  int nNumberCameras = 0;
342  for(int c = 0 ; c < m_nOverallCameras ; c++)
343  {
344  if(m_pCameraOpener[c] == NULL)
345  {
346  if(!OpenCamera(c))
347  return false;
348 
349  m_pCameraOpener[c] = this;
350  m_nOpenedCameras[nNumberCameras] = c;
351  nNumberCameras++;
352  }
353 
354  if( (m_nCameras != -1) && (nNumberCameras == m_nCameras))
355  break;
356  }
357 
358  if(m_nCameras == -1)
359  {
360  if(nNumberCameras == 0)
361  {
362  printf("error: no camera found\n");
363  CloseCamera();
364  return false;
365  }
366  m_nCameras = nNumberCameras;
367  }
368 
369  if(nNumberCameras < m_nCameras)
370  {
371  printf("error: could not open requested number of cameras\n");
372  CloseCamera();
373  return false;
374  }
375  }
376 
377  return true;
378 }
379 
381 {
382  int p = m_CameraInfo[nCamera].nPort;
383  int i = m_CameraInfo[nCamera].nIndex;
384 
385  printf("Opening camera %d: Port %d, Index %d, UID 0x%s, Format7 = %i\n",nCamera,p,i,m_CameraInfo[nCamera].sUID.c_str(), m_bFormat7Mode);
386 
387  char *device_name = 0;
388 
389  if (m_bFormat7Mode)
390  {
391  if (dc1394_dma_setup_format7_capture(m_handles[nCamera], m_cameras[nCamera].node, i + 1, MODE_FORMAT7_0, SPEED_400, m_nFormat7PacketSize, m_nFormat7MinX, m_nFormat7MinY, m_nFormat7Width, m_nFormat7Height, NUM_BUFFERS, DROP_FRAMES, device_name, &m_cameras[nCamera]) != DC1394_SUCCESS)
392  {
393  printf("error: unable to setup camera (mode supported by camera?)\n");
394  CloseCamera();
395  return false;
396  }
397  }
398  else
399  {
400  if (dc1394_dma_setup_capture(m_handles[nCamera], m_cameras[nCamera].node, i + 1, FORMAT_VGA_NONCOMPRESSED, m_video_mode, SPEED_400, GetDCFrameRateMode(m_frameRate), NUM_BUFFERS, DROP_FRAMES, device_name, &m_cameras[nCamera]) != DC1394_SUCCESS)
401  {
402  printf("error: unable to setup camera (mode supported by camera?)\n");
403  CloseCamera();
404  return false;
405  }
406  }
407 
408  // have the camera start sending us data
409  if (dc1394_start_iso_transmission(m_handles[nCamera], m_cameras[nCamera].node) != DC1394_SUCCESS)
410  {
411  printf("error: unable to start camera iso transmission\n");
412  CloseCamera();
413  return false;
414  }
415 
416  return true;
417 }
418 
420 {
421  for (int i = 0; i < m_nCameras; i++)
422  {
423  if (m_handles[i])
424  {
425  if(m_pCameraOpener[i] == this)
426  {
427  dc1394_dma_unlisten(m_handles[i], &m_cameras[i]);
428  dc1394_dma_release_camera(m_handles[i], &m_cameras[i]);
429  m_pCameraOpener[i] = NULL;
430  }
431  }
432  }
433 
434  width = -1;
435  height = -1;
436 
437  if (m_pTempImage)
438  {
439  delete m_pTempImage;
440  m_pTempImage = 0;
441  }
442 }
443 
445 {
446  width = -1;
447  height = -1;
448  int video_mode = 0;
449 
450  if (m_mode == e640x480)
451  {
452  width = 640;
453  height = 480;
454 
455  m_pTempImageHeader->width = 640;
456  m_pTempImageHeader->height = 480;
457 
458  switch (m_colorMode)
459  {
460  case eGrayScale:
462  m_video_mode = MODE_640x480_MONO;
463  break;
464 
465  case eRGB24:
466  m_video_mode = MODE_640x480_RGB;
467  break;
468 
469  case eYUV411ToRGB24:
470  m_video_mode = MODE_640x480_YUV411;
471  break;
472  }
473  }
474  else if (m_mode == e320x240)
475  {
476  width = 320;
477  height = 240;
478 
479  switch (m_colorMode)
480  {
481  case eGrayScale:
482  m_video_mode = MODE_640x480_MONO;
483  m_pTempImageHeader->width = 640;
484  m_pTempImageHeader->height = 480;
485  break;
486 
488  m_video_mode = MODE_640x480_MONO;
489  m_pTempImage = new CByteImage(640, 480, CByteImage::eRGB24);
490  m_pTempImageHeader->width = 640;
491  m_pTempImageHeader->height = 480;
492  break;
493 
494  case eRGB24:
495  m_video_mode = MODE_640x480_RGB;
496  m_pTempImageHeader->width = 640;
497  m_pTempImageHeader->height = 480;
498  break;
499 
500  case eYUV411ToRGB24:
501  m_video_mode = MODE_640x480_YUV411;
502  m_pTempImage = new CByteImage(640, 480, CByteImage::eRGB24);
503  m_pTempImageHeader->width = 640;
504  m_pTempImageHeader->height = 480;
505  break;
506  }
507  }
508  else
509  {
510  // mode not supported
511  return false;
512  }
513 
515  {
518  }
519  else if (m_colorMode == eRGB24 || m_colorMode == eYUV411ToRGB24)
520  {
523  }
524 
525  return true;
526 }
527 
529 {
530 
531  int width = pInput->width;
532  int height = pInput->height;
533 
534  int y1,y2,y3,y4,u,v;
535  int r,g,b;
536 
537  unsigned char* output = pOutput->pixels;
538  unsigned char* input = pInput->pixels;
539  // read chunks
540  for(int i = 0 ; i < height ; i++)
541  {
542  for(int j = 0 ; j < width / 4 ; j++)
543  {
544  u = input[0];
545  y1 = input[1];
546  y2 = input[2];
547 
548  v = input[3];
549  y3 = input[4];
550  y4 = input[5];
551 
552  YUVToRGB(y1,u,v,output);
553  YUVToRGB(y2,u,v,output + 3);
554  YUVToRGB(y3,u,v,output + 6);
555  YUVToRGB(y4,u,v,output + 9);
556 
557  input += 6;
558  output += 12;
559  }
560  }
561 }
562 
563 void CLinux1394Capture::YUVToRGB(int y, int u, int v, unsigned char* output)
564 {
565  int r,g,b;
566 
567  // u and v are +-0.5
568  u -= 128;
569  v -= 128;
570 
571  // conversion
572  r = int(y + 1.370705 * v);
573  g = int(y - 0.698001 * v - 0.337633 * u);
574  b = int(y + 1.732446 * u);
575 
576  // clamp to 0..1
577  if (r < 0) r = 0;
578  if (g < 0) g = 0;
579  if (b < 0) b = 0;
580  if (r > 255) r = 255;
581  if (g > 255) g = 255;
582  if (b > 255) b = 255;
583 
584  output[0] = (unsigned char) r;
585  output[1] = (unsigned char) g;
586  output[2] = (unsigned char) b;
587 }
588 
590 {
591  if ( (width == -1) || (height == -1) )
592  return false;
593 
594  int i;
595 
596  // first tell dc1394 that buffers can be reused
597  for (i = 0; i < m_nCameras; i++)
598  {
599  if (!m_handles[m_nOpenedCameras[i]])
600  return false;
601 
602  dc1394_dma_done_with_buffer(&m_cameras[m_nOpenedCameras[i]]);
603  }
604 
605  for (i = 0; i < m_nCameras; i++)
606  {
607  dc1394_dma_single_capture(&m_cameras[m_nOpenedCameras[i]]);
608  }
609 
610  for (i = 0; i < m_nCameras; i++)
611  {
612  m_pTempImageHeader->pixels = (unsigned char *) m_cameras[m_nOpenedCameras[i]].capture_buffer;
613 
614  if (m_mode == e640x480)
615  {
616  switch (m_colorMode)
617  {
620  break;
621 
622  case eGrayScale:
623  case eRGB24:
625  break;
626  case eYUV411ToRGB24:
627  ConvertYUV411(m_pTempImageHeader, ppImages[i]);
628  break;
629  }
630  }
631  else if (m_mode == e320x240)
632  {
633  switch (m_colorMode)
634  {
637  ImageProcessor::Resize(m_pTempImage, ppImages[i]);
638  break;
639 
640  case eGrayScale:
641  case eRGB24:
643  break;
644  case eYUV411ToRGB24:
646  ImageProcessor::Resize(m_pTempImage, ppImages[i]);
647  break;
648  }
649  }
650  }
651 
652  return true;
653 }
654 
656 {
657  if ( (width == -1) || (height == -1) )
658  return false;
659 
660  int i;
661 
662  // first tell dc1394 that buffers can be reused
663  for (i = 0; i < m_nCameras; i++)
664  {
665  if (!m_handles[m_nOpenedCameras[i]])
666  return false;
667 
668  dc1394_dma_done_with_buffer(&m_cameras[m_nOpenedCameras[i]]);
669  }
670 
671  for (i = 0; i < m_nCameras; i++)
672  {
673  dc1394_dma_single_capture(&m_cameras[m_nOpenedCameras[i]]);
674  }
675 
676  for (i = 0; i < m_nCameras; i++)
677  {
678  m_pTempImageHeader->pixels = (unsigned char *) m_cameras[m_nOpenedCameras[i]].capture_buffer;
679 
680  if (m_mode == e640x480)
681  {
683  }
684  else if (m_mode == e320x240)
685  {
687  }
688  }
689 
690  return true;
691 }
692 
694 {
695  switch (m_colorMode)
696  {
697  case eYUV411ToRGB24:
699  case eRGB24:
700  return CByteImage::eRGB24;
701  break;
702 
703  case eGrayScale:
704  return CByteImage::eGrayScale;
705  break;
706  }
707 
708  return (CByteImage::ImageType) -1;
709 }
710 
711 void CLinux1394Capture::SetGain(unsigned int nValue)
712 {
713  for (int i = 0; i < m_nCameras; i++)
714  {
715  if (nValue == -1)
716  {
717  dc1394_auto_on_off(m_handles[i], m_cameras[i].node, FEATURE_GAIN, 1);
718  }
719  else
720  {
721  dc1394_auto_on_off(m_handles[i], m_cameras[i].node, FEATURE_GAIN, 0);
722  dc1394_set_gain(m_handles[i], m_cameras[i].node, nValue);
723  }
724  }
725 }
726 
727 void CLinux1394Capture::SetExposure(unsigned int nValue)
728 {
729  for (int i = 0; i < m_nCameras; i++)
730  {
731  if (nValue == -1)
732  {
733  dc1394_auto_on_off(m_handles[i], m_cameras[i].node, FEATURE_EXPOSURE, 1);
734  }
735  else
736  {
737  dc1394_auto_on_off(m_handles[i], m_cameras[i].node, FEATURE_EXPOSURE, 0);
738  dc1394_set_exposure(m_handles[i], m_cameras[i].node, nValue);
739  }
740  }
741 }
742 
743 void CLinux1394Capture::SetShutter(unsigned int nValue)
744 {
745  for (int i = 0; i < m_nCameras; i++)
746  {
747  if (nValue == -1)
748  {
749  dc1394_auto_on_off(m_handles[i], m_cameras[i].node, FEATURE_SHUTTER, 1);
750  }
751  else
752  {
753  dc1394_auto_on_off(m_handles[i], m_cameras[i].node, FEATURE_SHUTTER, 0);
754  dc1394_set_shutter(m_handles[i], m_cameras[i].node, nValue);
755  }
756  }
757 }
758 
760 {
761  switch(frameRate)
762  {
763  case e60fps: return FRAMERATE_60;
764  case e30fps: return FRAMERATE_30;
765  case e15fps: return FRAMERATE_15;
766  case e7_5fps: return FRAMERATE_7_5;
767  case e3_75fps: return FRAMERATE_3_75;
768  case e1_875fps: return FRAMERATE_1_875;
769 
770  default: return FRAMERATE_30;
771  };
772 }
773 
775 {
776  // already listed
777  if(m_nOverallCameras != 0)
778  return true;
779 
780  // first: count cameras
781  raw1394handle_t raw_handle = raw1394_new_handle();
782  if (!raw_handle)
783  {
784  printf("error: unable to aquire a raw1394 handle\n");
785  return false;
786  }
787 
788  raw1394_portinfo ports[MAX_PORTS];
789  m_nPorts = raw1394_get_port_info(raw_handle, ports, m_nPorts);
790  raw1394_destroy_handle(raw_handle);
791  printf("number of ports = %d\n", m_nPorts);
792 
793  // build info for all cameras
794  for (int p = 0; p < m_nPorts; p++)
795  {
796  int camCount;
797 
798  // get the camera nodes and describe them as we find them
799  raw_handle = raw1394_new_handle();
800  raw1394_set_port(raw_handle, p);
801  m_pCameraNodes[p] = dc1394_get_camera_nodes(raw_handle, &camCount, 1);
802  raw1394_destroy_handle(raw_handle);
803 
804  // check cameras and retrieve info for capture
805  for (int i = 0; i < camCount; i++)
806  {
807  m_handles[m_nOverallCameras] = dc1394_create_handle(p);
809  {
810  printf("error: unable to aquire a raw1394 handle\n");
811  CloseCamera();
812  return false;
813  }
814 
816  dc1394_feature_set features;
817 
818  if (dc1394_get_camera_feature_set(m_handles[m_nOverallCameras], m_cameras[m_nOverallCameras].node, &features) != DC1394_SUCCESS)
819  {
820  printf("info: unable to get feature set\n");
821  }
822  else
823  {
824  //dc1394_print_feature_set(&m_features);
825  }
826 
827  unsigned int channel, speed;
828 
829  if (dc1394_get_iso_channel_and_speed(m_handles[m_nOverallCameras], m_cameras[m_nOverallCameras].node, &channel, &speed) != DC1394_SUCCESS)
830  {
831  printf("error: unable to get the iso channel number\n");
832  CloseCamera();
833  return false;
834  }
835 
836  // retrieve camera info
837  dc1394_camerainfo info;
838 
839  if (dc1394_get_camera_info(m_handles[m_nOverallCameras], m_cameras[m_nOverallCameras].node, &info) != DC1394_SUCCESS)
840  {
841  printf("error: unable to retrieve camera info\n");
842  CloseCamera();
843  return false;
844  } else {
847  unsigned int low = info.euid_64;
848  unsigned int high = (info.euid_64 >> 32);
850  m_nOverallCameras++;
851 
852  if(m_nOverallCameras > MAX_CAMERAS)
853  {
854  printf("error: found more cameras than MAX_CAMERAS\n");
855  CloseCamera();
856  return false;
857  }
858  }
859  }
860  }
861 
862  return true;
863 }
864 
865 std::string CLinux1394Capture::CamUIDToString(unsigned int nLow, unsigned int nHigh)
866 {
867  std::string UID = "";
868  char szUID[17];
869  sprintf(szUID,"%08X%08X\0",nHigh,nLow);
870  UID += szUID;
871 
872  return UID;
873 }
int m_nOpenedCameras[MAX_CAMERAS]
GLubyte g
Definition: glext.h:5166
void ConvertYUV411(CByteImage *pInput, CByteImage *pOutput)
int GetDCFrameRateMode(FrameRate frameRate)
BayerPatternType
The four possible variants for Bayer pattern conversion.
CByteImage * m_pTempImageHeader
int width
The width of the image in pixels.
Definition: ByteImage.h:257
static TCameraInfo m_CameraInfo[MAX_CAMERAS]
static nodeid_t * m_pCameraNodes[MAX_PORTS]
bool ConvertBayerPattern(const CByteImage *pInputImage, CByteImage *pOutputImage, BayerPatternType type)
Converts an 8 bit Bayer pattern CByteImage to an RGB24 color CByteImage.
const ImageProcessor::BayerPatternType m_bayerPatternType
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
Definition: ByteImage.h:80
CLinux1394Capture(int nCameras, VideoMode mode, ColorMode colorMode, ImageProcessor::BayerPatternType bayerPatternType=ImageProcessor::eBayerRG, FrameRate frameRate=e30fps)
const ColorMode m_colorMode
unsigned char * pixels
The pointer to the the pixels.
Definition: ByteImage.h:283
static dc1394_cameracapture m_cameras[MAX_CAMERAS]
static raw1394handle_t m_handles[MAX_CAMERAS]
void SetExposure(unsigned int nValue)
static int m_nOverallCameras
CByteImage::ImageType GetType()
#define DROP_FRAMES
bool CaptureImage(CByteImage **ppImages)
const GLubyte * c
Definition: glext.h:5181
void SetShutter(unsigned int nValue)
GLuint GLuint end
Definition: glext.h:3121
bool CopyImage(const CByteImage *pInputImage, CByteImage *pOutputImage, const MyRegion *pROI=0, bool bUseSameSize=false)
Copies one CByteImage to another.
#define MAX_PORTS
GLsizei const GLchar ** string
Definition: glext.h:3528
GLubyte GLubyte GLubyte a
Definition: glext.h:5166
int height
The height of the image in pixels.
Definition: ByteImage.h:264
const VideoMode m_mode
GLint mode
Definition: glext.h:4669
#define NUM_BUFFERS
std::string m_sCameraUID[MAX_CAMERAS]
GLubyte GLubyte b
Definition: glext.h:5166
int bytesPerPixel
The number of bytes used for encoding one pixel.
Definition: ByteImage.h:273
std::string CamUIDToString(unsigned int nLow, unsigned int nHigh)
GLenum GLsizei width
Definition: glext.h:3122
GLenum GLsizei GLsizei height
Definition: glext.h:3132
ImageType
Enum specifying the supported image types.
Definition: ByteImage.h:86
static CLinux1394Capture * m_pCameraOpener[MAX_CAMERAS]
GLenum GLenum GLenum input
Definition: glext.h:5307
ImageType type
The type of the image.
Definition: ByteImage.h:292
void SetGain(unsigned int nValue)
GLdouble GLdouble GLdouble r
Definition: glext.h:3227
GLenum GLint GLint y
Definition: glext.h:3125
const GLdouble * v
Definition: glext.h:3212
#define MAX_CAMERAS
GLuint GLenum GLenum transform
Definition: glext.h:5683
GLfloat GLfloat p
Definition: glext.h:5178
void YUVToRGB(int y, int u, int v, unsigned char *output)
bool CaptureBayerPatternImage(CByteImage **ppImages)
CByteImage * m_pTempImage
bool Resize(const CByteImage *pInputImage, CByteImage *pOutputImage, const MyRegion *pROI=0, bool bInterpolation=true)
Resizes a CByteImage and writes the result to a CByteImage.


asr_ivt
Author(s): Allgeyer Tobias, Hutmacher Robin, Kleinert Daniel, Meißner Pascal, Scholz Jonas, Stöckle Patrick
autogenerated on Mon Dec 2 2019 03:47:28