Linux1394Capture2.h
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: Linux1394Capture2.h
37 // Author: Kai Welke, Pedram Azad
38 // Date: 2007
39 // ****************************************************************************
40 // Requires: * libdc1394v2
41 // * libraw1394 >= 1.2.0
42 // ****************************************************************************
43 // Changes: 20.12.2007. Kai Welke
44 // * Built CLinux1394Capture2 on base of CLinux1394Capture
45 // * switched from libdc1394v1 to libdc1394v2 (solved problem
46 // with QT and allowed to use full firewire bandwidth)
47 // * added check for maximum bandwidth
48 // * generic camera feature access
49 // * Format7_0 implemented with ROI and framerate settings
50 // format7 support is camera dependant (dragonfly only
51 // supports two discrete framerates, dragonfly2 can be
52 // adjusted from 0.x ... 60.0 frames.
53 // ****************************************************************************
54 
55 
56 #ifndef _LINUX_1394_CAPTURE_2_H_
57 #define _LINUX_1394_CAPTURE_2_H_
58 
59 
60 // ****************************************************************************
61 // Necessary includes
62 // ****************************************************************************
63 
65 #include "Image/ImageProcessor.h"
66 #include <string>
67 #include <vector>
68 
69 #include <libraw1394/raw1394.h>
70 #include <dc1394/dc1394.h>
71 
72 
73 // ****************************************************************************
74 // Forward declarations
75 // ****************************************************************************
76 
77 class CByteImage;
78 
79 
80 // ****************************************************************************
81 // Defines
82 // ****************************************************************************
83 
84 // don't set this smaller than 2
85 #define MAX_CAMERAS 4
86 // maximum bandwidth of firewire (in quadlets / cycle)
87 #define MAX_S400_BANDWIDTH 4915
88 
89 
90 
91 // ****************************************************************************
92 // CLinux1394Capture2
93 // ****************************************************************************
94 
96 {
97 public:
98  // constructor, variable arguments are camera uids as const char*
99  CLinux1394Capture2(int nCameras, VideoMode mode, ColorMode colorMode, ImageProcessor::BayerPatternType bayerPatternType = ImageProcessor::eBayerRG, FrameRate frameRate = e30fps);
100  CLinux1394Capture2(VideoMode mode, ColorMode colorMode, ImageProcessor::BayerPatternType bayerPatternType = ImageProcessor::eBayerRG, FrameRate frameRate = e30fps, int nNumberUIDs = 0, ...);
101 
102  // format 7 modes
103  CLinux1394Capture2(int nCameras, VideoMode mode, float fFormat7FrameRate = 30.0f, int nFormat7MinX = 0, int nFormat7MinY = 0, int nFormat7Width = -1, int nFormat7Height = -1, ColorMode colorMode = CVideoCaptureInterface::eBayerPatternToRGB24, ImageProcessor::BayerPatternType bayerPatternType = ImageProcessor::eBayerRG);
104 
105  CLinux1394Capture2(VideoMode mode, float fFormat7FrameRate = 30.0f, int nFormat7MinX = 0, int nFormat7MinY = 0, int nFormat7Width = -1, int nFormat7Height = -1, ColorMode colorMode = CVideoCaptureInterface::eBayerPatternToRGB24, ImageProcessor::BayerPatternType bayerPatternType = ImageProcessor::eBayerRG, int nNumberUIDs = 0, ...);
106 
107 
108  // destructor
110 
111 
112  // public methods
113  bool OpenCamera();
114  void CloseCamera();
115  bool CaptureImage(CByteImage **ppImages);
116  bool CaptureBayerPatternImage(CByteImage **ppImages);
117 
118  // SetCameraUids can be used if the UIDs are determined dynamically
119  void SetCameraUids(std::vector<std::string> uids);
120  void SetGain(int nValue);
121  void SetExposure(int nValue);
122  void SetShutter(int nValue);
123  void SetWhiteBalance(int nU, int nV, int nCamera = -1);
124  void SetTemperature(int nTemperature);
125  void SetFeature(dc1394feature_t feature, std::string sName, int nValue);
126 
127  void ListFeatures();
128 
129  int GetWidth() { return width; }
130  int GetHeight() { return height; }
132  int GetNumberOfCameras() { return m_nCameras; }
133 
134  dc1394camera_t* GetCameraHandle(int Index) { return m_cameras[Index]; }
135 
136  VideoMode GetVideoMode() const {return m_mode;}
138 
139 protected:
140  // private methods
141  void InitFirstInstance();
142  void ExitLastInstance();
143  void ResetAllCameras();
144 
145  bool OpenCamera(int nCamera);
146  bool InitCameraMode();
147  dc1394framerate_t GetDCFrameRateMode(FrameRate frameRate);
148 
149  // conversion
150  void ConvertYUV411(CByteImage* pInput, CByteImage* pOutput);
151  void YUVToRGB(int y, int u, int v, unsigned char* output);
152 
153  // multiple camera handling
154  bool ListCameras();
155  std::string CamUIDToString(uint64_t uid);
156 
157  // private attributes
158  // temporary images for capruting
160 
161  int m_nMode;
162 
163  int width;
164  int height;
165 
166  // number of cameras requested by user
168  // requested video mode (see VideoCaptureInterface.h)
170  // requested color mode (see VideoCaptureInterface.h)
172  // requested frame rate (see VideoCaptureInterface.h)
174  // requested bayer pattern type (see ImageProcessor.h)
176  // unique camera ids as requested by user
179  // opened camera ids
181  // video mode
182  dc1394video_mode_t m_video_mode;
183  // format 7 mode
190 
191  // static for all instances
192  // lib dc + raw specific camera data
193  static dc1394_t* m_pDC1394;
194  static dc1394camera_t* m_cameras[MAX_CAMERAS];
195 
196  // internal camera data
197  static int m_nOverallCameras;
201 
202  // static instance counter for handle destruction
203  static int m_nInstances;
204 };
205 
206 
207 
208 #endif /* _LINUX_1394_CAPTURE_2_H_ */
void ConvertYUV411(CByteImage *pInput, CByteImage *pOutput)
CByteImage * m_pTempImageHeader
BayerPatternType
The four possible variants for Bayer pattern conversion.
void SetWhiteBalance(int nU, int nV, int nCamera=-1)
CByteImage::ImageType GetType()
void SetCameraUids(std::vector< std::string > uids)
dc1394framerate_t GetDCFrameRateMode(FrameRate frameRate)
FrameRate GetFrameRate() const
#define MAX_CAMERAS
static dc1394_t * m_pDC1394
void SetExposure(int nValue)
static int m_nRemainingBandwidth
VideoMode GetVideoMode() const
void SetFeature(dc1394feature_t feature, std::string sName, int nValue)
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
Definition: ByteImage.h:80
void SetTemperature(int nTemperature)
bool CaptureBayerPatternImage(CByteImage **ppImages)
static int m_nCameraBandwidth[MAX_CAMERAS]
void SetShutter(int nValue)
bool CaptureImage(CByteImage **ppImages)
std::string CamUIDToString(uint64_t uid)
GLsizei const GLchar ** string
Definition: glext.h:3528
CLinux1394Capture2(int nCameras, VideoMode mode, ColorMode colorMode, ImageProcessor::BayerPatternType bayerPatternType=ImageProcessor::eBayerRG, FrameRate frameRate=e30fps)
int m_nOpenedCameras[MAX_CAMERAS]
dc1394camera_t * GetCameraHandle(int Index)
std::string m_sCameraUID[MAX_CAMERAS]
const VideoMode m_mode
GLint mode
Definition: glext.h:4669
void YUVToRGB(int y, int u, int v, unsigned char *output)
const ColorMode m_colorMode
ImageType
Enum specifying the supported image types.
Definition: ByteImage.h:86
Interface to video capture modules.
static dc1394camera_t * m_cameras[MAX_CAMERAS]
GLenum GLint GLint y
Definition: glext.h:3125
const GLdouble * v
Definition: glext.h:3212
const ImageProcessor::BayerPatternType m_bayerPatternType
void SetGain(int nValue)
static CLinux1394Capture2 * m_pCameraOpener[MAX_CAMERAS]
static int m_nOverallCameras
dc1394video_mode_t m_video_mode


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