From d66882b98320644c1c848b9cb40b7787fa3d5781 Mon Sep 17 00:00:00 2001 From: gineshidalgo99 Date: Mon, 13 Nov 2017 21:57:19 -0500 Subject: [PATCH] Added tracking module structure --- .github/issue_template.md | 6 +- README.md | 140 ++++++++---------- examples/openpose/openpose.cpp | 4 +- include/openpose/core/datum.hpp | 17 ++- include/openpose/experimental/headers.hpp | 3 +- .../experimental/tracking/headers.hpp | 8 + .../tracking/personIdExtractor.hpp | 24 +++ .../tracking/wPersonIdExtractor.hpp | 78 ++++++++++ include/openpose/wrapper/wrapper.hpp | 7 + .../openpose/wrapper/wrapperStructPose.hpp | 9 +- src/openpose/CMakeLists.txt | 7 +- src/openpose/core/CMakeLists.txt | 4 +- src/openpose/core/datum.cpp | 9 +- src/openpose/experimental/CMakeLists.txt | 1 + .../experimental/tracking/CMakeLists.txt | 11 ++ .../experimental/tracking/defineTemplates.cpp | 6 + .../tracking/personIdExtractor.cpp | 39 +++++ src/openpose/face/CMakeLists.txt | 2 +- src/openpose/hand/CMakeLists.txt | 2 +- src/openpose/pose/CMakeLists.txt | 2 +- src/openpose/producer/CMakeLists.txt | 4 +- src/openpose/thread/CMakeLists.txt | 2 +- src/openpose/utilities/CMakeLists.txt | 6 +- src/openpose/wrapper/CMakeLists.txt | 6 +- src/openpose/wrapper/wrapperStructPose.cpp | 5 +- 25 files changed, 295 insertions(+), 107 deletions(-) create mode 100644 include/openpose/experimental/tracking/headers.hpp create mode 100644 include/openpose/experimental/tracking/personIdExtractor.hpp create mode 100644 include/openpose/experimental/tracking/wPersonIdExtractor.hpp create mode 100644 src/openpose/experimental/CMakeLists.txt create mode 100644 src/openpose/experimental/tracking/CMakeLists.txt create mode 100644 src/openpose/experimental/tracking/defineTemplates.cpp create mode 100644 src/openpose/experimental/tracking/personIdExtractor.cpp diff --git a/.github/issue_template.md b/.github/issue_template.md index 84752961..b7075734 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -36,10 +36,10 @@ You might select multiple topics, delete the rest: ### Your System Configuration **Operating system** (`lsb_release -a` in Ubuntu): -**Installation mode**: CMake, sh script, or manual Makefile installation (Ubuntu); VS2015, VS2017, CMake, ... (Windows) +**Installation mode**: CMake, sh script, manual Makefile installation, ... (Ubuntu); VS2015, VS2017, CMake, ... (Windows); ...? **CUDA version** (`cat /usr/local/cuda/version.txt` in most cases): **cuDNN version**: **GPU model** (`nvidia-smi` in Ubuntu): -**Caffe version**: Default from OpenPose or custom version. -**OpenCV version**: pre-compiled `apt-get install libopencv-dev` (only Ubuntu); OpenPose default (only Windows); compiled from source: 2.4.9, 2.4.12, 3.1, 3.2, ... +**Caffe version**: Default from OpenPose, custom version, ...? +**OpenCV version**: pre-compiled `apt-get install libopencv-dev` (only Ubuntu); OpenPose default (only Windows); compiled from source? If so, 2.4.9, 2.4.12, 3.1, 3.2?; ...? Compiler (`gcc --version` in Ubuntu): diff --git a/README.md b/README.md index 145eb6a0..0011a3cd 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,27 @@
- +
----------------- -[![Build Status](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose.svg?branch=master)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose) +| **`Linux`** | +|-------------| +|[![Build Status](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose.svg?branch=master)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose)| -OpenPose is a **library for real-time multi-person keypoint detection and multi-threading written in C++** using OpenCV and Caffe.

+OpenPose represents the **first real-time multi-person system to jointly detect human body, hand and facial keypoints (in total 130 keypoints) on single images**. **Functionality**: +- **Real-time multi-person keypoint detection**. + - 15 or **18-keypoint body estimation**. **Running time invariant to number of detected people**. + - **2x21-keypoint hand** estimation. Currently, **running time depends** on **number of detected people**. + - **70-keypoint face** estimation. Currently, **running time depends** on **number of detected people**. +- Inputs: Image, video, webcam, and IP camera. Included C++ demos to add your custom input. +- Outputs: Basic GUI display, keypoint saving (JSON, XML, YML, ...), and/or rendered image/video + keypoint saving (PNG, JPG, AVI, ...). +- Available: command-line demo, C++ wrapper, and C++ API. +- OS: Ubuntu, Windows, Nvidia TX2. + ## Latest News @@ -24,76 +35,51 @@ OpenPose is a **library for real-time multi-person keypoint detection and multi- -## Results -### Body Estimation -

