WebCamImageProvider.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2017, 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 ArmarX
19  * @author Mirko Waechter( mirko.waechter at kit dot edu)
20  * @date 2017
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 #pragma once
25 
27 #include <VisionX/interface/components/Calibration.h>
28 #include <opencv2/highgui/highgui.hpp>
29 
30 
31 namespace visionx
32 {
34  {
35  public:
37  {
38  defineOptionalProperty<int>("DeviceNumber", 0, "Number of the ID as it openCV expects (usually 0 if only one device exists).");
39  defineOptionalProperty<float>("FPS", 30.0f, "If not set, FPS is limited by device.");
40 
41  defineOptionalProperty<ImageDimension>("ImageResolution", ImageDimension(0, 0), "Image resolution. If not set, maximum is used.")
42  .setCaseInsensitive(true)
43  .map("320x240", ImageDimension(320, 240))
44  .map("640x480", ImageDimension(640, 480))
45  .map("800x600", ImageDimension(800, 600))
46  .map("768x576", ImageDimension(768, 576))
47  .map("1024x768", ImageDimension(1024, 768))
48  .map("1280x720", ImageDimension(1280, 960))
49  .map("1280x960", ImageDimension(1280, 960))
50  .map("1280x1024", ImageDimension(1280, 960))
51  .map("1600x1200", ImageDimension(1600, 1200))
52  .map("1920x1080", ImageDimension(1920, 1080))
53  .map("1920x1200", ImageDimension(1920, 1200))
54  .map("none", ImageDimension(0, 0));
55  }
56  };
57 
58 
60  // public MonocularCalibrationCapturingProviderInterface,
62  {
63  public:
65 
66  // ManagedIceObject interface
67  protected:
68  std::string getDefaultName() const override;
69 
70  // CapturingImageProviderInterface interface
71  public:
72  // CapturingImageProvider interface
73  protected:
74  void onInitCapturingImageProvider() override;
75  void onExitCapturingImageProvider() override;
76  bool capture(void** ppImageBuffers) override;
77  cv::VideoCapture capturer;
78  cv::Mat image;
79 
80  // CapturingImageProvider interface
81  protected:
82  void onStartCapture(float framesPerSecond) override;
83  void onStopCapture() override;
84 
85  // PropertyUser interface
86  public:
88 
89  // MonocularCalibrationCapturingProviderInterface interface
90  public:
91  MonocularCalibration getCalibration(const Ice::Current&);
92  std::vector<ImageDimension> getSupportedResolutions(cv::VideoCapture& camera);
93  std::vector<imrec::ChannelPreferences> getImageRecordingChannelPreferences(const Ice::Current&) override;
94  protected:
95  MonocularCalibration calibration;
96  };
97 
98 } // namespace visionx
99 
visionx::WebCamImageProviderPropertyDefinitions::WebCamImageProviderPropertyDefinitions
WebCamImageProviderPropertyDefinitions(std::string prefix)
Definition: WebCamImageProvider.h:36
visionx::WebCamImageProviderPropertyDefinitions
Definition: WebCamImageProvider.h:33
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::WebCamImageProvider::onExitCapturingImageProvider
void onExitCapturingImageProvider() override
This is called when the Component::onExitComponent() setup is called.
Definition: WebCamImageProvider.cpp:127
visionx::WebCamImageProvider::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: WebCamImageProvider.cpp:173
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
visionx::WebCamImageProvider::calibration
MonocularCalibration calibration
Definition: WebCamImageProvider.h:95
visionx::WebCamImageProvider::image
cv::Mat image
Definition: WebCamImageProvider.h:78
visionx::WebCamImageProvider
Definition: WebCamImageProvider.h:59
visionx::WebCamImageProvider::onStartCapture
void onStartCapture(float framesPerSecond) override
This is called when the image provider capturing has been started.
Definition: WebCamImageProvider.cpp:161
visionx::CapturingImageProvider::capture
virtual void capture()
Definition: CapturingImageProvider.cpp:106
visionx::WebCamImageProvider::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: WebCamImageProvider.cpp:42
visionx::CapturingImageProvider
The CapturingImageProvider provides a callback function to trigger the capturing of images with diffe...
Definition: CapturingImageProvider.h:52
visionx::WebCamImageProvider::getImageRecordingChannelPreferences
std::vector< imrec::ChannelPreferences > getImageRecordingChannelPreferences(const Ice::Current &) override
Definition: WebCamImageProvider.cpp:186
CapturingImageProvider.h
visionx::WebCamImageProvider::onInitCapturingImageProvider
void onInitCapturingImageProvider() override
This is called when the Component::onInitComponent() is called.
Definition: WebCamImageProvider.cpp:90
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::WebCamImageProvider::getSupportedResolutions
std::vector< ImageDimension > getSupportedResolutions(cv::VideoCapture &camera)
Definition: WebCamImageProvider.cpp:48
visionx::WebCamImageProvider::getCalibration
MonocularCalibration getCalibration(const Ice::Current &)
Definition: WebCamImageProvider.cpp:179
visionx::WebCamImageProvider::onStopCapture
void onStopCapture() override
This is called when the image provider capturing has been stopped.
Definition: WebCamImageProvider.cpp:168
visionx::WebCamImageProvider::capturer
cv::VideoCapture capturer
Definition: WebCamImageProvider.h:77
visionx::WebCamImageProvider::WebCamImageProvider
WebCamImageProvider()
Definition: WebCamImageProvider.cpp:34