IEEE1394ImageProvider.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package VisionX::Component
19  * @author Jan Issac (jan dot issac at gmx dot net)
20  * @date 2011
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
27 // VisionXCore
29 
30 // IVT
31 #include <Image/ByteImage.h>
32 #include <Image/ImageProcessor.h>
33 #include <Interfaces/VideoCaptureInterface.h>
34 //#include <VideoCapture/Linux1394Capture2.h>
35 #include <VideoCapture/Linux1394CaptureThreaded2.h>
36 
37 // STL
38 #include <string>
39 #include <map>
40 
41 namespace visionx
42 {
43 
44  struct ColorFormat
45  {
46  CVideoCaptureInterface::ColorMode colorMode;
47  visionx::ImageType imageType;
48 
50  {
51  }
52 
53  ColorFormat(CVideoCaptureInterface::ColorMode colorMode,
54  visionx::ImageType imageType)
56  {
57  }
58 
59  bool operator==(const ColorFormat& colorFormat) const
60  {
61  if (colorFormat.colorMode != colorMode)
62  {
63  return false;
64  }
65 
66  if (colorFormat.imageType != imageType)
67  {
68  return false;
69  }
70 
71  return true;
72  }
73  };
74 
77  {
78  public:
81  {
82 
83  defineOptionalProperty<ImageDimension>("VideoMode", ImageDimension(640, 480), "Image resolution")
84  .setCaseInsensitive(true)
85  .map("320x240", ImageDimension(320, 240))
86  .map("640x480", ImageDimension(640, 480))
87  .map("800x600", ImageDimension(800, 600))
88  .map("768x576", ImageDimension(768, 576))
89  .map("1024x768", ImageDimension(1024, 768))
90  .map("1280x960", ImageDimension(1280, 960))
91  .map("1600x1200", ImageDimension(1600, 1200))
92  .map("none", ImageDimension(0, 0));
93 
94  defineOptionalProperty<ColorFormat>("ColorMode", ColorFormat(CVideoCaptureInterface::eRGB24, eRgb), "Image color mode")
95  .setCaseInsensitive(true)
96  .map("gray-scale", ColorFormat(CVideoCaptureInterface::eGrayScale, eGrayScale))
97  .map("rgb", ColorFormat(CVideoCaptureInterface::eRGB24, eRgb))
98  .map("bayer-pattern", ColorFormat(CVideoCaptureInterface::eBayerPatternToRGB24, eBayerPattern))
99  .map("bayer-pattern-to-rgb", ColorFormat(CVideoCaptureInterface::eBayerPatternToRGB24, eRgb))
100  .map("yuv411-to-rgb", ColorFormat(CVideoCaptureInterface::eYUV411ToRGB24, eRgb));
101 
102  defineOptionalProperty<BayerPatternType>("BayerPatternType", eBayerPatternRg, "Raw image color pattern")
103  .setCaseInsensitive(true)
104  .map("bayer-pattern-bg", eBayerPatternBg)
105  .map("bayer-pattern-gb", eBayerPatternGb)
106  .map("bayer-pattern-gr", eBayerPatternGr)
107  .map("bayer-pattern-rg", eBayerPatternRg);
108 
109  defineOptionalProperty<bool>("Format7Mode", false, "Use Format7 mode");
110 
111  defineOptionalProperty<float>("FrameRate", 7.5f, "Frames per second")
112  .setMatchRegex("\\d+(.\\d*)?")
113  .setMin(0.0f)
114  .setMax(60.0f);
115 
116  // Camera UIDs
117  defineRequiredProperty<std::string>("CameraUIDs", "Camera UIDs seperated by comma, space or tab")
118  .setCaseInsensitive(true)
119  .setMatchRegex("\\s*[a-zA-Z0-9]{16}\\s*((,|\\s)\\s*[a-zA-Z0-9]{16})*");
120 
121  defineOptionalProperty<std::string>("ReferenceFrameName", "EyeLeftCameras", "Optional reference frame name.");
122  }
123  };
124 
125 
126  /**
127  * IEEE1394 image provider captures images from one or more cameras and
128  * supports the following image transmission formats:
129  *
130  * - RGB
131  * - Gray Scale
132  * - Bayer Pattern (Bg, Gb, Gr, Rg)
133  *
134  * \componentproperties
135  * \prop VisionX.IEEE1394ImageProvider.CameraUIDs: Comma or space separated
136  * list of camera UIDs. If not set all cameras will be opened.
137  * \prop VisionX.IEEE1394ImageProvider.VideoMode: Defines the camera
138  * resolution.
139  * - 320x240
140  * - 640x480 (default)
141  * - 800x600
142  * - 768x576
143  * - 1024x768
144  * - 1280x960
145  * - 1600x1200
146  * - none
147  * \prop VisionX.IEEE1394ImageProvider.ColorMode: Specifies how image format
148  * of camera is interpreted and converted. Cameras may support only
149  * one color mode. Possible values:
150  * - gray-scale
151  * - rgb
152  * - bayer-pattern
153  * - bayer-pattern-to-rgb (default)
154  * - yuv411-to-rgb
155  * \prop VisionX.IEEE1394ImageProvider.BayerPatternType: Specifies the bayer
156  * pattern type. Required only if ColorMode uses a bayer pattern
157  * format.
158  * Possible values:
159  * - bayer-pattern-bg
160  * - bayer-pattern-gb
161  * - bayer-pattern-gr
162  * - bayer-pattern.rg (default)
163  * \prop VisionX.IEEE1394ImageProvider.FrameRate: Capture frame rate as
164  * float (default: 30fps)
165  * \prop VisionX.IEEE1394ImageProvider.Format7Mode: Enable or disable
166  * IEEE1394 format 7 mode (possible values: true, false (default)).
167  */
169  virtual public visionx::CapturingImageProvider
170  {
171  public:
172  /**
173  * @see visionx::ImageProviderBase::onInitImageProvider()
174  */
175  void onInitCapturingImageProvider() override;
176 
177  /**
178  * @see visionx::ImageProviderBase::onExitImageProvider()
179  */
180  void onExitCapturingImageProvider() override;
181 
182  /**
183  * @see visionx::ImageProviderBase::onStartCapture()
184  */
185  void onStartCapture(float frameRate) override;
186 
187  /**
188  * @see visionx::ImageProviderBase::onStopCapture()
189  */
190  void onStopCapture() override;
191 
192  /**
193  * @see visionx::ImageProviderBase::capture()
194  */
195  bool capture(void** ppImageBuffers) override;
196 
197  /**
198  * @see armarx::Component::getDefaultName()
199  */
200  std::string getDefaultName() const override
201  {
202  return "IEEE1394ImageProvider";
203  }
204 
205  /**
206  * @see PropertyUser::createPropertyDefinitions()
207  */
209  {
213  }
214 
215 
216  protected:
217  /**
218  * Camera UID list
219  */
220  std::vector<std::string> uids;
221 
222  /**
223  * Camera color mode and resulting image time
224  */
226 
227  /**
228  * Video dimension data
229  */
230  visionx::ImageDimension videoDimension;
231 
232  /**
233  * Specific bayer pattern type, if ColorMode is BayerPattern
234  */
235  visionx::BayerPatternType bayerPatternType;
236 
237  /**
238  * Captured images
239  */
240  CByteImage** ppImages;
241 
242  /**
243  * Indicate whether using format 7 modes or not
244  */
246 
247  /**
248  * IEEE1394 Capture
249  */
250  //CLinux1394Capture2* ieee1394Capturer;
251  CLinux1394CaptureThreaded2* ieee1394Capturer;
252  };
253 }
visionx::ColorFormat::colorMode
CVideoCaptureInterface::ColorMode colorMode
Definition: IEEE1394ImageProvider.h:46
visionx::IEEE1394ImageProvider
IEEE1394 image provider captures images from one or more cameras and supports the following image tra...
Definition: IEEE1394ImageProvider.h:168
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::CapturingImageProvider::frameRate
float frameRate
Required frame rate.
Definition: CapturingImageProvider.h:198
visionx::IEEE1394ImageProvider::isFormat7Mode
bool isFormat7Mode
Indicate whether using format 7 modes or not.
Definition: IEEE1394ImageProvider.h:245
visionx::IEEE1394ImageProvider::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: IEEE1394ImageProvider.h:208
visionx::IEEE1394ImageProvider::uids
std::vector< std::string > uids
Camera UID list.
Definition: IEEE1394ImageProvider.h:220
visionx::IEEE1394PropertyDefinitions::IEEE1394PropertyDefinitions
IEEE1394PropertyDefinitions(std::string prefix)
Definition: IEEE1394ImageProvider.h:79
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
visionx::IEEE1394ImageProvider::onStopCapture
void onStopCapture() override
Definition: IEEE1394ImageProvider.cpp:156
visionx::ColorFormat::imageType
visionx::ImageType imageType
Definition: IEEE1394ImageProvider.h:47
visionx::ColorFormat::ColorFormat
ColorFormat()
Definition: IEEE1394ImageProvider.h:49
visionx::IEEE1394ImageProvider::bayerPatternType
visionx::BayerPatternType bayerPatternType
Specific bayer pattern type, if ColorMode is BayerPattern.
Definition: IEEE1394ImageProvider.h:235
visionx::ColorFormat::ColorFormat
ColorFormat(CVideoCaptureInterface::ColorMode colorMode, visionx::ImageType imageType)
Definition: IEEE1394ImageProvider.h:53
visionx::ColorFormat
Definition: IEEE1394ImageProvider.h:44
visionx::IEEE1394ImageProvider::videoDimension
visionx::ImageDimension videoDimension
Video dimension data.
Definition: IEEE1394ImageProvider.h:230
visionx::IEEE1394ImageProvider::getDefaultName
std::string getDefaultName() const override
Definition: IEEE1394ImageProvider.h:200
visionx::CapturingImageProvider::capture
virtual void capture()
Definition: CapturingImageProvider.cpp:106
visionx::CapturingImageProvider
The CapturingImageProvider provides a callback function to trigger the capturing of images with diffe...
Definition: CapturingImageProvider.h:52
visionx::ColorFormat::operator==
bool operator==(const ColorFormat &colorFormat) const
Definition: IEEE1394ImageProvider.h:59
visionx::IEEE1394ImageProvider::ieee1394Capturer
CLinux1394CaptureThreaded2 * ieee1394Capturer
IEEE1394 Capture.
Definition: IEEE1394ImageProvider.h:251
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:74
CapturingImageProvider.h
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::ComponentPropertyDefinitions::ComponentPropertyDefinitions
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition: Component.cpp:37
visionx::IEEE1394ImageProvider::onStartCapture
void onStartCapture(float frameRate) override
Definition: IEEE1394ImageProvider.cpp:127
visionx::IEEE1394ImageProvider::onInitCapturingImageProvider
void onInitCapturingImageProvider() override
Definition: IEEE1394ImageProvider.cpp:45
visionx::IEEE1394ImageProvider::colorFormat
ColorFormat colorFormat
Camera color mode and resulting image time.
Definition: IEEE1394ImageProvider.h:225
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:34
visionx::IEEE1394ImageProvider::ppImages
CByteImage ** ppImages
Captured images.
Definition: IEEE1394ImageProvider.h:240
visionx::IEEE1394PropertyDefinitions
Definition: IEEE1394ImageProvider.h:75
visionx::IEEE1394ImageProvider::onExitCapturingImageProvider
void onExitCapturingImageProvider() override
Definition: IEEE1394ImageProvider.cpp:111