- -

- -### Body + Face + Hands Estimation -

- -

- -### Body + Hands -

- -

- - - ## Contents 1. [Latest News](#latest-news) 2. [Results](#results) -3. [Introduction](#introduction) -4. [Functionality](#functionality) -5. [Installation, Reinstallation and Uninstallation](#installation-reinstallation-and-uninstallation) -6. [Quick Start](#quick-start) +3. [Installation, Reinstallation and Uninstallation](#installation-reinstallation-and-uninstallation) +4. [Quick Start](#quick-start) 1. [Demo](#demo) 2. [OpenPose Wrapper](#openpose-wrapper) - 3. [Adding An Extra Module](#Adding-an-extra-module) - 4. [OpenPose C++ API](#openpose-c++-api) -7. [Output](#output) -8. [Standalone Face Or Hand Keypoint Detector](#standalone-face-or-hand-keypoint-detector) -9. [Speed Up Openpose And Benchmark](#speed-up-openpose-and-benchmark) -10. [Send Us Failure Cases!](#send-us-failure-cases) -11. [Send Us Your Feedback!](#send-us-your-feedback) -12. [Citation](#citation) -12. [Other Contributors](#other-contributors) - - + 3. [Adding An Extra Module](#adding-an-extra-module) + 4. [OpenPose C++ API](#openpose-c-api) + 5. [Standalone Face Or Hand Detector](#standalone-face-or-hand-detector) + 6. [Library Dependencies](#library-dependencies) +5. [Output](#output) +6. [Speeding Up OpenPose and Benchmark](#speeding-up-openpose-and-benchmark) +7. [Send Us Failure Cases and Feedback!](#send-us-failure-cases-and-feedback) +8. [Authors and Contributors](#authors-and-contributors) +9. [Citation](#citation) +10. [License](#license) -## Introduction -OpenPose represents the **first real-time system to jointly detect human body, hand and facial keypoints (in total 130 keypoints) on single images**. In addition, the system computational performance on body keypoint estimation is invariant to the number of detected people in the image. It uses Caffe, but it could easily be ported to other frameworks (Tensorflow, Torch, etc.). If you implement any of those, feel free to make a pull request! -OpenPose is authored by [Gines Hidalgo](https://www.gineshidalgo.com/), [Zhe Cao](http://www.andrew.cmu.edu/user/zhecao), [Tomas Simon](http://www.cs.cmu.edu/~tsimon/), [Shih-En Wei](https://scholar.google.com/citations?user=sFQD3k4AAAAJ&hl=en), [Hanbyul Joo](http://www.cs.cmu.edu/~hanbyulj/), and [Yaser Sheikh](http://www.cs.cmu.edu/~yaser/). Currently, it is being maintained by [Gines Hidalgo](https://www.gineshidalgo.com/) and [Bikramjot Hanzra](https://www.linkedin.com/in/bikz05). -It is freely available for free non-commercial use, and may be redistributed under these conditions. Please, see the [license](LICENSE) for further details. [Interested in a commercial license? Check this link](https://flintbox.com/public/project/47343/). For commercial queries, contact [Yaser Sheikh](http://www.cs.cmu.edu/~yaser/). - -In addition, OpenPose would not be possible without the [CMU Panoptic Studio](http://domedb.perception.cs.cmu.edu/). - -The pose estimation work is based on the C++ code from [the ECCV 2016 demo](https://github.com/CMU-Perceptual-Computing-Lab/caffe_rtpose), "Realtime Multiperson Pose Estimation", [Zhe Cao](http://www.andrew.cmu.edu/user/zhecao), [Tomas Simon](http://www.cs.cmu.edu/~tsimon/), [Shih-En Wei](https://scholar.google.com/citations?user=sFQD3k4AAAAJ&hl=en), [Yaser Sheikh](http://www.cs.cmu.edu/~yaser/). The [original repo](https://github.com/ZheC/Multi-Person-Pose-Estimation) includes Matlab and Python version, as well as the training code. +## Results +### Body Estimation +

+ +

+### Body, Face, and Hands Estimation +

+ +

