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 
26 #include <opencv2/highgui/highgui.hpp>
27 
29 #include <VisionX/interface/components/Calibration.h>
30 
31 namespace visionx
32 {
34  {
35  public:
38  {
39  defineOptionalProperty<int>(
40  "DeviceNumber",
41  0,
42  "Number of the ID as it openCV expects (usually 0 if only one device exists).");
43  defineOptionalProperty<float>("FPS", 30.0f, "If not set, FPS is limited by device.");
44 
45  defineOptionalProperty<ImageDimension>("ImageResolution",
46  ImageDimension(0, 0),
47  "Image resolution. If not set, maximum is used.")
48  .setCaseInsensitive(true)
49  .map("320x240", ImageDimension(320, 240))
50  .map("640x480", ImageDimension(640, 480))
51  .map("800x600", ImageDimension(800, 600))
52  .map("768x576", ImageDimension(768, 576))
53  .map("1024x768", ImageDimension(1024, 768))
54  .map("1280x720", ImageDimension(1280, 960))
55  .map("1280x960", ImageDimension(1280, 960))
56  .map("1280x1024", ImageDimension(1280, 960))
57  .map("1600x1200", ImageDimension(1600, 1200))
58  .map("1920x1080", ImageDimension(1920, 1080))
59  .map("1920x1200", ImageDimension(1920, 1200))
60  .map("none", ImageDimension(0, 0));
61  }
62  };
63 
65  // public MonocularCalibrationCapturingProviderInterface,
67  {
68  public:
70 
71  // ManagedIceObject interface
72  protected:
73  std::string getDefaultName() const override;
74 
75  // CapturingImageProviderInterface interface
76  public:
77  // CapturingImageProvider interface
78  protected:
79  void onInitCapturingImageProvider() override;
80  void onExitCapturingImageProvider() override;
81  bool capture(void** ppImageBuffers) override;
82  cv::VideoCapture capturer;
83  cv::Mat image;
84 
85  // CapturingImageProvider interface
86  protected:
87  void onStartCapture(float framesPerSecond) override;
88  void onStopCapture() override;
89 
90  // PropertyUser interface
91  public:
93 
94  // MonocularCalibrationCapturingProviderInterface interface
95  public:
96  MonocularCalibration getCalibration(const Ice::Current&);
97  std::vector<ImageDimension> getSupportedResolutions(cv::VideoCapture& camera);
98  std::vector<imrec::ChannelPreferences>
99  getImageRecordingChannelPreferences(const Ice::Current&) override;
100 
101  protected:
102  MonocularCalibration calibration;
103  };
104 
105 } // namespace visionx
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:132
visionx::WebCamImageProvider::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: WebCamImageProvider.cpp:176
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
visionx::WebCamImageProvider::calibration
MonocularCalibration calibration
Definition: WebCamImageProvider.h:102
visionx::WebCamImageProvider::image
cv::Mat image
Definition: WebCamImageProvider.h:83
visionx::WebCamImageProvider
Definition: WebCamImageProvider.h:64
visionx::WebCamImageProvider::onStartCapture
void onStartCapture(float framesPerSecond) override
This is called when the image provider capturing has been started.
Definition: WebCamImageProvider.cpp:164
visionx::CapturingImageProvider::capture
virtual void capture()
Definition: CapturingImageProvider.cpp:109
visionx::WebCamImageProvider::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: WebCamImageProvider.cpp:43
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:189
CapturingImageProvider.h
visionx::WebCamImageProvider::onInitCapturingImageProvider
void onInitCapturingImageProvider() override
This is called when the Component::onInitComponent() is called.
Definition: WebCamImageProvider.cpp:88
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::WebCamImageProvider::getSupportedResolutions
std::vector< ImageDimension > getSupportedResolutions(cv::VideoCapture &camera)
Definition: WebCamImageProvider.cpp:49
visionx::WebCamImageProvider::getCalibration
MonocularCalibration getCalibration(const Ice::Current &)
Definition: WebCamImageProvider.cpp:183
visionx::WebCamImageProvider::onStopCapture
void onStopCapture() override
This is called when the image provider capturing has been stopped.
Definition: WebCamImageProvider.cpp:171
visionx::WebCamImageProvider::capturer
cv::VideoCapture capturer
Definition: WebCamImageProvider.h:82
visionx::WebCamImageProvider::WebCamImageProvider
WebCamImageProvider()
Definition: WebCamImageProvider.cpp:38