diff --git a/tracker-native/build.sh b/tracker-native/build.sh index fa83d78..0f4c7ff 100755 --- a/tracker-native/build.sh +++ b/tracker-native/build.sh @@ -35,3 +35,10 @@ g++ -std=c++17 -O2 -Wall -Wextra \ -o "${HERE}/build/pipeline_probe" \ -L "${ORT}/lib" -lonnxruntime -Wl,-rpath,"${ORT}/lib" echo "built ${HERE}/build/pipeline_probe" + +g++ -std=c++17 -O2 -Wall -Wextra \ + -I "${ORT}/include" -I "${HERE}/src" \ + "${HERE}/src/pose_estimator.cpp" "${HERE}/src/skel_render_probe.cpp" \ + -o "${HERE}/build/skel_render_probe" \ + -L "${ORT}/lib" -lonnxruntime -Wl,-rpath,"${ORT}/lib" +echo "built ${HERE}/build/skel_render_probe" diff --git a/tracker-native/scripts/render_skeleton.py b/tracker-native/scripts/render_skeleton.py new file mode 100644 index 0000000..04d15f0 --- /dev/null +++ b/tracker-native/scripts/render_skeleton.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +"""Render the tracker's pose skeleton (joints+bones) onto a test image. +Usage: build/skel_render_probe | this maps lm lines -> overlay PNG. + python3 scripts/render_skeleton.py +""" +import struct, sys +from PIL import Image, ImageDraw +rgb_bin, lm_txt, out = sys.argv[1], sys.argv[2], sys.argv[3] +f=open(rgb_bin,'rb'); w,h=struct.unpack('0.5 + d.line([lm[a][:2],lm[b][:2]],fill=(0,255,0) if vis else (130,130,130),width=4) +for i,(x,y,v) in lm.items(): + if i<33: d.ellipse([x-5,y-5,x+5,y+5],fill=(0,255,0) if v>0.5 else (255,160,0),outline=(0,0,0)) +img.save(out); print('wrote',out) diff --git a/tracker-native/src/skel_render_probe.cpp b/tracker-native/src/skel_render_probe.cpp new file mode 100644 index 0000000..a6c9bd7 --- /dev/null +++ b/tracker-native/src/skel_render_probe.cpp @@ -0,0 +1,18 @@ +#include +#include +#include +#include +#include "pose_estimator.h" +using namespace kinect_tracker; +int main(int argc, char** argv){ + const char* model = "models/pose_landmarks_detector.onnx"; + const char* path = argc>1?argv[1]:"/tmp/fullbody_rgb.bin"; + std::ifstream f(path, std::ios::binary); + int32_t w=0,h=0; f.read((char*)&w,4); f.read((char*)&h,4); + std::vector rgb((size_t)w*h*3); f.read((char*)rgb.data(), rgb.size()); + PoseEstimator est(model); + PoseResult r = est.acquire(rgb.data(), w, h); + printf("presence %.4f %dx%d\n", r.presence, w, h); + for(int i=0;i<39;i++) printf("lm %d %.3f %.3f %.4f\n", i, r.image_xy[i*2], r.image_xy[i*2+1], r.visibility[i]); + return 0; +} \ No newline at end of file diff --git a/tracker-native/testdata/fullbody_sample.jpg b/tracker-native/testdata/fullbody_sample.jpg new file mode 100644 index 0000000..c520e35 Binary files /dev/null and b/tracker-native/testdata/fullbody_sample.jpg differ