fix build and instructions for apple m1
This commit is contained in:
parent
b72fc70c01
commit
7b57938699
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -10,3 +10,5 @@ Cargo.lock
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
/refs/
|
/refs/
|
||||||
/mediapipe/
|
/mediapipe/
|
||||||
|
/logs/
|
||||||
|
.DS_Store
|
||||||
|
|
|
@ -12,10 +12,10 @@ edition = "2018"
|
||||||
name = "mediapipe"
|
name = "mediapipe"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cgmath = "0.18.0"
|
cgmath = "0.18"
|
||||||
libc = "0.2.0"
|
libc = "0.2"
|
||||||
opencv = { version = "0.63", features = ["clang-runtime"] }
|
opencv = "0.66"
|
||||||
protobuf = "2.23.0"
|
protobuf = "2.23"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
bindgen = "*"
|
bindgen = "*"
|
||||||
|
|
33
README.md
33
README.md
|
@ -12,31 +12,46 @@ And heavily based on this example: https://github.com/asprecic/mediapipe-qt-inte
|
||||||
|
|
||||||
## setup
|
## setup
|
||||||
|
|
||||||
|
To run the examples clone this project.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
git clone https://github.com/julesyoungberg/mediapipe-rs.git
|
||||||
|
```
|
||||||
|
|
||||||
Mediapipe is a framework for building AI-powered computer vision applications. It provides high level libraries exposing some of its solutions for common problems. This package makes some of these solutions available in Rust. In order to use it we must build a custom mediapipe C++ library.
|
Mediapipe is a framework for building AI-powered computer vision applications. It provides high level libraries exposing some of its solutions for common problems. This package makes some of these solutions available in Rust. In order to use it we must build a custom mediapipe C++ library.
|
||||||
|
|
||||||
Clone the modified Mediapipe repo.
|
Clone the modified Mediapipe repo next to `mediapipe-rs` or a project that uses `mediapipe-rs`.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
git clone https://github.com/julesyoungberg/mediapipe.git
|
git clone https://github.com/julesyoungberg/mediapipe.git
|
||||||
cd mediapipe
|
cd mediapipe
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### building mediapipe
|
||||||
|
|
||||||
Build & install the mediagraph library.
|
Build & install the mediagraph library.
|
||||||
|
|
||||||
### mac os
|
#### mac os
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
bazel build --define MEDIAPIPE_DISABLE_GPU=1 mediapipe:libmediagraph.dylib
|
bazel build --define MEDIAPIPE_DISABLE_GPU=1 mediapipe:libmediagraph.dylib
|
||||||
sudo cp bazel-bin/mediapipe/libmediagraph.dylib /usr/local/lib/libmediagraph.dylib
|
sudo cp bazel-bin/mediapipe/libmediagraph.dylib /usr/local/lib/libmediagraph.dylib
|
||||||
cp mediapipe/mediagraph.h /usr/local/include/mediagraph.h
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### linux (untested)
|
#### linux (untested)
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
bazel build --define MEDIAPIPE_DISABLE_GPU=1 mediapipe:mediagraph
|
bazel build --define MEDIAPIPE_DISABLE_GPU=1 mediapipe:mediagraph
|
||||||
cp bazel-bin/mediapipe/libmediagraph.so /usr/local/lib/libmediagraph.so
|
cp bazel-bin/mediapipe/libmediagraph.so /usr/local/lib/libmediagraph.so
|
||||||
cp mediapipe/mediagraph.h /usr/local/include/mediagraph.h
|
```
|
||||||
|
|
||||||
|
### linking & building
|
||||||
|
|
||||||
|
Navigate to the project directory and create a symbolic link to the `../mediapipe/mediapipe`.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cd ../mediapipe-rs # or the path to your project
|
||||||
|
ln -s ../mediapipe/mediapipe .
|
||||||
```
|
```
|
||||||
|
|
||||||
## usage
|
## usage
|
||||||
|
@ -47,13 +62,7 @@ Add the following to your dependencies list in `Cargo.toml`:
|
||||||
mediapipe = { git = "https://github.com/julesyoungberg/mediapipe-rs" }
|
mediapipe = { git = "https://github.com/julesyoungberg/mediapipe-rs" }
|
||||||
```
|
```
|
||||||
|
|
||||||
Mediapipe relies on tflite files which must be available at `./mediapipe/modules/`. The easiest way to satisfy this is by creating a symbolic link to mediapipe. Run the following command from the project directory.
|
Mediapipe relies on tflite files which must be available at `./mediapipe/modules/`. The easiest way to satisfy this is by creating a symbolic link to mediapipe as explained in the `linking & building` section above.
|
||||||
|
|
||||||
```shell
|
|
||||||
ln -s ../mediapipe/mediapipe .
|
|
||||||
```
|
|
||||||
|
|
||||||
The path to mediapipe may be different depending on where you have cloned it to.
|
|
||||||
|
|
||||||
## examples
|
## examples
|
||||||
|
|
||||||
|
|
2
build.rs
2
build.rs
|
@ -10,7 +10,7 @@ fn main() {
|
||||||
.clang_arg("-std=c++14")
|
.clang_arg("-std=c++14")
|
||||||
.clang_arg("-I/usr/local/include/opencv4")
|
.clang_arg("-I/usr/local/include/opencv4")
|
||||||
.generate_comments(true)
|
.generate_comments(true)
|
||||||
.header("/usr/local/include/mediagraph.h")
|
.header("./mediapipe/mediagraph.h")
|
||||||
.allowlist_function("mediagraph.*")
|
.allowlist_function("mediagraph.*")
|
||||||
.allowlist_type("mediagraph.*")
|
.allowlist_type("mediagraph.*")
|
||||||
.allowlist_var("mediagraph.*")
|
.allowlist_var("mediagraph.*")
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
profiler_config {
|
||||||
|
trace_enabled: true
|
||||||
|
# enable_profiler: true
|
||||||
|
trace_log_interval_count: 200
|
||||||
|
trace_log_path: "/Users/jules/workspace/mediapipe-rs/logs/"
|
||||||
|
}
|
||||||
|
|
||||||
# MediaPipe graph that performs pose tracking with TensorFlow Lite on CPU.
|
# MediaPipe graph that performs pose tracking with TensorFlow Lite on CPU.
|
||||||
|
|
||||||
# CPU buffer. (ImageFrame)
|
# CPU buffer. (ImageFrame)
|
||||||
|
@ -6,17 +13,19 @@ input_stream: "input_video"
|
||||||
# Output image with rendered results. (ImageFrame)
|
# Output image with rendered results. (ImageFrame)
|
||||||
output_stream: "multi_pose_landmarks"
|
output_stream: "multi_pose_landmarks"
|
||||||
|
|
||||||
output_stream: "pose_detections"
|
# output_stream: "pose_detections"
|
||||||
|
|
||||||
output_stream: "roi_from_landmarks"
|
output_stream: "roi_from_landmarks"
|
||||||
|
|
||||||
# Generates side packet to enable segmentation.
|
# Generates side packet to enable segmentation.
|
||||||
node {
|
node {
|
||||||
calculator: "ConstantSidePacketCalculator"
|
calculator: "ConstantSidePacketCalculator"
|
||||||
output_side_packet: "PACKET:enable_segmentation"
|
output_side_packet: "PACKET:0:enable_segmentation"
|
||||||
|
output_side_packet: "PACKET:1:num_poses"
|
||||||
node_options: {
|
node_options: {
|
||||||
[type.googleapis.com/mediapipe.ConstantSidePacketCalculatorOptions]: {
|
[type.googleapis.com/mediapipe.ConstantSidePacketCalculatorOptions]: {
|
||||||
packet { bool_value: true }
|
packet { bool_value: false }
|
||||||
|
packet { int_value: 2 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +43,7 @@ node {
|
||||||
node {
|
node {
|
||||||
calculator: "FlowLimiterCalculator"
|
calculator: "FlowLimiterCalculator"
|
||||||
input_stream: "input_video"
|
input_stream: "input_video"
|
||||||
input_stream: "FINISHED:output_video"
|
input_stream: "FINISHED:roi_from_landmarks"
|
||||||
input_stream_info: {
|
input_stream_info: {
|
||||||
tag_index: "FINISHED"
|
tag_index: "FINISHED"
|
||||||
back_edge: true
|
back_edge: true
|
||||||
|
@ -47,7 +56,8 @@ node {
|
||||||
calculator: "MultiPoseLandmarkCpu"
|
calculator: "MultiPoseLandmarkCpu"
|
||||||
input_side_packet: "ENABLE_SEGMENTATION:enable_segmentation"
|
input_side_packet: "ENABLE_SEGMENTATION:enable_segmentation"
|
||||||
input_stream: "IMAGE:throttled_input_video"
|
input_stream: "IMAGE:throttled_input_video"
|
||||||
|
input_side_packet: "NUM_POSES:num_poses"
|
||||||
output_stream: "LANDMARKS:multi_pose_landmarks"
|
output_stream: "LANDMARKS:multi_pose_landmarks"
|
||||||
output_stream: "DETECTION:pose_detections"
|
# output_stream: "DETECTION:pose_detections"
|
||||||
output_stream: "ROI_FROM_LANDMARKS:roi_from_landmarks"
|
output_stream: "ROI_FROM_LANDMARKS:roi_from_landmarks"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user