NerianVisionImageProvider.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package VisionX::ArmarXObjects::NerianVisionImageProvider
17 * @author Julian Tusch <julian.tusch@student.kit.edu>
18 * @date 2025
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23
24#pragma once
25
26#include <string>
27#include <utility>
28
29#include <Eigen/Core>
30
31#include <opencv2/opencv.hpp> // IWYU pragma: keep
32
33#include <Ice/Config.h>
34#include <Ice/Current.h>
35
39
41#include <VisionX/interface/components/Calibration.h>
42#include <VisionX/interface/core/DataTypes.h>
43
44#include <visiontransfer/deviceinfo.h>
45
46namespace visionx
47{
48 /// @class NerianVisionImageProviderPropertyDefinitions
50 {
51 public:
54 {
55 // these are the available resolutions (presets) for the Karmin and Ruby cameras
57 "dimensions",
58 visionx::ImageDimension(800, 592),
59 "Needs to be set according to the selected camera preset. This property will be "
60 "used as a fallback if auto-detection fails.")
61 // ruby //
62 .map("720x512", visionx::ImageDimension(720, 512))
63 .map("1024x768", visionx::ImageDimension(1024, 768))
64 .map("1440x1054", visionx::ImageDimension(1440, 1056))
65
66 // karmin //
67 .map("640x480", visionx::ImageDimension(640, 480))
68 .map("800x592", visionx::ImageDimension(800, 592))
69 .map("1024x768", visionx::ImageDimension(1024, 768))
70 .map("1280x960", visionx::ImageDimension(1280, 960))
71 .map("1600x1200", visionx::ImageDimension(1600, 1200))
72 .map("2016x1536", visionx::ImageDimension(2016, 1536))
73
74 // others (the docs are somewhat inconsistent) //
75 .map("768x592", visionx::ImageDimension(768, 592))
76 .map("992x768", visionx::ImageDimension(992, 768))
77 .map("1440x1024", visionx::ImageDimension(1440, 1024));
78
80 "enableColorCamera",
81 true,
82 "Only applies for the Nerian Vision Ruby camera. Disabling the "
83 "color camera may increase the frame rate. If you manually configure the device, "
84 "enable/disable the color output channel accordingly.");
85
86 defineOptionalProperty<bool>("rectifyImages",
87 true,
88 "If true, the images will be undistorted using the "
89 "internal calibration (on device).");
90 };
91 };
92
93 /**
94 * @defgroup Component-NerianVisionImageProvider NerianVisionImageProvider
95 * @ingroup VisionX-Components
96 * Provides support for Nerian Vision cameras for ArmarX.
97 *
98 * @class NerianVisionImageProvider
99 * @ingroup Component-NerianVisionImageProvider
100 * @brief Brief description of class NerianVisionImageProvider.
101 */
103 virtual public visionx::ImageProvider,
104 virtual public visionx::StereoCalibrationCaptureProviderInterface
105 {
106 public:
107 /**
108 * @see armarx::ManagedIceObject::getDefaultName()
109 */
110 std::string
111 getDefaultName() const override
112 {
113 return "NerianVisionImageProvider";
114 }
115
116 void startCapture(Ice::Float framesPerSecond, const Ice::Current& c) override;
117 void stopCapture(const Ice::Current& c) override;
118
119 // StereoCalibrationInterface
120 visionx::StereoCalibration getStereoCalibration(const Ice::Current& c) override;
121 bool getImagesAreUndistorted(const Ice::Current& c) override;
122 std::string getReferenceFrame(const Ice::Current& c) override;
123
124 protected:
125 void onInitImageProvider() override;
126
127 void onConnectImageProvider() override;
128
129 void runImagePublishing();
130
131 void onDisconnectImageProvider() override;
132
133 void onExitImageProvider() override;
134
135
136 /**
137 * @see PropertyUser::createPropertyDefinitions()
138 */
140
141 static std::string
142 getNameForDeviceModel(const visiontransfer::DeviceInfo::DeviceModel& model)
143 {
144 using visiontransfer::DeviceInfo;
145 switch (model)
146 {
147 case DeviceInfo::DeviceModel::SCENESCAN:
148 return "SceneScan";
149 case DeviceInfo::DeviceModel::SCENESCAN_PRO:
150 return "SceneScan Pro";
151 case DeviceInfo::DeviceModel::SCARLET:
152 return "Scarlet";
153 case DeviceInfo::DeviceModel::RUBY:
154 return "Ruby";
155 default:
156 return "(INVALID_ENUM_VALUE)";
157 }
158 }
159
160 private:
161 visiontransfer::DeviceInfo device;
163 bool enableColorCamera;
164 bool rectifyImages;
165 };
166} // 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 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)
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
ImageProvider abstract class defines a component which provide images via ice or shared memory.
Brief description of class NerianVisionImageProvider.
bool getImagesAreUndistorted(const Ice::Current &c) override
void stopCapture(const Ice::Current &c) override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onConnectImageProvider() override
This is called when the Component::onConnectComponent() setup is called.
visionx::StereoCalibration getStereoCalibration(const Ice::Current &c) override
std::string getReferenceFrame(const Ice::Current &c) override
static std::string getNameForDeviceModel(const visiontransfer::DeviceInfo::DeviceModel &model)
void startCapture(Ice::Float framesPerSecond, const Ice::Current &c) override
void onInitImageProvider() override
This is called when the Component::onInitComponent() is called.
void onExitImageProvider() override
This is called when the Component::onExitComponent() setup is called.
std::string getDefaultName() const override
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
ArmarX headers.