Tracking [SOLVED]

Is there any way I can start tracking objects like in Alessandruino´s video or at Instructables?

Don´t need to be facedetect, just would like to be able to track something.

I have set up 2 servos and the camera which is working fine with the Here I get a b/w picture and I can set a black dot to an object. If I move that object the black dot stays on that object but the servos don´t move. Keep getting millions of "limit out of range errors".

Also I would like to know how I get a colored picture. If I change to Pyramid-down I get colors but "no available parameters" anymore.

This is a big puzzle to me but I am learning every day. Thank you for any help.

Alessandruino's picture

Always send No-workt

Always send No-workt mastablasta ! we need to see :)

GroG's picture

One common problem is when

One common problem is when your servos are inverted.  So when a target is being tracked - the servo goes left when it should be going right...

Ale is the guru of inverting servos :)

Now that I say this - it would be nice if Tracking "observed" that it was inverted and would auto-invert if necessary

Mastablasta's picture

New test

I will do a new test soon (incl. invert servos) and send a no-worky if it doesn´t track.

My paradise:


wvantoorn's picture

Nice paradise!! Good looking

Nice paradise!! Good looking multicopters you have! What do you use for flight control? Guess you know your stuff about multirotors, we could learn from you!! Im building a quad copter with megapiratesNG, and want to make it UAV, and going to reflash my turnigy 9x to opensource firmware.

Mastablasta's picture


Thanks, here I usually spend 15 hours every day. So far I only used Dji controllers but I will go for the Arducopter or Megapirat soon. Now that I have started to understand opensource the Arducopter or Megapirat should be the better choice. The A2 controller is a nice piece of work but limited and prices are terrible. Are you happy with the Megapirat?

I´m working on two projects, one autonomous multicopter for life-guards dropping a self-inflating lifejacket for persons in need. Here I would like to learn more about the tracking. So far I need to fly manual or with GPS fix, return to home/land is already autonomous. Also no need for changing batteries as I have a build-in balancer with auto-charge on the ground, purely theoretical 24h operational.

For now I want to learn and understand MRL and how to use and how to do. Just started some weeks ago and I like it a lot. Never thought I would go into programming but it looks more simple than expected. I google a lot but it´s hard to find information about script structure/commands of Python. But things move.

GroG's picture

Great space !  And facinating

Great space ! 

And facinating project - KMC's makerspace is working on a similar - autonomous tracking project 

Although its to locate poachers versus persons in need..

There's a bajillion Python tutorials -  Most probably would be helpful so its hard to recommend something specific.  (I should read through one too)

Mastablasta's picture


Todays technology is amazing. Just a matter how to get all the hard- and software together.

This is a nice one as well:

Should not be too difficult to do.

My second project will be a saftey-system for multicopters. Parachutes exist but only make sense above a certain altitude. The plan is to have a double-airbag-system....lots of work yet to come!

Back to the tracking: I am using the and it started to track, ok only b/w and very slow (LKOpticalTrack). But it´s working!

Mastablasta's picture

again the tracking...

I have sent a no-worky.

Using Was working fine this morning and after that it does not keep any dot. After I click to set the dot the servos move away from that location. Like I have marked an object 50cm away. It moves to all sides, sometimes down, up, left or right. Playing all day with this.

I was using this script:

# a minimal tracking script - this will start all peer
# services and attach everything appropriately
# change parameters depending on your pan tilt, pins and
# Arduino details
# all commented code is not necessary but allows custom
# options

port = "COM4"
xServoPin = 22
yServoPin = 24

tracker = Runtime.createAndStart("tracker", "Tracking")

# set specifics on each Servo
servoX = tracker.getX()
servoX.setMinMax(0, 180)

servoY = tracker.getY()
servoY.setMinMax(0, 180)

# optional filter settings
opencv = tracker.getOpenCV()

# setting camera index to 1 default is 0

# connect to the Arduino

# Gray & PyramidDown make face tracking
# faster - if you dont like these filters - you
# may remove them before you select a tracking type with
# the following command
# tracker.clearPreFilters()

# diffrent types of tracking

# simple face detection and tracking
# tracker.faceDetect()

# lkpoint - click in video stream with
# mouse and it should track

# scans for faces - tracks if found
# tracker.findFace()


Mastablasta's picture


Little advantage if you know where is left and where is right.....

Ok, very slow tracking compared to some videos.

GroG's picture

So now the Y axis is correct?

So now the Y axis is correct?  Where was the trouble?  PID Kp makes the largest difference in tracking speed.

Mastablasta's picture


Somehow I messed up the Y-axis. Now everything looks fine. Pretty good and fast tracking, even follows a laser.

Thanks for your help.

Alessandruino's picture

If you want to play with

If you want to play with filters without borking the video do this :

1) stop capture
2) add or remove some filter
3) capture again

It works for me

Mastablasta's picture


I was trying this possibility as well. After 2 filters the picture starts to freeze. My feling is that my CPU isn´t working properly. These days I will hook up the Arduino to a different CPU.

But the b/w tracking is really working great. I have the Kp at 15 (16 and more it starts shaking) Ki also set at 15, Kd at 0.1. Marked my sunglasses with the dot  and the camera followed fine, I could even jump an make fast moves.

GroG's picture

POST VIDEO ! Elves like


Elves like movies with their popcorn

Mastablasta's picture


Here is a video of the tracking:

Mastablasta's picture

Little tracking test