Skip to content

People Live Tracking using YOLOv2 in MATLAB

Notifications You must be signed in to change notification settings

kbitr/Matlab-YOLOv2-LiveTracking

Repository files navigation

YOLOv2 for MatLab

YOLOv2 for Matlab is a fork of the Matlab MEX wrapper Yolomex by Ignacio Rocco with Matlab demos for LED control and people tracking.

screenshot

  • This is using the original darknet framework, so it's meant to run on Unix (OSX/Linux).
  • openMP is not included into gcc in OSX - you can still use your own compiler.
  • Don't be stupid: change paths, if you're using different versions!

Install

0. Clone

git clone --recursive https://github.com/kbitr/matlab-yolov2

1. Edit Makefile

  • Adjust CC path (OSX)
  • CUDA: Set "GPU=1"
  • openMP: Set "OPENMP=1"
make

2. Compile yolomex (in Matlab)

CUDA:

mex -I./darknet/include/ -I./darknet/src CFLAGS='-Wall -Wfatal-errors -Wno-unused-result -fPIC' -L. -lyolo -L/usr/local/cuda/lib64 -lcudart -lcublas -lcurand yolomex.c

CPU:

mex -I./darknet/include/ -I./darknet/src/ -L. -lyolo yolomex.c

4. Run Demo

main*.m

OSX's Clang can't compile openMP?

Well, yeah - just install LLVM.

brew install llvm
  • The following overwrites the mex-compiler config for c-files!
  • It's recommended to store the clang_openmp_maci64.xml in ~/Library/Application Support/MathWorks/MATLAB/R2017b.
  • Adjust path in the below command if necessary
mex -setup:'~/Library/Application Support/MathWorks/MATLAB/R2017b/clang_openmp_maci64.xml' C

Your Matlab crashes when using CUDA?

That happens when your GPU is running out of memory, since Matlab isn't aware of the memory usage. You should reduce the the batch value .cfg-file to a lower multiple of 32. (But other values work as well.)

By the way, for speeding up the detection you can reduce the width and height.