4

I'm trying to make a project "Determine velocity 2D of an object using Camera". That's just 2D velocity. I want to use Lucas Kanade algorithm in OpenCV. But I can't distinguish what coner belong to my object, and i can't find the centroid of my object to track ( This is white object place in Black background, this object have any shape, example: square, elip,.. ). How do I track the centroid of the object to determine the distance of the motion? Do I need use Lucas Kanade algorithm to make this project? Please help me.

thongbvt
  • 41
  • 3
  • Try this [link](http://stackoverflow.com/questions/77936/whats-the-best-way-to-calculate-a-3d-or-n-d-centroid). Maybe it will help you. – Afaq Oct 17 '12 at 10:58

1 Answers1

2

To obtain the velocity of an object you need to do two things, firstly you need to detect the object in each image (and condense it to the centroid as you have suggested), secondly you need to associate detected objects across different images. Once you've done that the velocity can be easily calculated by the simple equation of motion velocity = distance/time.

Association is easy if you only detect one object in each image (just assume the detection is the object), although this approach is liable to break in the real world.

Detecting your object is where I believe you are having difficulty. If it really is as simple as a single white object against a solid black background then finding the centroid should be simple, simply average the coordinates of all white pixels. If you have a noisy image, then you will need to do some cleaning up first, for example morphological closing and opening operations to remove small specks of noise.

Chris
  • 8,030
  • 4
  • 37
  • 56
  • Thank Chris. That's a good solution, i think so. Could you help me a question anymore? Someone wants me to use Lucas Kanade algorithm in OpenCV to determine velocity. I read this algorithm very carefully. But I don't understand what's useful of this algorithm in this case?! (sorry for my English) – thongbvt Oct 19 '12 at 18:26
  • 1
    The LK Optical Flow algorithm will track a set of points for you, and this set of tracks will help give you velocity. If you can add some images to your question it may be easier to help further. – Chris Oct 22 '12 at 11:19
  • Thank Chris. Finally, I give up Lucas Kanade algorithm. I done this project in 2013 by combine "Camera calibration", "Kalman filter", "Mean shift tracking" algorithms. – thongbvt Mar 04 '21 at 06:31