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;
273 bool depthImageReady;
274 bool depthImageProcessed;
283 pcl::PointCloud<CloudPointType>::Ptr pointcloud;
284 MetaPointCloudFormatPtr cloudFormat;
287 visionx::StereoCalibration calibration;
290 bool enableColorUndistortion =
false;
293 bool enableHeartbeat =
true;
296 std::string externalCalibrationFilePath;
299 cv::Mat cameraMatrix;
302 cv::Mat colorDistortionMap;
306 k4a_device_configuration_t config;
307 k4a::calibration k4aCalibration;
309 k4a::transformation transformation;
311 k4a::image alignedDepthImage, xyzImage;
313#ifdef INCLUDE_BODY_TRACKING
314 k4abt::tracker bodyTracker;
321 void runPublishBodyTrackingResults();
324 int mDeviceId = K4A_DEVICE_DEFAULT;
328 unsigned int num_crashes = 0;
331 diagnostics mDiagnostics;
333 bool bodyTrackingEnabled =
false;
334 bool bodyTrackingRunAtStart =
false;
335 std::atomic<bool> bodyTrackingIsRunning =
false;
336 std::string bodyTrackingModelFilename =
"${K4A_BODY_TRACKING_DNN_MODEL_FILEPATH}";
337 std::int32_t bodyTrackingGPUDeviceID = 0;
338 std::mutex bodyTrackingParameterMutex;
339 float bodyTrackingTemporalSmoothingFactor = 0.0f;
340 int bodyTrackingDepthMaskMinX = -1;
341 int bodyTrackingDepthMaskMaxX = -1;
342 int bodyTrackingDepthMaskMaxZ = -1;
343 bool startIMU =
false;
346 std::string bodyCameraFrameName =
"AzureKinectDepthCamera";
347 std::string robotName =
"Armar6";
360 void update(
int higherFramerate);
365 Subordinate pointCloud{.name =
"Point Cloud"};
368 std::mutex deviceToRealtimeOffsetMtx;
369 std::chrono::nanoseconds device_to_realtime_offset_{0};
371 std::mutex debugObserverMtx;
372 std::mutex metaInfoMtx;
374 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)