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 <map>
39 #include <string>
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, visionx::ImageType imageType) :
55  {
56  }
57 
58  bool
59  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 
76  {
77  public:
79  {
80 
81  defineOptionalProperty<ImageDimension>(
82  "VideoMode", ImageDimension(640, 480), "Image resolution")
83  .setCaseInsensitive(true)
84  .map("320x240", ImageDimension(320, 240))
85  .map("640x480", ImageDimension(640, 480))
86  .map("800x600", ImageDimension(800, 600))
87  .map("768x576", ImageDimension(768, 576))
88  .map("1024x768", ImageDimension(1024, 768))
89  .map("1280x960", ImageDimension(1280, 960))
90  .map("1600x1200", ImageDimension(1600, 1200))
91  .map("none", ImageDimension(0, 0));
92 
93  defineOptionalProperty<ColorFormat>(
94  "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",
99  ColorFormat(CVideoCaptureInterface::eBayerPatternToRGB24, eBayerPattern))
100  .map("bayer-pattern-to-rgb",
101  ColorFormat(CVideoCaptureInterface::eBayerPatternToRGB24, eRgb))
102  .map("yuv411-to-rgb", ColorFormat(CVideoCaptureInterface::eYUV411ToRGB24, eRgb));
103 
104  defineOptionalProperty<BayerPatternType>(
105  "BayerPatternType", eBayerPatternRg, "Raw image color pattern")
106  .setCaseInsensitive(true)
107  .map("bayer-pattern-bg", eBayerPatternBg)
108  .map("bayer-pattern-gb", eBayerPatternGb)
109  .map("bayer-pattern-gr", eBayerPatternGr)
110  .map("bayer-pattern-rg", eBayerPatternRg);
111 
112  defineOptionalProperty<bool>("Format7Mode", false, "Use Format7 mode");
113 
114  defineOptionalProperty<float>("FrameRate", 7.5f, "Frames per second")
115  .setMatchRegex("\\d+(.\\d*)?")
116  .setMin(0.0f)
117  .setMax(60.0f);
118 
119  // Camera UIDs
120  defineRequiredProperty<std::string>("CameraUIDs",
121  "Camera UIDs seperated by comma, space or tab")
122  .setCaseInsensitive(true)
123  .setMatchRegex("\\s*[a-zA-Z0-9]{16}\\s*((,|\\s)\\s*[a-zA-Z0-9]{16})*");
124 
125  defineOptionalProperty<std::string>(
126  "ReferenceFrameName", "EyeLeftCameras", "Optional reference frame name.");
127  }
128  };
129 
130  /**
131  * IEEE1394 image provider captures images from one or more cameras and
132  * supports the following image transmission formats:
133  *
134  * - RGB
135  * - Gray Scale
136  * - Bayer Pattern (Bg, Gb, Gr, Rg)
137  *
138  * \componentproperties
139  * \prop VisionX.IEEE1394ImageProvider.CameraUIDs: Comma or space separated
140  * list of camera UIDs. If not set all cameras will be opened.
141  * \prop VisionX.IEEE1394ImageProvider.VideoMode: Defines the camera
142  * resolution.
143  * - 320x240
144  * - 640x480 (default)
145  * - 800x600
146  * - 768x576
147  * - 1024x768
148  * - 1280x960
149  * - 1600x1200
150  * - none
151  * \prop VisionX.IEEE1394ImageProvider.ColorMode: Specifies how image format
152  * of camera is interpreted and converted. Cameras may support only
153  * one color mode. Possible values:
154  * - gray-scale
155  * - rgb
156  * - bayer-pattern
157  * - bayer-pattern-to-rgb (default)
158  * - yuv411-to-rgb
159  * \prop VisionX.IEEE1394ImageProvider.BayerPatternType: Specifies the bayer
160  * pattern type. Required only if ColorMode uses a bayer pattern
161  * format.
162  * Possible values:
163  * - bayer-pattern-bg
164  * - bayer-pattern-gb
165  * - bayer-pattern-gr
166  * - bayer-pattern.rg (default)
167  * \prop VisionX.IEEE1394ImageProvider.FrameRate: Capture frame rate as
168  * float (default: 30fps)
169  * \prop VisionX.IEEE1394ImageProvider.Format7Mode: Enable or disable
170  * IEEE1394 format 7 mode (possible values: true, false (default)).
171  */
173  {
174  public:
175  /**
176  * @see visionx::ImageProviderBase::onInitImageProvider()
177  */
178  void onInitCapturingImageProvider() override;
179 
180  /**
181  * @see visionx::ImageProviderBase::onExitImageProvider()
182  */
183  void onExitCapturingImageProvider() override;
184 
185  /**
186  * @see visionx::ImageProviderBase::onStartCapture()
187  */
188  void onStartCapture(float frameRate) override;
189 
190  /**
191  * @see visionx::ImageProviderBase::onStopCapture()
192  */
193  void onStopCapture() override;
194 
195  /**
196  * @see visionx::ImageProviderBase::capture()
197  */
198  bool capture(void** ppImageBuffers) override;
199 
200  /**
201  * @see armarx::Component::getDefaultName()
202  */
203  std::string
204  getDefaultName() const override
205  {
206  return "IEEE1394ImageProvider";
207  }
208 
209  /**
210  * @see PropertyUser::createPropertyDefinitions()
211  */
214  {
217  }
218 
219 
220  protected:
221  /**
222  * Camera UID list
223  */
224  std::vector<std::string> uids;
225 
226  /**
227  * Camera color mode and resulting image time
228  */
230 
231  /**
232  * Video dimension data
233  */
234  visionx::ImageDimension videoDimension;
235 
236  /**
237  * Specific bayer pattern type, if ColorMode is BayerPattern
238  */
239  visionx::BayerPatternType bayerPatternType;
240 
241  /**
242  * Captured images
243  */
244  CByteImage** ppImages;
245 
246  /**
247  * Indicate whether using format 7 modes or not
248  */
250 
251  /**
252  * IEEE1394 Capture
253  */
254  //CLinux1394Capture2* ieee1394Capturer;
255  CLinux1394CaptureThreaded2* ieee1394Capturer;
256  };
257 } // namespace visionx
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:172
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::CapturingImageProvider::frameRate
float frameRate
Required frame rate.
Definition: CapturingImageProvider.h:201
visionx::IEEE1394ImageProvider::isFormat7Mode
bool isFormat7Mode
Indicate whether using format 7 modes or not.
Definition: IEEE1394ImageProvider.h:249
visionx::IEEE1394ImageProvider::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: IEEE1394ImageProvider.h:213
visionx::IEEE1394ImageProvider::uids
std::vector< std::string > uids
Camera UID list.
Definition: IEEE1394ImageProvider.h:224
visionx::IEEE1394PropertyDefinitions::IEEE1394PropertyDefinitions
IEEE1394PropertyDefinitions(std::string prefix)
Definition: IEEE1394ImageProvider.h:78
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
visionx::IEEE1394ImageProvider::onStopCapture
void onStopCapture() override
Definition: IEEE1394ImageProvider.cpp:161
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:239
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:234
visionx::IEEE1394ImageProvider::getDefaultName
std::string getDefaultName() const override
Definition: IEEE1394ImageProvider.h:204
visionx::CapturingImageProvider::capture
virtual void capture()
Definition: CapturingImageProvider.cpp:109
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:255
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:79
CapturingImageProvider.h
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:69
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::ComponentPropertyDefinitions::ComponentPropertyDefinitions
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition: Component.cpp:35
visionx::IEEE1394ImageProvider::onStartCapture
void onStartCapture(float frameRate) override
Definition: IEEE1394ImageProvider.cpp:133
visionx::IEEE1394ImageProvider::onInitCapturingImageProvider
void onInitCapturingImageProvider() override
Definition: IEEE1394ImageProvider.cpp:47
visionx::IEEE1394ImageProvider::colorFormat
ColorFormat colorFormat
Camera color mode and resulting image time.
Definition: IEEE1394ImageProvider.h:229
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:35
visionx::IEEE1394ImageProvider::ppImages
CByteImage ** ppImages
Captured images.
Definition: IEEE1394ImageProvider.h:244
visionx::IEEE1394PropertyDefinitions
Definition: IEEE1394ImageProvider.h:75
visionx::IEEE1394ImageProvider::onExitCapturingImageProvider
void onExitCapturingImageProvider() override
Definition: IEEE1394ImageProvider.cpp:117