Close

Compiling openpose & the 1st test

A project log for Auto tracking camera

A camera that tracks a person & counts reps using *AI*.

lion-mclionheadlion mclionhead 12/24/2018 at 07:250 Comments

If you have multiple computer vision projects like lions do, each one was compiled for different versions of opencv & all its dependencies, so you can't have system wide dependencies.  The reason cocoa pods works is it compiles all the dependencies inside the project.  That's really not much of an innovation, but it's a political mountain to convince developers not to use system wide dependencies.  Creating a dependency manager with a meaningless name was all about overcoming the political mountain & legitimizing having dependencies in the project directory.

Most dependencies were already compiled for a previous project & installed in the /root/countreps prefix.  A gootuber recommended another version of openpose based on tensorflow, which might have fewer dependencies.

compiling OpenBLAS for Ryzen:

make TARGET=ZEN
make TARGET=ZEN PREFIX=/root/countreps install

FLOAT in OpenBLAS/common.h conflicts with another definition & has to be

renamed FLOAT_ when compiling openpose.

OpenCV must be built with GTK support.

To build opencv:
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/root/countreps/ ..

make
# this doesn't work
make install
# running this a 2nd time is what installs libopencv.so
make

to build openpose:

mkdir build
cd build
cmake \
-DGPU_MODE=CPU_ONLY \
-DUSE_MKL=n \
-DOpenCV_INCLUDE_DIRS=/root/countreps/include \
-DOpenCV_LIBS_DIR=/root/countreps/lib \
-DCaffe_INCLUDE_DIRS=/root/countreps/include \
-DCaffe_LIBS=/root/countreps/lib/libcaffe.so \
-DBUILD_CAFFE=OFF \
-DPROTOBUF_LIBRARY=/root/countreps/lib \
-DProtobuf_INCLUDE_DIRS=/root/countreps/include \
-DGLOG_INCLUDE_DIR=/root/countreps/include \
-DGLOG_LIBRARY=/root/countreps/lib \
-DGFLAGS_INCLUDE_DIR=/root/countreps/include \
-DGFLAGS_LIBRARY=/root/countreps/lib \
-DCMAKE_INSTALL_PREFIX=/root/countreps/ \
..

To compile openpose:

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/countreps/lib make VERBOSE=1

We have the simplest demo possible:

https://cdn.hackaday.io/files/1629446971396096/countreps.c

https://cdn.hackaday.io/files/1629446971396096/Makefile

to compile countreps:

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/lib make

to run countreps:

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/lib countreps

It reads JPEG photos from test_input & writes output to test_output.

The test program processed 424 frames at 640x480 resolution.

2.15 seconds per frame on the 4.1Ghz Ryzen 7 2700x. 

4 gig of RAM required.

The 1st test brought the same disappointment as encoding MPEG video in 1995, on a 33Mhz computer. It was amazingly good at tracking the subject, but too slow to do it in realtime. The next step would be compiling the CUDA dependencies. It still wouldn't be portable. 

The embedded installations in modern subject tracking cameras all use NVidia TX2 boards at $800.  Maybe there could be a cheaper solution using a laptop.  Just like 1995, the lion kingdom can't afford the required hardware.



Discussions