ImageSequenceProvider.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
28#include <VisionX/interface/components/Calibration.h>
29
30
31// IVT
32#include <mutex>
33#include <string>
34
35#include <Calibration/StereoCalibration.h>
36#include <Image/ByteImage.h>
37#include <VideoCapture/BitmapSequenceCapture.h>
38
39namespace visionx
40{
42 {
43 public:
46 {
48 "PathLeft",
49 "Filename and path of the left camera images. Enter the path of the first image of "
50 "the sequence. Filenames need to follow the format: path/*%d.bmp (e.g. "
51 "path/image_left0000.bmp).");
53 "PathRight",
54 "",
55 "Filename and path of the right camera images. Enter the path of the first image "
56 "of the sequence. Filenames need to follow the format: path/*%d.bmp (e.g. "
57 "path/image_right0000.bmp).");
58 defineOptionalProperty<float>("FrameRate", 30.0f, "Frames per second")
59 .setMatchRegex("\\d+(.\\d*)?")
60 .setMin(0.0f)
61 .setMax(60.0f);
63 "ImageSize",
64 ImageDimension(640, 480),
65 "Target resolution of the images. Loaded images will be converted to this size.")
66 .setCaseInsensitive(true)
67 .map("320x240", ImageDimension(320, 240))
68 .map("640x480", ImageDimension(640, 480))
69 .map("648x482", ImageDimension(648, 482))
70 .map("800x600", ImageDimension(800, 600))
71 .map("768x576", ImageDimension(768, 576))
72 .map("1024x768", ImageDimension(1024, 768))
73 .map("1024x1024", ImageDimension(1024, 1024))
74 .map("1280x960", ImageDimension(1280, 960))
75 .map("1600x1200", ImageDimension(1600, 1200))
76 .map("none", ImageDimension(0, 0));
77
79 "CalibrationFile",
80 "",
81 "Camera calibration file, will be made available in the SLICE interface");
83 "ImagesAreUndistorted", false, "Sets whether images are provided undistorted.");
85 "LoadNextImageAutomatically",
86 true,
87 "If true, a new image is loaded everytime the 'capture()' function is executed. If "
88 "false, the same image is provided until 'loadNextImage()' is called from "
89 "somewhere");
91 "RepeatImageCount", 1, "Repeats the images for the specified amount of time.");
92
94 "ReferenceFrameName", "EyeLeftCamera", "Optional reference frame name.");
95 }
96 };
97
98 /**
99 * Image sequence provider loads images from a device and broadcasts
100 * notifications after loading at a specified frame rate.
101 *
102 * It supports the following image transmission formats:
103 *
104 * - RGB
105 * - Gray Scale
106 *
107 * \componentproperties
108 * \prop VisionX.ImageSequenceProvider.PathLeft: Image directory of the left
109 * (base) camera.
110 * \prop VisionX.ImageSequenceProvider.PathRight: Image directory of the
111 * right camera. Leave this empty if stereo is not required.
112 */
114 virtual public CapturingImageProvider,
115 virtual public ImageFileSequenceProviderInterface
116 {
117 public:
118 static std::string GetDefaultName();
119 std::string getDefaultName() const override;
120
121 /**
122 * Returns the StereoCalibration as provided in configuration
123 *
124 * @return visionx::StereoCalibration
125 */
126 visionx::StereoCalibration
127 getStereoCalibration(const Ice::Current& c = Ice::emptyCurrent) override;
128
129 /**
130 * Returns whether images are undistorted
131 *
132 * @return bool
133 */
134 bool getImagesAreUndistorted(const Ice::Current& c = Ice::emptyCurrent) override;
135
136 std::string
137 getReferenceFrame(const Ice::Current& c = Ice::emptyCurrent) override
138 {
139 return getProperty<std::string>("ReferenceFrameName").getValue();
140 }
141
142 /**
143 * Set the paths for the image files. If there are no stereo images, leave the right path empty
144 *
145 */
146 void setImageFilePath(const std::string& imageFilePathLeft,
147 const std::string& imageFilePathRight = "",
148 const Ice::Current& c = Ice::emptyCurrent) override;
149
150 void loadNextImage(const Ice::Current& c = Ice::emptyCurrent) override;
151
152
153 protected:
154 /**
155 * @see visionx::CapturingImageProvider::onInitCapturingImageProvider()
156 */
157 void onInitCapturingImageProvider() override;
158
159 /**
160 * @see visionx::CapturingImageProvider::onExitCapturingImageProvider()
161 */
162 void onExitCapturingImageProvider() override;
163
164 /**
165 * @see visionx::CapturingImageProvider::onStartCapture(float frameRate)
166 */
167 void onStartCapture(float frameRate) override;
168
169 /**
170 * @see visionx::CapturingImageProvider::onStopCapture()
171 */
172 void onStopCapture() override;
173
174 bool capture(void** ppImageBuffers) override;
175
176
177 void OpenImageFiles();
178
179 /**
180 * @see PropertyUser::createPropertyDefinitions()
181 */
188
189 CByteImage** images;
190 CByteImage** resizedImages;
191 CBitmapSequenceCapture* bitmapSequenceCapture;
192 std::string filePathLeft;
193 std::string filePathRight;
194 std::mutex captureMutex;
196
197 private:
198 /**
199 * IVT Stereo Calibration object
200 */
201 CStereoCalibration ivtStereoCalibration;
202
203 /**
204 * VisionX StereoCalibration object
205 */
206 StereoCalibration stereoCalibration;
207
208 int currentRepeatCount = 0;
209 int repeatImageCount;
210 };
211
212} // namespace visionx
constexpr T c
Default component property definition container.
Definition Component.h:70
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
Property< PropertyType > getProperty(const std::string &name)
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
PropertyDefinition< PropertyType > & defineRequiredProperty(const std::string &name, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
The CapturingImageProvider provides a callback function to trigger the capturing of images with diffe...
Image sequence provider loads images from a device and broadcasts notifications after loading at a sp...
std::string getReferenceFrame(const Ice::Current &c=Ice::emptyCurrent) override
void loadNextImage(const Ice::Current &c=Ice::emptyCurrent) override
CBitmapSequenceCapture * bitmapSequenceCapture
void setImageFilePath(const std::string &imageFilePathLeft, const std::string &imageFilePathRight="", const Ice::Current &c=Ice::emptyCurrent) override
Set the paths for the image files.
void onStartCapture(float frameRate) override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
bool getImagesAreUndistorted(const Ice::Current &c=Ice::emptyCurrent) override
Returns whether images are undistorted.
visionx::StereoCalibration getStereoCalibration(const Ice::Current &c=Ice::emptyCurrent) override
Returns the StereoCalibration as provided in configuration.
std::string getDefaultName() const override
Retrieve default name of component.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
ArmarX headers.