29#include <condition_variable>
36#include <opencv2/opencv.hpp>
43#include <ArmarXCore/interface/observers/ObserverInterface.h>
48#include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
55#include <VisionX/interface/components/AzureKinectPointCloudProviderInterface.h>
56#include <VisionX/libraries/armem_human/server/HumanMemoryServerInterface.h>
62#ifdef INCLUDE_BODY_TRACKING
93 virtual public armarx::AzureKinectPointCloudProviderInterface,
97#ifdef INCLUDE_BODY_TRACKING
131 std::vector<imrec::ChannelPreferences>
137 const Ice::Current& = Ice::emptyCurrent)
override;
140 const Ice::Current& = Ice::emptyCurrent)
override;
144 const Ice::Current& = Ice::emptyCurrent)
override;
168 MetaPointCloudFormatPtr
171 MetaPointCloudFormatPtr info =
new MetaPointCloudFormat();
173 info->type = PointContentType::eColoredPoints;
177 ARMARX_INFO <<
"default pointcloud format: " << resultColorImage->width <<
", "
178 << resultColorImage->height;
181 resultColorImage->width * resultColorImage->height *
sizeof(ColoredPoint3D);
182 info->size = info->capacity;
193 static inline std::pair<int, int>
198 case K4A_COLOR_RESOLUTION_720P:
200 case K4A_COLOR_RESOLUTION_2160P:
202 case K4A_COLOR_RESOLUTION_1440P:
204 case K4A_COLOR_RESOLUTION_1080P:
206 case K4A_COLOR_RESOLUTION_3072P:
208 case K4A_COLOR_RESOLUTION_1536P:
212 throw std::logic_error(
"Invalid color dimensions value!");
221 static inline std::pair<int, int>
226 case K4A_DEPTH_MODE_NFOV_2X2BINNED:
228 case K4A_DEPTH_MODE_NFOV_UNBINNED:
230 case K4A_DEPTH_MODE_WFOV_2X2BINNED:
232 case K4A_DEPTH_MODE_WFOV_UNBINNED:
234 case K4A_DEPTH_MODE_PASSIVE_IR:
238 throw std::logic_error(
"Invalid depth dimensions value!");
251 s << version.major <<
"." << version.minor <<
"." << version.iteration;
258 const std::chrono::nanoseconds& k4a_system_timestamp_ns);
267 IceUtil::Time imagesTime;
270 std::mutex pointcloudProcMutex;
271 std::condition_variable pointcloudProcSignal;
277 bool depthImageReady =
false;
278 bool depthImageProcessed =
false;
287 pcl::PointCloud<CloudPointType>::Ptr pointcloud;
288 MetaPointCloudFormatPtr cloudFormat;
291 visionx::StereoCalibration calibration;
294 bool enableColorUndistortion =
false;
297 bool enableHeartbeat =
true;
300 std::string externalCalibrationFilePath;
303 cv::Mat cameraMatrix;
306 cv::Mat colorDistortionMap;
310 k4a_device_configuration_t config;
311 k4a::calibration k4aCalibration;
313 k4a::transformation transformation;
315 k4a::image alignedDepthImage, xyzImage;
317#ifdef INCLUDE_BODY_TRACKING
318 k4abt::tracker bodyTracker;
325 void runPublishBodyTrackingResults();
328 int mDeviceId = K4A_DEVICE_DEFAULT;
332 unsigned int num_crashes = 0;
335 diagnostics mDiagnostics;
337 bool bodyTrackingEnabled =
false;
338 bool bodyTrackingRunAtStart =
false;
339 std::atomic<bool> bodyTrackingIsRunning =
false;
340 std::string bodyTrackingModelFilename =
"${K4A_BODY_TRACKING_DNN_MODEL_FILEPATH}";
341 std::int32_t bodyTrackingGPUDeviceID = 0;
342 std::mutex bodyTrackingParameterMutex;
343 float bodyTrackingTemporalSmoothingFactor = 0.0f;
344 int bodyTrackingDepthMaskMinX = -1;
345 int bodyTrackingDepthMaskMaxX = -1;
346 int bodyTrackingDepthMaskMaxZ = -1;
347 bool startIMU =
false;
350 std::string bodyCameraFrameName =
"AzureKinectDepthCamera";
351 std::string robotName =
"Armar6";
364 void update(
int higherFramerate);
369 Subordinate pointCloud{.name =
"Point Cloud"};
372 std::mutex deviceToRealtimeOffsetMtx;
373 std::chrono::nanoseconds device_to_realtime_offset_{0};
375 std::mutex debugObserverMtx;
376 std::mutex metaInfoMtx;
378 armarx::plugins::HeartbeatComponentPlugin* heartbeatPlugin =
nullptr;
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
Represents a point in time.
AzureKinectPointCloudProviderPropertyDefinitions(std::string prefix)
void onInitComponent() override
Pure virtual hook for the subclass.
void setMaxDepthBodyTracking(int maxDepthInMM, const Ice::Current &=Ice::emptyCurrent) override
armarx::DateTime timestampToArmarX(const std::chrono::microseconds &k4a_timestamp_us)
bool doCapture() override
Main capturing function.
void enableHumanPoseEstimation(const armarx::EnableHumanPoseEstimationInput &input, const Ice::Current &=Ice::emptyCurrent) override
void onExitCapturingPointCloudProvider() override
This is called when the Component::onExitComponent() setup is called.
void onDisconnectComponent() override
Hook for subclass.
static std::pair< int, int > GetDepthDimensions(const k4a_depth_mode_t depth_mode)
Returns the dimension of the depth images that will be produced for a certain resolution.
void onStartCapture(float frames_per_second) override
This is called when the point cloud provider capturing has been started.
static std::pair< int, int > GetColorDimensions(const k4a_color_resolution_t resolution)
Returns the dimension of the color images that will be produced for a certain resolution.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void runPointcloudPublishing()
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 VersionToString(const k4a_version_t &version)
Creates a string from a k4a_version_t.
std::function< void(armarx::Duration)> createSwCallback(const std::string &description)
void onInitCapturingPointCloudProvider() override
This is called when the Component::onInitComponent() is called.
MetaPointCloudFormatPtr getDefaultPointCloudFormat() override
default point cloud format used to initialize shared memory
void onConnectComponent() override
Pure virtual hook for the subclass.
void onStopCapture() override
This is called when the point cloud provider capturing has been stopped.
static std::string GetDefaultName()
bool getImagesAreUndistorted(const ::Ice::Current &c) override
std::vector< imrec::ChannelPreferences > getImageRecordingChannelPreferences(const Ice::Current &) override
void onInitImageProvider() override
This is called when the Component::onInitComponent() is called.
void setWidthBodyTracking(int minXinPixel, int maxXinPixel, const Ice::Current &=Ice::emptyCurrent) override
void onExitComponent() override
Hook for subclass.
void onExitImageProvider() override
This is called when the Component::onExitComponent() setup is called.
void initializeTimestampOffset(const std::chrono::microseconds &k4a_device_timestamp_us)
bool hasSharedMemorySupport(const Ice::Current &c) override
pcl::PointXYZRGBA CloudPointType
void onDisconnectImageProvider() override
AzureKinectPointCloudProvider()
std::string getDefaultName() const override
void updateTimestampOffset(const std::chrono::microseconds &k4a_device_timestamp_us, const std::chrono::nanoseconds &k4a_system_timestamp_ns)
The CapturingPointCloudProvider provides a callback function to trigger the capturing of point clouds...
ImageProvider abstract class defines a component which provide images via ice or shared memory.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
#define ARMARX_INFO
The normal logging level.
client::plugins::PluginUser ClientPluginUser
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
std::unique_ptr< CByteImage > CByteImageUPtr
unsigned int skipFramesCount
void update(int higherFramerate)