Giter VIP home page Giter VIP logo

opencv-openpose-demo's Introduction

OpenPose-OpenCV Demo

  • 使用 OpenCV cv::dnn 模块调用 OpenPose 模型进行人体骨架识别。(可通过调整 .xml 文件来修改外部设置)。
  • An encapsulation that demonstrates the usage of OpenCV cv::dnn on OpenPOSE to detect Multiple Human Pose.

run-cpu run-cpu-multiple

File Structure

.
├── build
├── CMakeLists.txt  -- CMake Stuff
├── conf            -- Configurations
│   └── ...
├── default.xml     -- Default Configuration
├── include         -- Read from Configurations
│   └── ...
├── LICENSE 
├── logsrc          -- Log Helper[1]
│   └── ...
├── main.cpp        -- Main Program
├── models          -- Models
│   └── ...
├── openpose        -- Encapsulated Opencv-OpenPose [2]
│   └── ...
├── README.md
└── sources         -- Example Images and Videos
    └── ...

32 directories, 116 files
  • [1]: Reference: https://github.com/emilk/loguru
  • [2]: Reference: https://github.com/spmallick/learnopencv/tree/master/OpenPose-Multi-Person

Requirement

  • OpenCV
  • pthread (loguru requirement, other choices could be found in the manual)
  • wget and Access to the Internet (To download models)

Usage

Run Examples

# Download Models
./getModels.sh

mkdir build && cd build
cmake ..
make
./run -h # Check Program Usage
./run

Coding APIs

  • Copy ./openpose directory
  • Add following lines to CMakeLists.txt
INCLUDE_DIRECTORIES("./openpose")
ADD_SUBDIRECTORY("./openpose")
TARGET_LINK_LIBRARIES(run openpose)
# - `run` is the program names you define with `ADD_EXECUTABLE` command
# - `openpose` is the library name defined in `./openpose/CMakeLists.txt`

Configurations

  • Modify File default.xml for configurations
<?xml version="1.0"?>
<opencv_storage>
	<Settings>

		<!-- specify what kind of model was trained. It could be (COCO, BODY_25) depends on dataset. -->
		<dataset>BODY_25</dataset>
		<!-- model configuration, e.g. hand/pose.prototxt -->
		<modelTxt>./models/body_25/pose_deploy.prototxt</modelTxt>
		<!-- model weights, e.g. hand/pose_iter_102000.caffemodel -->
		<modelBin>./models/body_25/pose_iter_584000.caffemodel</modelBin>

		<!-- Preprocess input image by resizing to a specific widh. -->
		<W_in>368</W_in>
		<!-- Preprocess input image by resizing to a specific height. -->
		<H_in>368</H_in>

		<!-- threshold or confidence value for the heatmap -->
		<thresh>0.07</thresh>
		<!-- scale for blob -->
		<scale>0.003922</scale>

		<logPath>log.log</logPath>

		<!-- Could be (CPU, GPU) depends on devices and OpenCV Versions -->
		<device>CPU</device>

		<!-- Could be (CAM, IMAGE, VIDEO) -->
		<inputType>VIDEO</inputType>

		<!-- "*.png/jpg .etc" = Use Images -->
		<imageFile>./sources/group.jpg</imageFile>
		<!-- <outputPath>./output.png</outputPath> -->

		<!-- OutputPath is Necessary -->
		<videoFile>./sources/cxk.mp4</videoFile>
		<outputPath>./output.mp4</outputPath>

	</Settings>
</opencv_storage>

Add Audio using ffmpeg

  • Because OpenCV does not provide the audio features, the default output is muted without any audio. However, we can easily concatenate the audio from original input video on the output one to make the result sound.
ffmpeg -vn -i cxk.mp4 -i output.mp4 -y result_2.mp4

# - Options:
# 	-vn: No Video Frames is taken from `cxk.mp4`
# 	-i : Input File
# 	-y : Combine both
# - Legend:
# 	cxk.mp4   : Original Input File
# 	output.mp4: Output File without Audio

opencv-openpose-demo's People

Contributors

chrisvicky avatar

Stargazers

 avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.