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
132 std::vector<imrec::ChannelPreferences>
138 const Ice::Current& = Ice::emptyCurrent)
override;
141 const Ice::Current& = Ice::emptyCurrent)
override;
145 const Ice::Current& = Ice::emptyCurrent)
override;
169 MetaPointCloudFormatPtr
172 MetaPointCloudFormatPtr info =
new MetaPointCloudFormat();
174 info->type = PointContentType::eColoredPoints;
178 ARMARX_INFO <<
"default pointcloud format: " << resultColorImage->width <<
", "
179 << resultColorImage->height;
182 resultColorImage->width * resultColorImage->height *
sizeof(ColoredPoint3D);
183 info->size = info->capacity;
194 static inline std::pair<int, int>
199 case K4A_COLOR_RESOLUTION_720P:
201 case K4A_COLOR_RESOLUTION_2160P:
203 case K4A_COLOR_RESOLUTION_1440P:
205 case K4A_COLOR_RESOLUTION_1080P:
207 case K4A_COLOR_RESOLUTION_3072P:
209 case K4A_COLOR_RESOLUTION_1536P:
213 throw std::logic_error(
"Invalid color dimensions value!");
222 static inline std::pair<int, int>
227 case K4A_DEPTH_MODE_NFOV_2X2BINNED:
229 case K4A_DEPTH_MODE_NFOV_UNBINNED:
231 case K4A_DEPTH_MODE_WFOV_2X2BINNED:
233 case K4A_DEPTH_MODE_WFOV_UNBINNED:
235 case K4A_DEPTH_MODE_PASSIVE_IR:
239 throw std::logic_error(
"Invalid depth dimensions value!");
252 s << version.major <<
"." << version.minor <<
"." << version.iteration;
259 const std::chrono::nanoseconds& k4a_system_timestamp_ns);
268 IceUtil::Time imagesTime;
271 std::mutex pointcloudProcMutex;
272 std::condition_variable pointcloudProcSignal;
274 bool depthImageReady;
275 bool depthImageProcessed;
284 pcl::PointCloud<CloudPointType>::Ptr pointcloud;
285 MetaPointCloudFormatPtr cloudFormat;
288 visionx::StereoCalibration calibration;
291 bool enableColorUndistortion =
false;
294 bool enableHeartbeat =
true;
297 std::string externalCalibrationFilePath;
300 cv::Mat cameraMatrix;
303 cv::Mat colorDistortionMap;
307 k4a_device_configuration_t config;
308 k4a::calibration k4aCalibration;
310 k4a::transformation transformation;
312 k4a::image alignedDepthImage, xyzImage;
314#ifdef INCLUDE_BODY_TRACKING
315 k4abt::tracker bodyTracker;
322 void runPublishBodyTrackingResults();
325 int mDeviceId = K4A_DEVICE_DEFAULT;
329 unsigned int num_crashes = 0;
332 diagnostics mDiagnostics;
334 bool bodyTrackingEnabled =
false;
335 bool bodyTrackingRunAtStart =
false;
336 std::atomic<bool> bodyTrackingIsRunning =
false;
337 std::string bodyTrackingModelFilename =
"${K4A_BODY_TRACKING_DNN_MODEL_FILEPATH}";
338 std::int32_t bodyTrackingGPUDeviceID = 0;
339 std::mutex bodyTrackingParameterMutex;
340 float bodyTrackingTemporalSmoothingFactor = 0.0f;
341 int bodyTrackingDepthMaskMinX = -1;
342 int bodyTrackingDepthMaskMaxX = -1;
343 int bodyTrackingDepthMaskMaxZ = -1;
344 bool startIMU =
false;
347 std::string bodyCameraFrameName =
"AzureKinectDepthCamera";
348 std::string robotName =
"Armar6";
361 void update(
int higherFramerate);
366 Subordinate pointCloud{.name =
"Point Cloud"};
369 std::mutex deviceToRealtimeOffsetMtx;
370 std::chrono::nanoseconds device_to_realtime_offset_{0};
372 std::mutex debugObserverMtx;
373 std::mutex metaInfoMtx;
375 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.
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)