Skip to content

Commit

Permalink
Further separating code for 2D and 3D cameras
Browse files Browse the repository at this point in the history
  • Loading branch information
pbosetti committed May 3, 2024
1 parent 27a83e5 commit 0eedff2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ if(WIN32)
endif()

if(k4a_FOUND AND k4abt_FOUND AND USE_KINECT_AZURE)
add_plugin(skeletonizer3D LIBS ${OpenCV_LIBS} k4a::k4a k4a::k4abt)
add_plugin(skeletonizer3D LIBS ${OpenCV_LIBS} k4a::k4a k4a::k4abt Eigen3::Eigen)
target_compile_definitions(skeletonizer3D PRIVATE KINECT_AZURE)
else()
add_plugin(skeletonizer3D LIBS common ${OpenCV_LIBS} openvino::runtime Eigen3::Eigen)
Expand Down
48 changes: 29 additions & 19 deletions src/plugin/skeletonizer3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ map<int, string> keypoints_map = {
class Skeletonizer3D : public Source<json> {

/*
____ _ _ _ _
/ ___|| |_ __ _| |_(_) ___ _ __ ___ ___ _ __ ___ | |__ ___ _ __ ___
____ _ _ _ _
/ ___|| |_ __ _| |_(_) ___ _ __ ___ ___ _ __ ___ | |__ ___ _ __ ___
\___ \| __/ _` | __| |/ __| | '_ ` _ \ / _ \ '_ ` _ \| '_ \ / _ \ '__/ __|
___) | || (_| | |_| | (__ | | | | | | __/ | | | | | |_) | __/ | \__ \
|____/ \__\__,_|\__|_|\___| |_| |_| |_|\___|_| |_| |_|_.__/ \___|_| |___/
*/
#ifndef KINECT_AZURE
static cv::Mat renderHumanPose(HumanPoseResult &_result,
Expand Down Expand Up @@ -152,14 +152,14 @@ class Skeletonizer3D : public Source<json> {
}
#endif

/*
__ __ _ _ _
| \/ | ___| |_| |__ ___ __| |___
| |\/| |/ _ \ __| '_ \ / _ \ / _` / __|
| | | | __/ |_| | | | (_) | (_| \__ \
|_| |_|\___|\__|_| |_|\___/ \__,_|___/
*/
/*
__ __ _ _ _
| \/ | ___| |_| |__ ___ __| |___
| |\/| |/ _ \ __| '_ \ / _ \ / _` / __|
| | | | __/ |_| | | | (_) | (_| \__ \
|_| |_|\___|\__|_| |_|\___/ \__,_|___/
*/

public:
// Constructor
Expand Down Expand Up @@ -445,6 +445,9 @@ class Skeletonizer3D : public Source<json> {
* @return result status ad defined in return_type
*/
return_type skeleton_from_rgb_compute(bool debug = false) {
#ifdef KINECT_AZURE

#else
if (_pipeline->isReadyToProcess()) {
_frame_num = _pipeline->submitData(
ImageInputData(_rgb), make_shared<ImageMetaData>(_rgb, _start_time));
Expand All @@ -464,6 +467,7 @@ class Skeletonizer3D : public Source<json> {
}
_frames_processed++;

#endif
return return_type::success;
}

Expand All @@ -477,7 +481,9 @@ class Skeletonizer3D : public Source<json> {
* @return result status ad defined in return_type
*/
return_type hessian_compute(bool debug = false) {
#ifdef KINECT_AZURE

#else
// y -> rows
// x -> cols

Expand Down Expand Up @@ -635,7 +641,7 @@ class Skeletonizer3D : public Source<json> {
}
}
}

#endif
return return_type::success;
}

Expand Down Expand Up @@ -733,6 +739,9 @@ class Skeletonizer3D : public Source<json> {

acquire_frame(_dummy);

#ifdef KINECT_AZURE

#else
skeleton_from_rgb_compute(_params["debug"]["skeleton_from_rgb_compute"]);

if (!(_result)) {
Expand Down Expand Up @@ -763,6 +772,7 @@ class Skeletonizer3D : public Source<json> {

// store the output in the out parameter json and the point cloud in the
// blob parameter
#endif
return return_type::success;
}

Expand All @@ -789,10 +799,10 @@ class Skeletonizer3D : public Source<json> {
string kind() override { return PLUGIN_NAME; }

protected:
Mat _rgbd; /**< the last RGBD frame */
Mat _rgb; /**< the last RGB frame */
Mat _rgbd; /**< the last RGBD frame */
Mat _rgb; /**< the last RGB frame */
map<string, vector<unsigned char>>
_skeleton2D; /**< the skeleton from 2D cameras only*/
_skeleton2D; /**< the skeleton from 2D cameras only*/
map<string, vector<unsigned char>>
_skeleton3D; /**< the skeleton from 3D cameras only*/
vector<Mat> _heatmaps; /**< the joints heatmaps */
Expand All @@ -816,23 +826,23 @@ class Skeletonizer3D : public Source<json> {
int _camera_device = 0;
data_t _fps = 25;
string _resolution_rgb = "800x600";
int _rgb_height; /**< image size rows */
int _rgb_width; /**< image size cols */
int _rgb_height; /**< image size rows */
int _rgb_width; /**< image size cols */
vector<cv::Point2i> _keypoints_list;
vector<cv::Point3f> _keypoints_cov;
string _model_file;
string _agent_id;
VideoCapture _cap;
chrono::steady_clock::time_point _start_time;
ov::Core _core;

#ifdef KINECT_AZURE
int _azure_device = 0; /**< the azure device ID */
k4a::capture _k4a_rgbd; /**< the last capture */
k4a::device _device;
k4abt::tracker _tracker;
// k4a_capture_t _k4a_rgbd; /**< the last capture */
#else
#else
ov::Core _core;
unique_ptr<ResultBase> _result;
OutputTransform _output_transform;
unique_ptr<ModelBase> _model;
Expand Down

0 comments on commit 0eedff2

Please sign in to comment.