-## Functionality -- Multi-person 15 or **18-keypoint body pose** estimation and rendering. **Running time invariant to number of people** on the image. -- Multi-person **2x21-keypoint hand** estimation and rendering. Note: In this initial version, **running time** linearly **depends** on the **number of people** on the image. -- Multi-person **70-keypoint face** estimation and rendering. Note: In this initial version, **running time** linearly **depends** on the **number of people** on the image. -- Flexible and easy-to-configure **multi-threading** module. -- Image, video, webcam and IP camera reader. -- Able to save and load the results in various formats (JSON, XML, PNG, JPG, ...). -- Small display and GUI for simple result visualization. -- All the functionality is wrapped into a **simple-to-use OpenPose Wrapper class**. +### Body and Hands Estimation +

+ +

## Installation, Reinstallation and Uninstallation -You can find the installation, reinstallation and uninstallation steps on: [doc/installation.md](doc/installation.md). +See [doc/installation.md](doc/installation.md) for instructions on how to build from source or how to download our portable binaries. ## Quick Start -Most users do not need the [OpenPose C++ API](#openpose-c++-api), but they can simply use the basic [Demo](#demo) and/or [OpenPose Wrapper](#openpose-wrapper). +Most users do not need the [OpenPose C++ API](#openpose-c-api), but they can simply use the basic [Demo](#demo) and/or [OpenPose Wrapper](#openpose-wrapper). ### Demo Ideal to process images/video/webcam and display/save the results. Check [doc/demo_overview.md](doc/demo_overview.md). @@ -107,44 +93,46 @@ Learn how to easily add an extra module to OpenPose in [doc/library_add_new_modu ### OpenPose C++ API Your case if you want to use the C++ API. See [doc/library_introduction.md](doc/library_introduction.md). - - -## Output -Output (format, keypoint index ordering, etc.) in [doc/output.md](doc/output.md). - - - -## Standalone Face Or Hand Keypoint Detector +### Standalone Face Or Hand Detector If you do not need the body detector and want to speed up the face keypoint detection, you can use the OpenCV-based approach, see [doc/standalone_face_or_hand_keypoint_detector.md](doc/standalone_face_or_hand_keypoint_detector.md). You can also use the OpenPose hand and/or face keypoint detectors with your own face or hand detectors, rather than using the body detector. E.g. useful for camera views at which the hands are visible but not the body, so that the OpenPose detector would fail. See [doc/standalone_face_or_hand_keypoint_detector.md](doc/standalone_face_or_hand_keypoint_detector.md). +### Library Dependencies +OpenPose currently uses OpenCV and Caffe, as well as any Caffe dependency. The demos additionally use GFlags. It could easily be ported to other deep learning frameworks (Tensorflow, Torch, ...). Feel free to make a pull request if you implement any of those! -## Speed Up OpenPose and Benchmark -Check the OpenPose Benchmark and some hints to speed up OpenPose on [doc/installation.md#faq](doc/installation.md#faq). + +## Output +Output (format, keypoint index ordering, etc.) in [doc/output.md](doc/output.md). -## Send Us Failure Cases! -If you find videos or images where OpenPose does not seems to work well, feel free to send them to openposecmu@gmail.com (email only for failure cases!), we will use them to improve the quality of the algorithm. Thanks! +## Speeding Up OpenPose and Benchmark +Check the OpenPose Benchmark and some hints to speed up OpenPose on [doc/installation.md#faq](doc/installation.md#faq). -## Send Us Your Feedback! +## Send Us Failure Cases and Feedback! Our library is open source for research purposes, and we want to continuously improve it! So please, let us know if... -1. ... you find any bug (in functionality or speed). +1. ... you find videos or images where OpenPose does not seems to work well. Feel free to send them to openposecmu@gmail.com (email only for failure cases!), we will use them to improve the quality of the algorithm! +2. ... you find any bug (in functionality or speed). +3. ... you added some functionality to some class or some new Worker subclass which we might potentially incorporate. +4. ... you know how to speed up or improve any part of the library. +5. ... you have a request about possible functionality. +6. ... etc. -2. ... you added some functionality to some class or some new Worker subclass which we might potentially incorporate. +Just comment on GitHub or make a pull request and we will answer as soon as possible! Send us an email if you use the library to make a cool demo or YouTube video! -3. ... you know how to speed up or improve any part of the library. -4. ... you have a request about possible functionality. -5. ... etc. +## Authors and Contributors +OpenPose is authored by [Gines Hidalgo](https://www.gineshidalgo.com/), [Zhe Cao](http://www.andrew.cmu.edu/user/zhecao), [Tomas Simon](http://www.cs.cmu.edu/~tsimon/), [Shih-En Wei](https://scholar.google.com/citations?user=sFQD3k4AAAAJ&hl=en), [Hanbyul Joo](http://www.cs.cmu.edu/~hanbyulj/), and [Yaser Sheikh](http://www.cs.cmu.edu/~yaser/). Currently, it is being maintained by [Gines Hidalgo](https://www.gineshidalgo.com/) and [Bikramjot Hanzra](https://www.linkedin.com/in/bikz05). The [original CVPR 2017 repo](https://github.com/ZheC/Multi-Person-Pose-Estimation) includes Matlab and Python versions, as well as the training code. The body pose estimation work is based on [the original ECCV 2016 demo](https://github.com/CMU-Perceptual-Computing-Lab/caffe_rtpose). -Just comment on GitHub or make a pull request and we will answer as soon as possible! Send us an email if you use the library to make a cool demo or YouTube video! +In addition, OpenPose would not be possible without the [CMU Panoptic Studio dataset](http://domedb.perception.cs.cmu.edu/). + +We would also like to thank all the people who helped OpenPose in any way. The main contributors are listed in [doc/contributors.md](doc/contributors.md). @@ -174,5 +162,5 @@ Please cite these papers in your publications if it helps your research (the fac -## Other Contributors -We would like to thank all the people who helped OpenPose in any way. The main contributors are listed in [doc/contributors.md](doc/contributors.md). +## License +OpenPose is freely available for free non-commercial use, and may be redistributed under these conditions. Please, see the [license](LICENSE) for further details. [Interested in a commercial license? Check this link](https://flintbox.com/public/project/47343/). For commercial queries, contact [Yaser Sheikh](http://www.cs.cmu.edu/~yaser/). diff --git a/examples/openpose/openpose.cpp b/examples/openpose/openpose.cpp index 018a414a..8eee66d0 100755 --- a/examples/openpose/openpose.cpp +++ b/examples/openpose/openpose.cpp @@ -71,6 +71,7 @@ DEFINE_int32(keypoint_scale, 0, "Scaling of the (x,y) co " size (set with `net_resolution`), `2` to scale it to the final output size (set with" " `resolution`), `3` to scale it in the range [0,1], and 4 for range [-1,1]. Non related" " with `scale_number` and `scale_gap`."); +DEFINE_bool(identification, false, "Whether to enable people identification across frames. Not available yet, coming soon."); // OpenPose Body Pose DEFINE_bool(body_disable, false, "Disable body keypoint detection. Option only possible for faster (but less accurate) face" " keypoint detection."); @@ -217,7 +218,8 @@ int openPoseDemo() poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, op::ScaleMode::UnsignedChar, - (float)FLAGS_render_threshold, enableGoogleLogging}; + (float)FLAGS_render_threshold, enableGoogleLogging, + FLAGS_identification}; // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{FLAGS_face, faceNetInputSize, op::flagsToRenderMode(FLAGS_face_render, FLAGS_render_pose), diff --git a/include/openpose/core/datum.hpp b/include/openpose/core/datum.hpp index 58b138e2..92f7971d 100644 --- a/include/openpose/core/datum.hpp +++ b/include/openpose/core/datum.hpp @@ -33,7 +33,7 @@ namespace op * Original image to be processed in Array format. * It has been resized to the net input resolution, as well as reformatted Array format to be compatible * with the net. - * In case of >1 scales, then each scale is right- and bottom-padded to fill the greatest resolution. The + * If >1 scales, each scale is right- and bottom-padded to fill the greatest resolution. The * scales are sorted from bigger to smaller. * Vector size: #scales * Each array size: 3 x input_net_height x input_net_width @@ -43,7 +43,7 @@ namespace op /** * Rendered image in Array format. * It consists of a blending of the cvInputData and the pose/body part(s) heatmap/PAF(s). - * If rendering is disabled (e.g. `no_render_pose` flag in the demo), then outputData will be empty. + * If rendering is disabled (e.g. `no_render_pose` flag in the demo), outputData will be empty. * Size: 3 x output_net_height x output_net_width */ Array outputData; @@ -51,7 +51,7 @@ namespace op /** * Rendered image in cv::Mat uchar format. * It has been resized to the desired output resolution (e.g. `resolution` flag in the demo). - * If outputData is empty, then cvOutputData will also be empty. + * If outputData is empty, cvOutputData will also be empty. * Size: (output_height x output_width) x 3 channels */ cv::Mat cvOutputData; @@ -64,12 +64,21 @@ namespace op */ Array poseKeypoints; + /** + * People ID + * It returns a person ID for each body pose, providing temporal consistency. The ID will be the same one + * for a person across frames. I.e. this ID allows to keep track of the same person in time. + * If either person identification is disabled or poseKeypoints is empty, poseIds will also be empty. + * Size: #people + */ + Array poseIds; + /** * Body pose global confidence/score for each person in the image. * It does not only consider the score of each body keypoint, but also the score of each PAF association. * Optimized for COCO evaluation metric. * It will highly penalyze people with missing body parts (e.g. cropped people on the borders of the image). - * If poseKeypoints is empty, then poseScores will also be empty. + * If poseKeypoints is empty, poseScores will also be empty. * Size: #people */ Array poseScores; diff --git a/include/openpose/experimental/headers.hpp b/include/openpose/experimental/headers.hpp index 70785a5e..b34802d5 100644 --- a/include/openpose/experimental/headers.hpp +++ b/include/openpose/experimental/headers.hpp @@ -1,7 +1,8 @@ #ifndef OPENPOSE_EXPERIMENTAL_HEADERS_HPP #define OPENPOSE_EXPERIMENTAL_HEADERS_HPP -// producer module +// experimental modules // #include +#include #endif // OPENPOSE_EXPERIMENTAL_HEADERS_HPP diff --git a/include/openpose/experimental/tracking/headers.hpp b/include/openpose/experimental/tracking/headers.hpp new file mode 100644 index 00000000..0f76f818 --- /dev/null +++ b/include/openpose/experimental/tracking/headers.hpp @@ -0,0 +1,8 @@ +#ifndef OPENPOSE_TRACKING_HEADERS_HPP +#define OPENPOSE_TRACKING_HEADERS_HPP + +// tracking module +#include +#include + +#endif // OPENPOSE_TRACKING_HEADERS_HPP diff --git a/include/openpose/experimental/tracking/personIdExtractor.hpp b/include/openpose/experimental/tracking/personIdExtractor.hpp new file mode 100644 index 00000000..bbff3597 --- /dev/null +++ b/include/openpose/experimental/tracking/personIdExtractor.hpp @@ -0,0 +1,24 @@ +#ifndef OPENPOSE_TRACKING_PERSON_ID_EXTRACTOR_HPP +#define OPENPOSE_TRACKING_PERSON_ID_EXTRACTOR_HPP + +#include + +namespace op +{ + class OP_API PersonIdExtractor + { + public: + PersonIdExtractor(); + + virtual ~PersonIdExtractor(); + + Array extractIds(const Array& poseKeypoints); + + private: + long long mNextPersonId; + + DELETE_COPY(PersonIdExtractor); + }; +} + +#endif // OPENPOSE_TRACKING_PERSON_ID_EXTRACTOR_HPP diff --git a/include/openpose/experimental/tracking/wPersonIdExtractor.hpp b/include/openpose/experimental/tracking/wPersonIdExtractor.hpp new file mode 100644 index 00000000..773b55d4 --- /dev/null +++ b/include/openpose/experimental/tracking/wPersonIdExtractor.hpp @@ -0,0 +1,78 @@ +#ifndef OPENPOSE_TRACKING_W_PERSON_ID_EXTRACTOR_HPP +#define OPENPOSE_TRACKING_W_PERSON_ID_EXTRACTOR_HPP + +#include +#include +#include + +namespace op +{ + template + class WPersonIdExtractor : public Worker + { + public: + explicit WPersonIdExtractor(const std::shared_ptr& personIdExtractorSharedPtr); + + void initializationOnThread(); + + void work(TDatums& tDatums); + + private: + std::shared_ptr spPersonIdExtractor; + + DELETE_COPY(WPersonIdExtractor); + }; +} + + + + + +// Implementation +#include +namespace op +{ + template + WPersonIdExtractor::WPersonIdExtractor(const std::shared_ptr& personIdExtractorSharedPtr) : + spPersonIdExtractor{personIdExtractorSharedPtr} + { + } + + template + void WPersonIdExtractor::initializationOnThread() + { + } + + template + void WPersonIdExtractor::work(TDatums& tDatums) + { + try + { + if (checkNoNullNorEmpty(tDatums)) + { + // Debugging log + dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__); + // Profiling speed + const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__); + // Render people pose + for (auto& tDatum : *tDatums) + tDatum.poseIds = spPersonIdExtractor->extractIds(tDatum.poseKeypoints); + // Profiling speed + Profiler::timerEnd(profilerKey); + Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__); + // Debugging log + dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__); + } + } + catch (const std::exception& e) + { + this->stop(); + tDatums = nullptr; + error(e.what(), __LINE__, __FUNCTION__, __FILE__); + } + } + + COMPILE_TEMPLATE_DATUM(WPersonIdExtractor); +} + +#endif // OPENPOSE_TRACKING_W_PERSON_ID_EXTRACTOR_HPP diff --git a/include/openpose/wrapper/wrapper.hpp b/include/openpose/wrapper/wrapper.hpp index abe1ada4..9c1acb78 100644 --- a/include/openpose/wrapper/wrapper.hpp +++ b/include/openpose/wrapper/wrapper.hpp @@ -276,6 +276,7 @@ namespace op #include #include #include +#include #include #include namespace op @@ -818,6 +819,12 @@ namespace op // Frame buffer and ordering if (spWPoses.size() > 1u) mPostProcessingWs.emplace_back(std::make_shared>()); + // Person ID identification + if (wrapperStructPose.identification) + { + const auto personIdExtractor = std::make_shared(); + mPostProcessingWs.emplace_back(std::make_shared>(personIdExtractor)); + } // Frames processor (OpenPose format -> cv::Mat format) if (renderOutput) { diff --git a/include/openpose/wrapper/wrapperStructPose.hpp b/include/openpose/wrapper/wrapperStructPose.hpp index 42e2932a..e7646d58 100644 --- a/include/openpose/wrapper/wrapperStructPose.hpp +++ b/include/openpose/wrapper/wrapperStructPose.hpp @@ -150,6 +150,11 @@ namespace op */ bool enableGoogleLogging; + /** + * Whether to return a person ID for each body skeleton, providing temporal consistency. + */ + bool identification; + /** * Constructor of the struct. * It has the recommended and default values we recommend for each element of the struct. @@ -166,8 +171,8 @@ namespace op const int defaultPartToRender = 0, const std::string& modelFolder = "models/", const std::vector& heatMapTypes = {}, const ScaleMode heatMapScale = ScaleMode::ZeroToOne, - const float renderThreshold = 0.05f, - const bool enableGoogleLogging = true); + const float renderThreshold = 0.05f, const bool enableGoogleLogging = true, + const bool identification = false); }; } diff --git a/src/openpose/CMakeLists.txt b/src/openpose/CMakeLists.txt index 70403472..757823b3 100644 --- a/src/openpose/CMakeLists.txt +++ b/src/openpose/CMakeLists.txt @@ -1,4 +1,5 @@ add_subdirectory(core) +add_subdirectory(experimental) add_subdirectory(filestream) add_subdirectory(gui) add_subdirectory(pose) @@ -8,9 +9,9 @@ add_subdirectory(thread) add_subdirectory(face) add_subdirectory(hand) add_subdirectory(wrapper) -set_target_properties(openpose_core openpose_filestream openpose_gui openpose_pose - openpose_utilities openpose_producer openpose_thread openpose_face openpose_hand - openpose_wrapper +set_target_properties(openpose_core openpose_face openpose_filestream + openpose_gui openpose_hand openpose_pose openpose_producer + openpose_utilities openpose_thread openpose_tracking openpose_wrapper PROPERTIES COMPILE_FLAGS ${OP_CXX_FLAGS}) # make the openpose.so diff --git a/src/openpose/core/CMakeLists.txt b/src/openpose/core/CMakeLists.txt index 8c84a0c5..9a589351 100644 --- a/src/openpose/core/CMakeLists.txt +++ b/src/openpose/core/CMakeLists.txt @@ -20,10 +20,10 @@ cuda_add_library(openpose_core resizeAndMergeBase.cpp resizeAndMergeBase.cu resizeAndMergeCaffe.cpp - scaleAndSizeExtractor) + scaleAndSizeExtractor.cpp) add_library(caffe SHARED IMPORTED) -set_property(TARGET caffe PROPERTY IMPORTED_LOCATION ${Caffe_LIBS}) +set_property(TARGET caffe PROPERTY IMPORTED_LOCATION ${Caffe_LIBS}) target_link_libraries(openpose_core caffe) diff --git a/src/openpose/core/datum.cpp b/src/openpose/core/datum.cpp index 60445306..52d5840f 100644 --- a/src/openpose/core/datum.cpp +++ b/src/openpose/core/datum.cpp @@ -3,7 +3,9 @@ namespace op { - Datum::Datum() + Datum::Datum() : + id{std::numeric_limits::max()}, + poseIds{-1} { } @@ -19,6 +21,7 @@ namespace op cvOutputData{datum.cvOutputData}, // Resulting Array data poseKeypoints{datum.poseKeypoints}, + poseIds{datum.poseIds}, poseScores{datum.poseScores}, poseHeatMaps{datum.poseHeatMaps}, faceRectangles{datum.faceRectangles}, @@ -49,6 +52,7 @@ namespace op cvOutputData = datum.cvOutputData; // Resulting Array data poseKeypoints = datum.poseKeypoints; + poseIds = datum.poseIds, poseScores = datum.poseScores, poseHeatMaps = datum.poseHeatMaps, faceRectangles = datum.faceRectangles, @@ -90,6 +94,7 @@ namespace op std::swap(cvOutputData, datum.cvOutputData); // Resulting Array data std::swap(poseKeypoints, datum.poseKeypoints); + std::swap(poseIds, datum.poseIds); std::swap(poseScores, datum.poseScores); std::swap(poseHeatMaps, datum.poseHeatMaps); std::swap(faceRectangles, datum.faceRectangles); @@ -122,6 +127,7 @@ namespace op std::swap(cvOutputData, datum.cvOutputData); // Resulting Array data std::swap(poseKeypoints, datum.poseKeypoints); + std::swap(poseIds, datum.poseIds); std::swap(poseScores, datum.poseScores); std::swap(poseHeatMaps, datum.poseHeatMaps); std::swap(faceRectangles, datum.faceRectangles); @@ -164,6 +170,7 @@ namespace op datum.cvOutputData = cvOutputData.clone(); // Resulting Array data datum.poseKeypoints = poseKeypoints.clone(); + datum.poseIds = poseIds.clone(); datum.poseScores = poseScores.clone(); datum.poseHeatMaps = poseHeatMaps.clone(); datum.faceRectangles = faceRectangles; diff --git a/src/openpose/experimental/CMakeLists.txt b/src/openpose/experimental/CMakeLists.txt new file mode 100644 index 00000000..4cc09828 --- /dev/null +++ b/src/openpose/experimental/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(tracking) diff --git a/src/openpose/experimental/tracking/CMakeLists.txt b/src/openpose/experimental/tracking/CMakeLists.txt new file mode 100644 index 00000000..d904c600 --- /dev/null +++ b/src/openpose/experimental/tracking/CMakeLists.txt @@ -0,0 +1,11 @@ +set(SOURCES + defineTemplates.cpp + personIdExtractor.cpp) + +add_library(openpose_tracking ${SOURCES}) + +install(TARGETS openpose_tracking + EXPORT OpenPose + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/openpose) diff --git a/src/openpose/experimental/tracking/defineTemplates.cpp b/src/openpose/experimental/tracking/defineTemplates.cpp new file mode 100644 index 00000000..33ec4e15 --- /dev/null +++ b/src/openpose/experimental/tracking/defineTemplates.cpp @@ -0,0 +1,6 @@ +#include + +namespace op +{ + DEFINE_TEMPLATE_DATUM(WPersonIdExtractor); +} diff --git a/src/openpose/experimental/tracking/personIdExtractor.cpp b/src/openpose/experimental/tracking/personIdExtractor.cpp new file mode 100644 index 00000000..5a4690b4 --- /dev/null +++ b/src/openpose/experimental/tracking/personIdExtractor.cpp @@ -0,0 +1,39 @@ +#include + +namespace op +{ + PersonIdExtractor::PersonIdExtractor() : + mNextPersonId{0ll} + { + try + { + error("PersonIdExtractor (`identification` flag) not available yet, but we are working on it! Coming" + " soon!", __LINE__, __FUNCTION__, __FILE__); + } + catch (const std::exception& e) + { + error(e.what(), __LINE__, __FUNCTION__, __FILE__); + } + } + + PersonIdExtractor::~PersonIdExtractor() + { + } + + Array PersonIdExtractor::extractIds(const Array& poseKeypoints) + { + try + { + // Dummy: giving a new id to each element + Array poseIds{poseKeypoints.getSize(0), -1}; + for (auto i = 0u ; i < poseIds.getVolume() ; i++) + poseIds[i] = mNextPersonId++; + return poseIds; + } + catch (const std::exception& e) + { + error(e.what(), __LINE__, __FUNCTION__, __FILE__); + return Array{}; + } + } +} diff --git a/src/openpose/face/CMakeLists.txt b/src/openpose/face/CMakeLists.txt index db7be005..6bccfb43 100644 --- a/src/openpose/face/CMakeLists.txt +++ b/src/openpose/face/CMakeLists.txt @@ -15,7 +15,7 @@ if (BUILD_CAFFE) add_dependencies(openpose_face openpose_caffe) endif (BUILD_CAFFE) -install(TARGETS openpose_face +install(TARGETS openpose_face EXPORT OpenPose RUNTIME DESTINATION bin LIBRARY DESTINATION lib diff --git a/src/openpose/hand/CMakeLists.txt b/src/openpose/hand/CMakeLists.txt index 1d6cd5e7..b90fc419 100644 --- a/src/openpose/hand/CMakeLists.txt +++ b/src/openpose/hand/CMakeLists.txt @@ -1,4 +1,4 @@ -set(SOURCES +set(SOURCES defineTemplates.cpp handDetector.cpp handDetectorFromTxt.cpp diff --git a/src/openpose/pose/CMakeLists.txt b/src/openpose/pose/CMakeLists.txt index 108ba02b..c86dc4dd 100644 --- a/src/openpose/pose/CMakeLists.txt +++ b/src/openpose/pose/CMakeLists.txt @@ -1,4 +1,4 @@ -set(SOURCES +set(SOURCES bodyPartConnectorBase.cpp bodyPartConnectorBase.cu bodyPartConnectorCaffe.cpp diff --git a/src/openpose/producer/CMakeLists.txt b/src/openpose/producer/CMakeLists.txt index d489aecb..3024c0ba 100644 --- a/src/openpose/producer/CMakeLists.txt +++ b/src/openpose/producer/CMakeLists.txt @@ -8,8 +8,8 @@ set(SOURCES webcamReader.cpp) add_library(openpose_producer ${SOURCES}) -target_link_libraries(openpose_producer ${OpenCV_LIBS} openpose_core - openpose_thread openpose_filestream) +target_link_libraries(openpose_producer ${OpenCV_LIBS} openpose_core + openpose_filestream openpose_thread) install(TARGETS openpose_producer EXPORT OpenPose diff --git a/src/openpose/thread/CMakeLists.txt b/src/openpose/thread/CMakeLists.txt index cfb6775d..a1b6b7ae 100644 --- a/src/openpose/thread/CMakeLists.txt +++ b/src/openpose/thread/CMakeLists.txt @@ -3,7 +3,7 @@ set(SOURCES add_library(openpose_thread ${SOURCES}) -install(TARGETS openpose_thread +install(TARGETS openpose_thread EXPORT OpenPose RUNTIME DESTINATION bin LIBRARY DESTINATION lib diff --git a/src/openpose/utilities/CMakeLists.txt b/src/openpose/utilities/CMakeLists.txt index 25af7114..85d38a07 100644 --- a/src/openpose/utilities/CMakeLists.txt +++ b/src/openpose/utilities/CMakeLists.txt @@ -1,4 +1,4 @@ -set(SOURCES +set(SOURCES cuda.cpp errorAndLog.cpp fileSystem.cpp @@ -9,9 +9,9 @@ set(SOURCES string.cpp) find_package(Boost COMPONENTS system filesystem REQUIRED) - + cuda_add_library(openpose_utilities ${SOURCES}) -target_link_libraries(openpose_utilities openpose_producer openpose_filestream +target_link_libraries(openpose_utilities openpose_filestream openpose_producer ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY}) install(TARGETS openpose_utilities diff --git a/src/openpose/wrapper/CMakeLists.txt b/src/openpose/wrapper/CMakeLists.txt index 6fb8a96e..4ac61551 100644 --- a/src/openpose/wrapper/CMakeLists.txt +++ b/src/openpose/wrapper/CMakeLists.txt @@ -7,9 +7,9 @@ set(SOURCES wrapperStructPose.cpp) add_library(openpose_wrapper ${SOURCES}) -target_link_libraries(openpose_wrapper openpose_thread openpose_pose openpose_hand - openpose_core openpose_face openpose_filestream openpose_gui openpose_producer - openpose_utilities) +target_link_libraries(openpose_wrapper openpose_core openpose_face openpose_filestream + openpose_gui openpose_hand openpose_pose openpose_producer openpose_thread + openpose_tracking openpose_utilities) install(TARGETS openpose_wrapper EXPORT OpenPose diff --git a/src/openpose/wrapper/wrapperStructPose.cpp b/src/openpose/wrapper/wrapperStructPose.cpp index d032ed66..7dec2ffc 100644 --- a/src/openpose/wrapper/wrapperStructPose.cpp +++ b/src/openpose/wrapper/wrapperStructPose.cpp @@ -12,7 +12,7 @@ namespace op const std::string& modelFolder_, const std::vector& heatMapTypes_, const ScaleMode heatMapScale_, const float renderThreshold_, - const bool enableGoogleLogging_) : + const bool enableGoogleLogging_, const bool identification_) : enable{enable_}, netInputSize{netInputSize_}, outputSize{outputSize_}, @@ -31,7 +31,8 @@ namespace op heatMapTypes{heatMapTypes_}, heatMapScale{heatMapScale_}, renderThreshold{renderThreshold_}, - enableGoogleLogging{enableGoogleLogging_} + enableGoogleLogging{enableGoogleLogging_}, + identification{identification_} { } } -- GitLab