Skip to content

Commit

Permalink
OpenCV (so all 3rdparty deps) removed from headers
Browse files Browse the repository at this point in the history
  • Loading branch information
gineshidalgo99 committed Oct 7, 2019
1 parent b3aceed commit d5d3427
Show file tree
Hide file tree
Showing 185 changed files with 3,168 additions and 1,996 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ It is **authored by [Gines Hidalgo](https://www.gineshidalgo.com), [Zhe Cao](htt
- **Output**: Basic image + keypoint display/saving (PNG, JPG, AVI, ...), keypoint saving (JSON, XML, YML, ...), and/or keypoints as array class.
- **OS**: Ubuntu (14, 16), Windows (8, 10), Mac OSX, Nvidia TX2.
- **Training and datasets**:
- [OpenPose Training](https://github.com/CMU-Perceptual-Computing-Lab/openpose_train).
- [Foot dataset website](https://cmu-perceptual-computing-lab.github.io/foot_keypoint_dataset/).
- [**OpenPose Training**](https://github.com/CMU-Perceptual-Computing-Lab/openpose_train).
- [**Foot dataset website**](https://cmu-perceptual-computing-lab.github.io/foot_keypoint_dataset/).
- **Others**:
- Available: command-line demo, C++ wrapper, and C++ API.
- [**Python API**](doc/modules/python_module.md).
Expand All @@ -55,7 +55,7 @@ It is **authored by [Gines Hidalgo](https://www.gineshidalgo.com), [Zhe Cao](htt


## Latest Features
- Oct 2019: [**Training code released**](https://github.com/CMU-Perceptual-Computing-Lab/openpose_train)!
- Sep 2019: [**Training code released**](https://github.com/CMU-Perceptual-Computing-Lab/openpose_train)!
- Jan 2019: [**Unity plugin released**](https://github.com/CMU-Perceptual-Computing-Lab/openpose_unity_plugin)!
- Jan 2019: [**Improved Python API**](doc/modules/python_module.md) released! Including body, face, hands, and all the functionality of the C++ API!
- Dec 2018: [**Foot dataset released**](https://cmu-perceptual-computing-lab.github.io/foot_keypoint_dataset) and [**new paper released**](https://arxiv.org/abs/1812.08008)!
Expand Down
86 changes: 86 additions & 0 deletions doc/deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
Deploying OpenPose (Exporting OpenPose to Other Projects)
==========================

## Contents
1. [Introduction](#introduction)
2. [Third-Party Libraries](#third-party-libraries)
3. [Private OpenPose Include Directory](#private-openpose-include-directory)
4. [Crash and Core Dumped Avoidance](#crash-and-core-dumped-avoidance)
5. [Deploying OpenPose](#deploying-openpose)
1. [Windows](#windows)
2. [CMake (Windows, Ubuntu, and Mac)](#cmake-windows-ubuntu-and-mac)



### Introduction
Starting in OpenPose 1.6.0 (GitHub code in or after October 2019), OpenPose has considerable refactor its code to get rid of OpenCV in its headers. This makes OpenPose 1.6 headers different to previous versions and a bit harder to use. However, it allows OpenPose to be exported to other projects without requiring any third-party libraries (except in some special cases detailed below). The greatest benefit of this change: if your project already uses OpenCV, and you add your own version of OpenPose, the OpenCV version used in OpenPose and the one used in your project will not interfere with each other anymore, even if they are different versions!



### Third-Party Libraries
While compiling OpenPose from source, the static library files (`*.a` for Ubuntu, `*.lib` for Windows, etc.) and `include/` directories of all the third-party libraries detailed in [doc/installation.md](./installation.md) are required (GFlags, Glog, OpenCV, Caffe, etc.). However, when deploying OpenPose, fewer dependencies are required:
- GFLags and Glog are required only if the `include/openpose/flags.hpp` file is going to be used (e.g., when intenting to use the command-line interface).
- OpenCV can be optionally included if your project already uses it (but make sure to use the same binaries and include directory of OpenCV for both OpenPose and your project or weird runtime crashes will occur!). Including OpenCV does not increase the functionality of OpenPose, but it makes it easier to use by adding some functions that directly take cv::Mat matrices as input (rather than raw pointers). However, it is optional starting in OpenPose 1.6.0.
- Caffe or any other 3rd-party libraries are not required.

The static library files (`*.a` for Ubuntu, `*.lib` for Windows, etc.) and `include/` directories are the files that must be included in your project settings. However, the runtime library files (`*.so` for Ubuntu, `*.dll` for Windows, etc.), which are always required, must simply be placed together with the final executable or in default system paths. I.e., these files are only used during runtime, so they do not require any configuration in your project settings. E.g., for Windows, you can simply copy the content of the auto-generated `build/bin/` directory into the path where your executable is located.



### Private OpenPose Include Directory
Inside `include/`, there are 2 directories: `openpose/` and `openpose_private/`. Adding the `include_private` directory will require to include more libraries (e.g., OpenCV and Eigen). This directory exposes some extra functions used internally, but most of the cases this functionality is not required at all, so the `include/` directory should only contain the `openpose/` directory when exported.

Windows-only: In addition, Windows users have to manually add `OP_API` to all the functions/classes from `openpose_private/` that he desires to use and then re-compile OpenPose.



### Crash and Core Dumped Avoidance
If your project already uses OpenCV, and you add your own version of OpenPose, the OpenCV version of OpenPose and the one from your project will not interfere anymore, even if they are different versions. However, you cannot use the OpenCV functions of OpenPose from a different project if that project uses a different versions of OpenCV. Otherwise, very cryptic runtime DLL errors might occur! Make sure you either:
- Compile OpenPose and your project with the same version of OpenCV.
- Or if that is not possible (new since OpenPose 1.6.0), use the non-OpenCV analog functions of OpenPose to avoid cryptic DLL runtime crashes.



## Deploying OpenPose
### Windows
First of all, make sure to read all the sections above.

Second, note that the CMake option should also work for Windows. Alternatively, we also show the more Windows-like version in which `*.dll`, `*.lib`, and `include/` files are copied, which might be easier to apply when using the portable binaries.



### CMake (Windows, Ubuntu, and Mac)
First of all, make sure to read all the sections above.

If you only intend to use the OpenPose demo, you might skip this step. This step is only recommended if you plan to use the OpenPose API from other projects.

To install the OpenPose headers and libraries into the system environment path (e.g., `/usr/local/` or `/usr/`), run the following command.
```
cd build/
sudo make install
```

Once the installation is completed, you can use OpenPose in your other project using the `find_package` cmake command. Below, is a small example `CMakeLists.txt`. In order to use this script, you also need to copy `FindGFlags.cmake` and `FindGlog.cmake` into your `<project_root_directory>/cmake/Modules/` (create the directory if necessary).
```
cmake_minimum_required(VERSION 2.8.7)
add_definitions(-std=c++11)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
find_package(GFlags)
find_package(Glog)
find_package(OpenCV)
find_package(OpenPose REQUIRED)
include_directories(${OpenPose_INCLUDE_DIRS} ${GFLAGS_INCLUDE_DIR} ${GLOG_INCLUDE_DIR} ${OpenCV_INCLUDE_DIRS})
add_executable(example.bin example.cpp)
target_link_libraries(example.bin ${OpenPose_LIBS} ${GFLAGS_LIBRARY} ${GLOG_LIBRARY} ${OpenCV_LIBS})
```

If Caffe was built with OpenPose, it will automatically find it. Otherwise, you will need to link Caffe again as shown below (otherwise, you might get an error like `/usr/bin/ld: cannot find -lcaffe`).
```
link_directories(<path_to_caffe_installation>/caffe/build/install/lib)
```
45 changes: 7 additions & 38 deletions doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ OpenPose - Installation
7. [Installation](#installation)
8. [Reinstallation](#reinstallation)
9. [Uninstallation](#uninstallation)
10. [Optional Settings](#optional-settings)
10. [Deploying OpenPose (Exporting OpenPose to Other Projects)](#desploying-openpose-exporting-openpose-to-other-projects)
11. [Optional Settings](#optional-settings)
1. [Maximum Speed](#maximum-speed)
2. [COCO and MPI Models](#coco-and-mpi-models)
3. [Python API](#python-api)
Expand Down Expand Up @@ -129,7 +130,6 @@ The instructions in this section describe the steps to build OpenPose using CMak
3. [OpenPose Configuration](#openpose-configuration)
4. [OpenPose Building](#openpose-building)
5. [Run OpenPose](#run-openpose)
6. [OpenPose from other Projects (Ubuntu and Mac)](#openpose-from-other-projects-ubuntu-and-mac)



Expand Down Expand Up @@ -207,42 +207,6 @@ Check OpenPose was properly installed by running it on the default images, video
### OpenPose from other Projects (Ubuntu and Mac)
If you only intend to use the OpenPose demo, you might skip this step. This step is only recommended if you plan to use the OpenPose API from other projects.
To install the OpenPose headers and libraries into the system environment path (e.g., `/usr/local/` or `/usr/`), run the following command.
```
cd build/
sudo make install
```
Once the installation is completed, you can use OpenPose in your other project using the `find_package` cmake command. Below, is a small example `CMakeLists.txt`. In order to use this script, you also need to copy `FindGFlags.cmake` and `FindGlog.cmake` into your `<project_root_directory>/cmake/Modules/` (create the directory if necessary).
```
cmake_minimum_required(VERSION 2.8.7)

add_definitions(-std=c++11)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")

find_package(GFlags)
find_package(Glog)
find_package(OpenCV)
find_package(OpenPose REQUIRED)

include_directories(${OpenPose_INCLUDE_DIRS} ${GFLAGS_INCLUDE_DIR} ${GLOG_INCLUDE_DIR} ${OpenCV_INCLUDE_DIRS})

add_executable(example.bin example.cpp)

target_link_libraries(example.bin ${OpenPose_LIBS} ${GFLAGS_LIBRARY} ${GLOG_LIBRARY} ${OpenCV_LIBS})
```
If Caffe was built with OpenPose, it will automatically find it. Otherwise, you will need to link Caffe again as shown below (otherwise, you might get an error like `/usr/bin/ld: cannot find -lcaffe`).
```
link_directories(<path_to_caffe_installation>/caffe/build/install/lib)
```
## Reinstallation
In order to re-install OpenPose:
1. (Ubuntu and Mac) If you ran `sudo make install`, then run `sudo make uninstall` in `build/`.
Expand All @@ -259,6 +223,11 @@ In order to uninstall OpenPose:
## Deploying OpenPose (Exporting OpenPose to Other Projects)
See [doc/deployment.md](./deployment.md).
### Optional Settings
#### Maximum Speed
Check the OpenPose Benchmark as well as some hints to speed up and/or reduce the memory requirements for OpenPose on [doc/speed_up_openpose.md](./speed_up_openpose.md).
Expand Down
19 changes: 11 additions & 8 deletions doc/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ OpenPose Library - Release Notes
3. CvMatToOutput and Renderers allow to keep input resolution as output for images (core module).
6. New standalone face keypoint detector based on OpenCV face detector: much faster if body keypoint detection is not required but much less accurate.
7. Face and hand keypoint detectors now can return each keypoint heatmap.
8. The flag `USE_CUDNN` is no longer required; `USE_CAFFE` and `USE_CUDA` (replacing the old `CPU_ONLY`) are no longer required to use the library, only to build it. In addition, Boost, Caffe, and its dependencies have been removed from the OpenPose header files. Only OpenCV include and lib folders are required when building a project using OpenPose.
8. The flag `USE_CUDNN` is no longer required; `USE_CAFFE` and `USE_CUDA` (replacing the old `CPU_ONLY`) are no longer required to use the library, only to build it. In addition, Boost, Caffe, and its dependencies have been removed from the OpenPose header files. Only OpenCV include and lib directories are required when building a project using OpenPose.
9. OpenPose successfully compiles if the flags `USE_CAFFE` and/or `USE_CUDA` are not enabled, although it will give an error saying they are required.
10. COCO JSON file outputs 0 as score for non-detected keypoints.
11. Added example for OpenPose for user asynchronous output and cleaned all `tutorial_wrapper/` examples.
Expand Down Expand Up @@ -247,7 +247,7 @@ OpenPose Library - Release Notes
1. Removed scale parameter from hand and face rectangle extractor (causing wrong results if custom `--output_resolution`).
2. Functions `scaleKeypoints`, other than `scaleKeypoints(Array<float>& keypoints, const float scale)`, renamed as `scaleKeypoints2d`.
3. `(W)PoseExtractor` renamed to `(W)PoseExtractorNet` to distinguish from new `PoseExtractor`. Analogously with `(W)FaceExtractorNet` and `(W)HandExtractorNet`.
4. Experimental module removed and internal `tracking` folder moved to main openpose folder.
4. Experimental module removed and internal `tracking` directory moved to main openpose directory.
5. Switched GUI shortcuts for the kind of channel to render (skeleton, heatmap, PAF, ...) in order to make it more intuitive: 1 for skeleton, 1 for background heatmap, 2 for adding all heatmaps, 3 for adding all PAFs, and 4 to 0 for the initial heatmaps.
3. Main bugs fixed:
1. Fixed hand and face extraction and rendering scaling issues when `--output_resolution` is not the default one.
Expand Down Expand Up @@ -276,7 +276,7 @@ OpenPose Library - Release Notes
2. Renamed `tutorial_wrapper` as `tutorial_api_cpp` as well as new examples were added.
2. Renamed `tutorial_python` as `tutorial_api_python` as well as new examples were added.
3. Renamed `tutorial_thread` as `tutorial_api_thread`, focused in the multi-thread mechanism.
4. Removed `tutorial_pose`, the folder `tutorial_api_cpp` includes much cleaner and commented examples.
4. Removed `tutorial_pose`, the directory `tutorial_api_cpp` includes much cleaner and commented examples.
5. Examples do not end in core dumped if an OpenPose exception occurred during initialization, but they are rather closed returning -1. However, it will still results in core dumped if the exception occurs during multi-threading execution.
6. Added new examples, including examples to extract face and/or hand from images.
7. Added `--no_display` flag for the examples that does not use OpenPose output.
Expand Down Expand Up @@ -345,9 +345,9 @@ OpenPose Library - Release Notes
1. Replaced `--camera_fps` flag by `--write_video_fps`, given that it was a confusing name: It did not affect the webcam FPS, but only the FPS of the output video. In addition, default value changed from 30 to -1.
2. Flag `--hand_tracking` is a subcase of `--hand_detector`, so it has been removed and incorporated as `--hand_detector 3`.
8. Renamed `--frame_keep_distortion` as `--frame_undistort`, which performs the opposite operation (the default value has been also changed to the opposite).
9. Renamed `--camera_parameter_folder` as `--camera_parameter_path` because it could also take a whole XML file path rather than its parent folder.
9. Renamed `--camera_parameter_folder` as `--camera_parameter_path` because it could also take a whole XML file path rather than its parent directory.
10. Default value of flag `--scale_gap` changed from 0.3 to 0.25.
11. Moved most sh scripts into the `scripts/` folder. Only models/getModels.sh and the `*.bat` files are kept under `models/` and `3rdparty/windows`.
11. Moved most sh scripts into the `scripts/` directory. Only models/getModels.sh and the `*.bat` files are kept under `models/` and `3rdparty/windows`.
12. For Python compatibility and scalability increase, template `TDatums` used for `include/openpose/wrapper/wrapper.hpp` has changed from `std::vector<Datum>` to `std::vector<std::shared_ptr<Datum>>`, including the respective changes in all the worker classes. In addition, some template classes have been simplified to only take 1 template parameter for user simplicity.
13. Renamed intRound, charRound, etc. by positiveIntRound, positiveCharRound, etc. so that people can realize it is not safe for negative numbers.
14. Replaced flag `--write_coco_foot_json` by `--write_coco_json_variants` in order to generalize to any COCO JSON format (i.e., hand, face, etc).
Expand All @@ -357,7 +357,7 @@ OpenPose Library - Release Notes
3. Template functions could not be imported in Windows for projects using the OpenPose library DLL.
4. Function `scaleKeypoints2d` was not working if any of the scales was 1 (e.g., fail if scaleX = 1 but scaleY != 1, or if any offset was not 0).
5. Fixed bug in `KeepTopNPeople` that could provoke segmentation fault for `number_people_max` > 1.
6. Camera parameter reader can now take folder paths even if they are not finished in `/` (e.g., `~/Desktop/` worked but `~/Desktop` did not).
6. Camera parameter reader can now take directory paths even if they are not finished in `/` (e.g., `~/Desktop/` worked but `~/Desktop` did not).
7. 3D module: If the image area was smaller than HD resolution image area, the 3D keypoints were not properly estimated.
8. OpenCL fixes.
9. If manual CUDA architectures are set in CMake, they are also set for Caffe rather than only for OpenPose.
Expand All @@ -383,10 +383,13 @@ OpenPose Library - Release Notes



## Current version - Future OpenPose 1.5.2
## Current version - Future OpenPose 1.6.0
1. Main improvements:
1. Default OpenCV version for Windows upgraded to version 4.1.1, extracted from their oficial website: section `Releases`, subsection `OpenCV – 4.1.1`, `Windows` version.
1. Headers do not contain any 3rd-party library includes nor functions. This way, OpenPose can be exported without needing 3rd-party includes nor static library files (e.g., lib files in Windows), allowing people to use their own versions of OpenCV, Eigen, etc. without conflicting with OpenPose. Dynamic library files (e.g., `dll` files in Windows, `so` in Ubuntu) are still required.
2. Created the `openpose_private` directory with some internal headers that, if exported with OpenPose, would require including 3rd-party headers and static library files.
3. Default OpenCV version for Windows upgraded to version 4.1.1, extracted from their oficial website: section `Releases`, subsection `OpenCV - 4.1.1`, `Windows` version.
2. Functions or parameters renamed:
1. All headers moved into `openpose_private` and all 3rd-party library calls in headers.
3. Main bugs fixed:
1. Removed many Visual Studio (Windows) warnings.
4. Changes/additions that affect the compatibility with the OpenPose Unity Plugin:
Expand Down
2 changes: 1 addition & 1 deletion doc/released_features.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
OpenPose Library - All Released Features
====================================

- Oct 2019: [**Training code released**](https://github.com/CMU-Perceptual-Computing-Lab/openpose_train)!
- Sep 2019: [**Training code released**](https://github.com/CMU-Perceptual-Computing-Lab/openpose_train)!
- Jan 2019: [**Unity plugin released**](https://github.com/CMU-Perceptual-Computing-Lab/openpose_unity_plugin)!
- Jan 2019: [**Improved Python API**](doc/modules/python_module.md) released! Including body, face, hands, and all the functionality of the C++ API!
- Dec 2018: [**Foot dataset released**](https://cmu-perceptual-computing-lab.github.io/foot_keypoint_dataset) and [**new paper released**](https://arxiv.org/abs/1812.08008)!
Expand Down
Loading

0 comments on commit d5d3427

Please sign in to comment.