Hello, stranger!
This article explains self calibration mechanism of turret.
Code of it is here: https://bitbucket.org/m0ntana/selfcalibration
Full size and complete video is here
One of versions of my turret includes moving camera installed above water sprayer. Like this:
![]() |
![]() |
![]() |
Let's assume water sprayer shoots exactly to the center of camera's picture. I'm assuming this just to simplify everything. You should remember - this is just-for-fun project and it's not pretending to solve any real-world tasks.
When turret captures a target at top left corner, for example, it should move itself to specific X,Y angles so the center of the picture points exactly to the target.
But how do we know X,Y axis angles to move camera to, so its center points exactly to the object?
The simplest solution i have is:
You can see automatically generated grid and red lines which represent centers of the picture.
To make things more easy i will calibrate turret to four rectangles only:
top-left, top-right, bottom-left, bottom-right.
You can then spend more time and calibrate every rectangle you have on grid.
But how do we know when center of the pictures is inside of specific rectangle?
OpenCV Tracker
will help us with this.
OpenCV Tracker
allows us to track objects on video. Let's say we detected motion on static picture and we want know to trace this object. We initialize Tracker
for a rectangle of motion detected. Then we apply next new frames to this Tracker
and it gives us updated [x, y, width, height] of rectangle with object we track.
But in the same time there is no difference for Tracker
if object moves and picture is static OR picture moves and object is static. It is still relative movement which can be tracked.
And we can use this for automatic calibration.
The basic algorithm is:
Tracker
for specific rectangle
That's it!
New updates of turret's code are coming soon. Follow my instagram [instagram.com/da.hell.is.this] and youtube