Go to the documentation of this file.
24 #include <pcl/point_types.h>
25 #include <pcl/common/transforms.h>
30 #include <VisionX/interface/components/Calibration.h>
35 static constexpr
auto InMaskSuff =
"_in_mask";
36 static constexpr
auto OutOfMaskSuff =
"_out_of_mask";
37 static constexpr
auto OutOfMaskImgSuff =
"_out_of_image";
38 static constexpr
auto MaskVisuSuff =
"_mask_visu";
39 static constexpr
auto MaskAsCloudSuff =
"_mask_as_cloud";
41 #define call_template_function(F) \
42 switch(_pointCloudProviderInfo.pointCloudFormat->type) \
45 case visionx::PointContentType::eColoredPoints : F<pcl::PointXYZRGBA>(); break; \
46 case visionx::PointContentType::eColoredOrientedPoints : F<pcl::PointXYZRGBNormal>(); break; \
48 case visionx::PointContentType::eColoredLabeledPoints : F<pcl::PointXYZRGBL>(); break; \
50 case visionx::PointContentType::eOrientedPoints : \
51 ARMARX_ERROR << "eOrientedPoints NOT HANDLED IN VISIONX"; \
52 [[fallthrough]]; default: \
53 ARMARX_ERROR << "Could not process point cloud, because format '" \
54 << _pointCloudProviderInfo.pointCloudFormat->type << "' is unknown"; \
79 _redHi =
static_cast<std::uint8_t
>(getProperty<int>(
"MaskRedHi"));
80 _redLo =
static_cast<std::uint8_t
>(getProperty<int>(
"MaskRedLo"));
81 _greenHi =
static_cast<std::uint8_t
>(getProperty<int>(
"MaskGreenHi"));
82 _greenLo =
static_cast<std::uint8_t
>(getProperty<int>(
"MaskGreenLo"));
83 _blueHi =
static_cast<std::uint8_t
>(getProperty<int>(
"MaskBlueHi"));
84 _blueLo =
static_cast<std::uint8_t
>(getProperty<int>(
"MaskBlueLo"));
102 enableResultPointClouds<pcl::PointXYZRGBA>(
getName() + InMaskSuff);
103 enableResultPointClouds<pcl::PointXYZRGBA>(
getName() + OutOfMaskSuff);
104 enableResultPointClouds<pcl::PointXYZRGBA>(
getName() + OutOfMaskImgSuff);
105 enableResultPointClouds<pcl::PointXYZRGBA>(
getName() + MaskVisuSuff);
106 enableResultPointClouds<pcl::PointXYZRGBA>(
getName() + MaskAsCloudSuff);
158 auto frameprov = visionx::ReferenceFrameInterfacePrx::checkedCast(
_maskImageProvider);
167 const std::string calibProviderName = getProperty<std::string>(
"CalibrationProviderName");
168 if (calibProviderName.empty())
170 auto mcalibprov = visionx::MonocularCalibrationCapturingProviderInterfacePrx::checkedCast(
_maskImageProvider);
171 auto scalibprov = visionx::StereoCalibrationInterfacePrx::checkedCast(
_maskImageProvider);
186 auto calibProvider = getProxy<Ice::ObjectPrx>(calibProviderName);
187 auto mcalibprov = visionx::MonocularCalibrationCapturingProviderInterfacePrx::checkedCast(calibProvider);
188 auto scalibprov = visionx::StereoCalibrationInterfacePrx::checkedCast(calibProvider);
207 auto makeSlider = [&](std::string name,
int val,
int min = 0,
int max = 255)
216 auto makeFSlider = [&](std::string name,
int min,
int max,
float val)
227 makeSlider(
"red lo",
_redLo);
228 makeSlider(
"red hi",
_redHi);
231 makeSlider(
"blue lo",
_blueLo);
232 makeSlider(
"blue hi",
_blueHi);
255 const int focaladjrange = 10000;
273 checkboxBuilder.widget().label =
"Sync using timestamp";
274 rootLayoutBuilder.
addChild(checkboxBuilder);
275 rootLayoutBuilder.
addChild(
new RemoteGui::VSpacer());
344 const float s = std::sin(alpha);
345 const float c = std::cos(alpha);
351 const float ushifted = u - + width / 2.f +
_offsetX;
352 const float vshifted =
v - + height / 2.f +
_offsetY;
354 const float rotatedU =
c * ushifted +
s * vshifted;
355 const float rotatedV = -
s * ushifted +
c * vshifted;
357 const float x = (
_flipX ? 1 : -1) * rotatedU;
358 const float y = (
_flipY ? 1 : -1) * rotatedV;
366 const float s = std::sin(alpha);
367 const float c = std::cos(alpha);
370 const float u = (
_flipX ? 1 : -1) * (x / z) * fx;
371 const float v = (
_flipY ? 1 : -1) * (y / z) * fy;
373 const float rotatedU =
c * u + -
s *
v;
374 const float rotatedV =
s * u +
c *
v;
380 const std::int64_t imgx =
static_cast<std::int64_t
>(rotatedU + width / 2.f) -
_offsetX;
381 const std::int64_t imgy =
static_cast<std::int64_t
>(rotatedV + height / 2.f) -
_offsetY;
417 typename pcl::PointCloud<PointType>::Ptr inputCloud(
new pcl::PointCloud<PointType>());
453 camInReportFrame = fp.toEigen();
458 pclInCamFrame = fp.toEigen();
463 typename pcl::PointCloud<PointType>::Ptr tmpCloud(
new pcl::PointCloud<PointType>());
464 pcl::transformPointCloud(*inputCloud, *tmpCloud, pclInCamFrame);
465 tmpCloud.swap(inputCloud);
472 std::uint64_t pointsInImage = 0;
473 std::uint64_t pointsOutOfImage = 0;
474 _maskedCloud.reset(
new pcl::PointCloud<pcl::PointXYZRGBA>());
475 _inputCloud.reset(
new pcl::PointCloud<pcl::PointXYZRGBA>());
476 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr unmaskedCloud(
new pcl::PointCloud<pcl::PointXYZRGBA>());
477 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr outOfImageCloud(
new pcl::PointCloud<pcl::PointXYZRGBA>());
478 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr visuCloud(
new pcl::PointCloud<pcl::PointXYZRGBA>());
482 for (
const auto& point : inputCloud->points)
511 const auto uv =
xyz2uv(p.x, p.y, p.z, fx, fy);
512 const std::int64_t u = uv.at(0);
513 const std::int64_t
v = uv.at(1);
514 if (u < 0 || u >= img.width || v < 0 || v >= img.height)
518 p.r = p.b = p.a = 255;
520 outOfImageCloud->push_back(p);
525 p.r = img.pixels[(u +
v * img.width) * 3 + 0];
526 p.g = img.pixels[(u +
v * img.width) * 3 + 1];
527 p.b = img.pixels[(u +
v * img.width) * 3 + 2];
531 const bool okR = r.first <= p.r && r.second >= p.r;
532 const bool okG = g.first <= p.g && g.second >= p.g;
533 const bool okB = b.first <= p.b && b.second >= p.b;
541 unmaskedCloud->push_back(p);
543 visuCloud->push_back(p);
547 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr tmpCloud(
new pcl::PointCloud<pcl::PointXYZRGBA>());
549 pcl::transformPointCloud(*
_maskedCloud, *tmpCloud, camInReportFrame);
552 pcl::transformPointCloud(*unmaskedCloud, *tmpCloud, camInReportFrame);
555 pcl::transformPointCloud(*outOfImageCloud, *tmpCloud, camInReportFrame);
558 pcl::transformPointCloud(*visuCloud, *tmpCloud, camInReportFrame);
563 for (
int u = 0; u < img.width; ++u)
565 for (
int v = 0;
v < img.height; ++
v)
568 auto xyz =
uvz2xyz(u,
v, (fx + fy) / 2, fx, fy);
574 p.r = img.pixels[(u +
v * img.width) * 3 + 0];
575 p.g = img.pixels[(u +
v * img.width) * 3 + 1];
576 p.b = img.pixels[(u +
v * img.width) * 3 + 2];
577 visuCloud->push_back(p);
580 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...
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)
MatrixXX< 4, 4, float > Matrix4f
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