Archives: Opencv

Primitive turret automatic tracking

Continuing in my series of developments with the Mech Warfare turret, I’ve now managed to replicate the primitive target tracking functionality I had in the v2 version of the turret.  This works using a pretty simple principle:

  • raspicam is used to read the raspberry pi camera
  • ArUco is used to find any fiducials in view
  • The target closest to the center is deemed, the “active target”
  • The pitch and yaw rate are set based on a simple P controller to bring that target to a known point

This works passably, as shown in the video below:

bazel for opencv

The next level of difficulty in bazel-ifying packages for mjmech was opencv.

First, for the impatient, Apache 2.0 licensed sources are available on github: https://github.com/mjbots/bazel_deps/tree/master/tools/workspace/opencv

OpenCV’s native build system consists of nearly 200 cmake files with over 20,000 total lines of code, plus assorted helper scripts and prototype files which are substituted into.  Fortunately, I didn’t need to support the full complexity of the opencv build system.  Things I didn’t bother to touch: