Go to the documentation of this file.
26 #include <pcl/common/transforms.h>
27 #include <pcl/point_types.h>
34 #include <VisionX/interface/components/Calibration.h>
37 static constexpr
auto InMaskSuff =
"_in_mask";
38 static constexpr
auto OutOfMaskSuff =
"_out_of_mask";
39 static constexpr
auto OutOfMaskImgSuff =
"_out_of_image";
40 static constexpr
auto MaskVisuSuff =
"_mask_visu";
41 static constexpr
auto MaskAsCloudSuff =
"_mask_as_cloud";
43 #define call_template_function(F) \
44 switch (_pointCloudProviderInfo.pointCloudFormat->type) \
47 case visionx::PointContentType::eColoredPoints: \
48 F<pcl::PointXYZRGBA>(); \
50 case visionx::PointContentType::eColoredOrientedPoints: \
51 F<pcl::PointXYZRGBNormal>(); \
54 case visionx::PointContentType::eColoredLabeledPoints: \
55 F<pcl::PointXYZRGBL>(); \
58 case visionx::PointContentType::eOrientedPoints: \
59 ARMARX_ERROR << "eOrientedPoints NOT HANDLED IN VISIONX"; \
62 ARMARX_ERROR << "Could not process point cloud, because format '" \
63 << _pointCloudProviderInfo.pointCloudFormat->type << "' is unknown"; \
93 _redHi =
static_cast<std::uint8_t
>(getProperty<int>(
"MaskRedHi"));
94 _redLo =
static_cast<std::uint8_t
>(getProperty<int>(
"MaskRedLo"));
95 _greenHi =
static_cast<std::uint8_t
>(getProperty<int>(
"MaskGreenHi"));
96 _greenLo =
static_cast<std::uint8_t
>(getProperty<int>(
"MaskGreenLo"));
97 _blueHi =
static_cast<std::uint8_t
>(getProperty<int>(
"MaskBlueHi"));
98 _blueLo =
static_cast<std::uint8_t
>(getProperty<int>(
"MaskBlueLo"));
110 VirtualRobot::RobotIO::eStructure);
118 enableResultPointClouds<pcl::PointXYZRGBA>(
getName() + InMaskSuff);
119 enableResultPointClouds<pcl::PointXYZRGBA>(
getName() + OutOfMaskSuff);
120 enableResultPointClouds<pcl::PointXYZRGBA>(
getName() + OutOfMaskImgSuff);
121 enableResultPointClouds<pcl::PointXYZRGBA>(
getName() + MaskVisuSuff);
122 enableResultPointClouds<pcl::PointXYZRGBA>(
getName() + MaskAsCloudSuff);
127 getProperty<std::string>(
"PointCloudProviderReferenceFrameOverride");
170 getProperty<std::string>(
"MaskImageProviderReferenceFrameOverride");
184 const std::string calibProviderName = getProperty<std::string>(
"CalibrationProviderName");
185 if (calibProviderName.empty())
188 visionx::MonocularCalibrationCapturingProviderInterfacePrx::checkedCast(
196 scalibprov->getStereoCalibration().calibrationLeft.cameraParam.focalLength.at(
199 scalibprov->getStereoCalibration().calibrationLeft.cameraParam.focalLength.at(
205 mcalibprov->getCalibration().cameraParam.focalLength.at(0);
207 mcalibprov->getCalibration().cameraParam.focalLength.at(1);
212 auto calibProvider = getProxy<Ice::ObjectPrx>(calibProviderName);
214 visionx::MonocularCalibrationCapturingProviderInterfacePrx::checkedCast(
216 auto scalibprov = visionx::StereoCalibrationInterfacePrx::checkedCast(calibProvider);
221 scalibprov->getStereoCalibration().calibrationLeft.cameraParam.focalLength.at(
224 scalibprov->getStereoCalibration().calibrationLeft.cameraParam.focalLength.at(
230 mcalibprov->getCalibration().cameraParam.focalLength.at(0);
232 mcalibprov->getCalibration().cameraParam.focalLength.at(1);
241 auto makeSlider = [&](std::string name,
int val,
int min = 0,
int max = 255)
250 auto makeFSlider = [&](std::string name,
int min,
int max,
float val)
256 static_cast<int>(
max -
min)))
262 makeSlider(
"red lo",
_redLo);
263 makeSlider(
"red hi",
_redHi);
266 makeSlider(
"blue lo",
_blueLo);
267 makeSlider(
"blue hi",
_blueHi);
289 const int focaladjrange = 10000;
304 checkboxBuilder.widget().label =
"Sync using timestamp";
305 rootLayoutBuilder.
addChild(checkboxBuilder);
306 rootLayoutBuilder.
addChild(
new RemoteGui::VSpacer());
370 std::pair<float, float>
381 const float s = std::sin(alpha);
382 const float c = std::cos(alpha);
388 const float ushifted = u - +width / 2.f +
_offsetX;
389 const float vshifted =
v - +height / 2.f +
_offsetY;
391 const float rotatedU =
c * ushifted +
s * vshifted;
392 const float rotatedV = -
s * ushifted +
c * vshifted;
394 const float x = (
_flipX ? 1 : -1) * rotatedU;
395 const float y = (
_flipY ? 1 : -1) * rotatedV;
400 std::array<std::int64_t, 2>
404 const float s = std::sin(alpha);
405 const float c = std::cos(alpha);
408 const float u = (
_flipX ? 1 : -1) * (x / z) * fx;
409 const float v = (
_flipY ? 1 : -1) * (y / z) * fy;
411 const float rotatedU =
c * u + -
s *
v;
412 const float rotatedV =
s * u +
c *
v;
418 const std::int64_t imgx =
static_cast<std::int64_t
>(rotatedU + width / 2.f) -
_offsetX;
419 const std::int64_t imgy =
static_cast<std::int64_t
>(rotatedV + height / 2.f) -
_offsetY;
431 template <
typename Po
intType>
457 typename pcl::PointCloud<PointType>::Ptr inputCloud(
new pcl::PointCloud<PointType>());
488 camInReportFrame = fp.toEigen();
494 pclInCamFrame = fp.toEigen();
499 typename pcl::PointCloud<PointType>::Ptr tmpCloud(
new pcl::PointCloud<PointType>());
500 pcl::transformPointCloud(*inputCloud, *tmpCloud, pclInCamFrame);
501 tmpCloud.swap(inputCloud);
508 std::uint64_t pointsInImage = 0;
509 std::uint64_t pointsOutOfImage = 0;
510 _maskedCloud.reset(
new pcl::PointCloud<pcl::PointXYZRGBA>());
511 _inputCloud.reset(
new pcl::PointCloud<pcl::PointXYZRGBA>());
512 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr unmaskedCloud(
new pcl::PointCloud<pcl::PointXYZRGBA>());
513 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr outOfImageCloud(
514 new pcl::PointCloud<pcl::PointXYZRGBA>());
515 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr visuCloud(
new pcl::PointCloud<pcl::PointXYZRGBA>());
519 for (
const auto& point : inputCloud->points)
547 const auto uv =
xyz2uv(p.x, p.y, p.z, fx, fy);
548 const std::int64_t u = uv.at(0);
549 const std::int64_t
v = uv.at(1);
550 if (u < 0 || u >= img.width || v < 0 || v >= img.height)
554 p.r = p.b = p.a = 255;
556 outOfImageCloud->push_back(p);
561 p.r = img.pixels[(u +
v * img.width) * 3 + 0];
562 p.g = img.pixels[(u +
v * img.width) * 3 + 1];
563 p.b = img.pixels[(u +
v * img.width) * 3 + 2];
567 const bool okR = r.first <= p.r && r.second >= p.r;
568 const bool okG = g.first <= p.g && g.second >= p.g;
569 const bool okB = b.first <= p.b && b.second >= p.b;
577 unmaskedCloud->push_back(p);
579 visuCloud->push_back(p);
583 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr tmpCloud(
new pcl::PointCloud<pcl::PointXYZRGBA>());
585 pcl::transformPointCloud(*
_maskedCloud, *tmpCloud, camInReportFrame);
588 pcl::transformPointCloud(*unmaskedCloud, *tmpCloud, camInReportFrame);
591 pcl::transformPointCloud(*outOfImageCloud, *tmpCloud, camInReportFrame);
594 pcl::transformPointCloud(*visuCloud, *tmpCloud, camInReportFrame);
599 for (
int u = 0; u < img.width; ++u)
601 for (
int v = 0;
v < img.height; ++
v)
604 auto xyz =
uvz2xyz(u,
v, (fx + fy) / 2, fx, fy);
610 p.r = img.pixels[(u +
v * img.width) * 3 + 0];
611 p.g = img.pixels[(u +
v * img.width) * 3 + 1];
612 p.b = img.pixels[(u +
v * img.width) * 3 + 2];
613 visuCloud->push_back(p);
616 pcl::transformPointCloud(*visuCloud, *tmpCloud, camInReportFrame);
visionx::ImageProviderInterfacePrx _maskImageProvider
RemoteGui::TabProxy _guiTab
std::atomic< std::uint8_t > _redLo
detail::IntSliderBuilder makeIntSlider(std::string const &name)
detail::VBoxLayoutBuilder makeVBoxLayout(std::string const &name="")
std::pair< float, float > maskImageProviderFocalLength() const
detail::HBoxLayoutBuilder makeHBoxLayout(std::string const &name="")
std::atomic_bool _maskMatchOneRangeInsteadOfAll
MetaPointCloudFormatPtr getPointCloudFormat(std::string providerName)
int numberImages
Number of images.
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr _inputCloud
void onInitPointCloudAndImageProcessor() override
Setup the vision component.
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr _maskedCloud
std::atomic< std::uint8_t > _redHi
VirtualRobot::RobotPtr _localRobot
std::string _maskImageProviderName
static bool synchronizeLocalClone(VirtualRobot::RobotPtr robot, RobotStateComponentInterfacePrx robotStatePrx)
std::string _pointCloudReportFrame
float _maskImageProviderFocalLengthY
static VirtualRobot::RobotPtr createLocalCloneFromFile(RobotStateComponentInterfacePrx robotStatePrx, VirtualRobot::RobotIO::RobotDescription loadMode=VirtualRobot::RobotIO::eFull)
This is a convenience function for createLocalClone, which automatically gets the filename from the R...
MatrixXX< 4, 4, float > Matrix4f
float _maskImageProviderFocalLengthX
std::atomic< float > _focalLengthAdjustment
std::atomic< std::int64_t > _offsetY
std::string _robotStateComponentName
PointCloudProviderInterfacePrx proxy
Proxy to PointCloud provider.
ImageProviderInfo getImageProvider(std::string name, ImageType destinationImageType=eRgb, bool waitForProxy=false)
Select an ImageProvider.
SimplePeriodicTask ::pointer_type _guiTask
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
std::atomic< std::uint8_t > _blueLo
std::string _pointCloudProviderRefFrame
std::atomic_bool _syncRobotWithTimestamp
detail::LabelBuilder makeTextLabel(std::string const &text)
std::atomic< std::uint8_t > _greenHi
ImageFormatInfo imageFormat
Image format struct that contains all necessary image information.
std::string _remoteGuiName
std::atomic< std::int64_t > _guiParamUpdated
DebugDrawerInterfacePrx _debugDrawerTopic
std::string _maskImageProviderRefFrame
ComboBoxBuilder & addOptions(std::vector< std::string > const &options)
void Identity(MatrixXX< N, N, T > *a)
std::shared_ptr< Value > value()
detail::IntSpinBoxBuilder makeIntSpinBox(std::string const &name)
void provideResultPointClouds(const PointCloudPtrT &pointClouds, std::string providerName="")
sends result PointClouds for visualization
Derived & addChild(WidgetPtr const &child)
detail::CheckBoxBuilder makeCheckBox(std::string const &name)
detail::FloatSliderBuilder makeFloatSlider(std::string const &name)
bool waitForPointClouds(int milliseconds=1000)
Wait for new PointClouds.
std::atomic< std::int64_t > _offsetX
void usingImageProvider(std::string name)
Registers a delayed topic subscription and a delayed provider proxy retrieval which all will be avail...
Derived & value(ValueT const &value)
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
int getImages(CByteImage **ppImages)
Poll images from provider.
int getPointClouds(const PointCloudPtrT &pointCloudPtr)
Poll PointClouds from provider.
#define ARMARX_CHECK_GREATER_EQUAL(lhs, rhs)
This macro evaluates whether lhs is greater or equal (>=) rhs and if it turns out to be false it will...
visionx::PointCloudProviderInfo _pointCloudProviderInfo
ValueProxy< T > getValue(std::string const &name)
RobotStateComponentInterfacePrx _robotStateComponent
std::vector< void * > _maskImageProviderImages
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
double v(double t, double v0, double a0, double j)
RemoteGuiInterfacePrx _remoteGui
ImageProviderInterfacePrx proxy
proxy to image provider
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
visionx::PointCloudProviderInterfacePrx _pointCloudProvider
std::array< std::int64_t, 2 > xyz2uv(float x, float y, float z, float fx, float fy) const
void offeringTopic(const std::string &name)
Registers a topic for retrival after initialization.
set(LIBS ArmarXCoreInterfaces ${CMAKE_THREAD_LIBS_INIT} ${dl_LIBRARIES} ${rt_LIBRARIES} ${QT_LIBRARIES} ${Boost_LIBRARIES} BoostAssertionHandler ArmarXCPPUtility SimoxUtility) set(LIB_FILES ArmarXManager.cpp ArmarXMultipleObjectsScheduler.cpp ArmarXObjectScheduler.cpp ManagedIceObject.cpp ManagedIceObjectPlugin.cpp Component.cpp ComponentPlugin.cpp IceGridAdmin.cpp ArmarXObjectObserver.cpp IceManager.cpp PackagePath.cpp RemoteReferenceCount.cpp logging/LoggingUtil.cpp logging/Logging.cpp logging/LogSender.cpp logging/ArmarXLogBuf.cpp system/ArmarXDataPath.cpp system/DynamicLibrary.cpp system/ProcessWatcher.cpp system/FactoryCollectionBase.cpp system/cmake/CMakePackageFinder.cpp system/cmake/CMakePackageFinderCache.cpp system/cmake/ArmarXPackageToolInterface.cpp system/RemoteObjectNode.cpp services/sharedmemory/HardwareId.cpp services/tasks/RunningTask.cpp services/tasks/ThreadList.cpp services/tasks/ThreadPool.cpp services/profiler/Profiler.cpp services/profiler/FileLoggingStrategy.cpp services/profiler/IceLoggingStrategy.cpp application/Application.cpp application/ApplicationOptions.cpp application/ApplicationProcessFacet.cpp application/ApplicationNetworkStats.cpp application/properties/PropertyUser.cpp application/properties/Property.cpp application/properties/PropertyDefinition.cpp application/properties/PropertyDefinitionContainer.cpp application/properties/PropertyDefinitionHelpFormatter.cpp application/properties/PropertyDefinitionConfigFormatter.cpp application/properties/PropertyDefinitionBriefHelpFormatter.cpp application/properties/PropertyDefinitionXmlFormatter.cpp application/properties/PropertyDefinitionDoxygenFormatter.cpp application/properties/PropertyDefinitionDoxygenComponentPagesFormatter.cpp application/properties/PropertyDefinitionContainerBriefHelpFormatter.cpp application/properties/IceProperties.cpp exceptions/Exception.cpp exceptions/local/UnexpectedEnumValueException.cpp util/FileSystemPathBuilder.cpp util/StringHelpers.cpp util/IceReportSkipper.cpp util/Throttler.cpp util/distributed/AMDCallbackCollection.cpp util/distributed/RemoteHandle/ClientSideRemoteHandleControlBlock.cpp util/distributed/RemoteHandle/RemoteHandle.cpp util/distributed/RemoteHandle/RemoteHandleControlBlock.cpp time/ice_conversions.cpp time/json_conversions.cpp time/CallbackWaitLock.cpp time/Clock.cpp time/ClockType.cpp time/ClockTypeNames.cpp time/CycleUtil.cpp time/DateTime.cpp time/Duration.cpp time/Frequency.cpp time/LocalTimeServer.cpp time/Metronome.cpp time/ScopedStopWatch.cpp time/StopWatch.cpp time/Timer.cpp time/TimeKeeper.cpp time/TimeUtil.cpp csv/CsvWriter.cpp csv/CsvReader.cpp eigen/conversions.cpp eigen/ice_conversions.cpp) set(LIB_HEADERS ArmarXManager.h ArmarXDummyManager.h ArmarXMultipleObjectsScheduler.h ArmarXObjectObserver.h ArmarXObjectScheduler.h ArmarXFwd.h Component.h ComponentPlugin.h ComponentFactories.h CoreObjectFactories.h IceGridAdmin.h IceManager.h IceManagerImpl.h json_conversions.h ManagedIceObject.h ManagedIceObjectPlugin.h ManagedIceObjectImpl.h ManagedIceObjectDependency.h ManagedIceObjectRegistryInterface.h PackagePath.h RemoteReferenceCount.h system/ImportExport.h system/ImportExportComponent.h system/AbstractFactoryMethod.h system/FactoryCollectionBase.h system/Synchronization.h system/ArmarXDataPath.h system/DynamicLibrary.h system/ProcessWatcher.h system/ConditionSynchronization.h system/cmake/CMakePackageFinder.h system/cmake/CMakePackageFinderCache.h system/cmake/FindPackageX.cmake system/cmake/ArmarXPackageToolInterface.h system/RemoteObjectNode.h logging/LoggingUtil.h logging/LogSender.h logging/Logging.h logging/ArmarXLogBuf.h logging/SpamFilterData.h services/tasks/RunningTask.h services/tasks/PeriodicTask.h services/tasks/ThreadList.h services/tasks/TaskUtil.h services/tasks/ThreadPool.h services/sharedmemory/SharedMemoryProvider.h services/sharedmemory/SharedMemoryConsumer.h services/sharedmemory/IceSharedMemoryProvider.h services/sharedmemory/IceSharedMemoryConsumer.h services/sharedmemory/HardwareIdentifierProvider.h services/sharedmemory/HardwareId.h services/sharedmemory/exceptions/SharedMemoryExceptions.h services/profiler/Profiler.h services/profiler/LoggingStrategy.h services/profiler/FileLoggingStrategy.h services/profiler/IceLoggingStrategy.h application/Application.h application/ApplicationOptions.h application/ApplicationProcessFacet.h application/ApplicationNetworkStats.h application/properties/forward_declarations.h application/properties/Properties.h application/properties/Property.h application/properties/PluginEigen.h application/properties/PluginEnumNames.h application/properties/PluginCfgStruct.h application/properties/PluginAll.h application/properties/PropertyUser.h application/properties/PropertyDefinition.h application/properties/PropertyDefinition.hpp application/properties/PropertyDefinitionInterface.h application/properties/PropertyDefinitionContainer.h application/properties/PropertyDefinitionFormatter.h application/properties/PropertyDefinitionContainerFormatter.h application/properties/PropertyDefinitionConfigFormatter.h application/properties/PropertyDefinitionHelpFormatter.h application/properties/PropertyDefinitionBriefHelpFormatter.h application/properties/PropertyDefinitionXmlFormatter.h application/properties/PropertyDefinitionDoxygenFormatter.h application/properties/PropertyDefinitionDoxygenComponentPagesFormatter.h application/properties/PropertyDefinitionContainerBriefHelpFormatter.h application/properties/ProxyPropertyDefinition.h application/properties/IceProperties.h exceptions/Exception.h exceptions/LocalException.h exceptions/local/DynamicLibraryException.h exceptions/local/ExpressionException.h exceptions/local/FileIOException.h exceptions/local/InvalidPropertyValueException.h exceptions/local/MissingRequiredPropertyException.h exceptions/local/PropertyInheritanceCycleException.h exceptions/local/ProxyNotInitializedException.h exceptions/local/UnexpectedEnumValueException.h exceptions/local/UnmappedValueException.h exceptions/local/ValueRangeExceededException.h exceptions/user/NotImplementedYetException.h rapidxml/rapidxml.hpp rapidxml/rapidxml_print.hpp rapidxml/rapidxml_iterators.hpp rapidxml/rapidxml_utils.hpp rapidxml/wrapper/RapidXmlReader.h rapidxml/wrapper/RapidXmlWriter.h rapidxml/wrapper/DefaultRapidXmlReader.h rapidxml/wrapper/MultiNodeRapidXMLReader.h util/IceBlobToObject.h util/ObjectToIceBlob.h util/FileSystemPathBuilder.h util/FiniteStateMachine.h util/StringHelpers.h util/StringHelperTemplates.h util/algorithm.h util/OnScopeExit.h util/Predicates.h util/Preprocessor.h util/PropagateConst.h util/Registrar.h util/TemplateMetaProgramming.h util/TripleBuffer.h util/IceReportSkipper.h util/Throttler.h util/distributed/AMDCallbackCollection.h util/distributed/RemoteHandle/ClientSideRemoteHandleControlBlock.h util/distributed/RemoteHandle/RemoteHandle.h util/distributed/RemoteHandle/RemoteHandleControlBlock.h util/SimpleStatemachine.h time.h time_minimal.h time/forward_declarations.h time/ice_conversions.h time/json_conversions.h time/CallbackWaitLock.h time/Clock.h time/ClockType.h time/ClockTypeNames.h time/CycleUtil.h time/DateTime.h time/Duration.h time/Frequency.h time/LocalTimeServer.h time/Metronome.h time/ScopedStopWatch.h time/StopWatch.h time/Timer.h time/TimeUtil.h time/TimeKeeper.h csv/CsvWriter.h csv/CsvReader.h eigen/conversions.h eigen/ice_conversions.h ice_conversions.h ice_conversions/ice_conversions_boost_templates.h ice_conversions/ice_conversions_templates.h ice_conversions/ice_conversions_templates.tpp $
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)
std::vector< visionx::CByteImageUPtr > _maskImageProviderImageOwner
#define call_template_function(F)
static bool synchronizeLocalCloneToTimestamp(VirtualRobot::RobotPtr robot, RobotStateComponentInterfacePrx robotStatePrx, Ice::Long timestamp)
Synchronizes a local robot to a robot state at timestamp.
void usingPointCloudProvider(std::string providerName)
Registers a delayed topic subscription and a delayed provider proxy retrieval which will be available...
std::array< float, 3 > uvz2xyz(int u, int v, float z, float fx, float fy) const
std::atomic< float > _maskZRotation
void onDisconnectPointCloudAndImageProcessor() override
Implement this method in the PointCloudAndImageProcessor in order to execute parts when the component...
detail::ComboBoxBuilder makeComboBox(std::string const &name)
void onConnectPointCloudAndImageProcessor() override
Implement this method in your PointCloudAndImageProcessor in order execute parts when the component i...
std::string _debugDrawerTopicName
std::mutex _pointCloudReportFrameMutex
PointCloudProviderInfo getPointCloudProvider(std::string name, bool waitForProxy=false)
Select an PointCloudProvider.
std::string getName() const
Retrieve name of object.
std::atomic< std::uint8_t > _blueHi
#define ARMARX_CHECK_EQUAL(lhs, rhs)
This macro evaluates whether lhs is equal (==) rhs and if it turns out to be false it will throw an E...
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
detail::FloatSpinBoxBuilder makeFloatSpinBox(std::string const &name)
visionx::ImageProviderInfo _maskImageProviderInfo
void process() override
Process the vision component.
std::atomic< std::uint8_t > _greenLo
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
double s(double t, double s0, double v0, double a0, double j)
This file offers overloads of toIce() and fromIce() functions for STL container types.
Derived & steps(int steps)
bool waitForImages(int milliseconds=1000)
Wait for new images.
std::string _pointCloudProviderName