• sara

    hi i want to ask a question can i use this to find goalpost in soccer video ???

    • Eric

      Hey Sara,

      I don’t think it’s a good way to find goalpost using mean shift. It’s nice for tracking object which you already recognized, but can hardly find something new. For your situation, maybe you should extract features of goalpost, as soon as you find it, use mean shift for tracking it.


    • Lakshay Garg

      Try reading about the Hough Line transform

    • hassan

      you must search of morphological operations to find the skeleton(basic shape) of the object. In your case it is a goal post so you shall have a skeleton of that and perform morphological operations for that.You have to work a little.

  • I am using opencv code for mean shift calculation but if the object is not in the screen the program crashes .
    how to solve this?

  • George

    In your code, line 6 includes I(i, j) which is never defined. Bradski calls it the “pixel (probability) value.” How do you calculate it?
    Thank you.

    • Eric

      I edited that code for more clear, yes it is actually a probability map, we can get it by doing Back Projection. Check OpenCV/samples/cpp/camshiftdemo.cpp

  • mohammad

    do have any idea about speed tracking of object in every frame.
    thank you .

    • Eric

      Hi, for speed calculating, we should know the world coordination, means the camera should be calibrated, then we can figure out the speed of objects by project the distance in image into real world coordination (we should also know the time between the two images have been taken, say, 40ms). Maybe LK method can do the distance calculation part well.

  • Shiloh

    Hi, is it possible to use cam shift for multiple objects? Can you explain a little bit what should I do to achieve that?

  • Peerapong

    I want to ask you some question. In case of we have only gray scale image, This algorithm can be processed or can’t? thank you

    • Eric

      Hi Peerapong,

      I think so, because for 3-channel images, we just use the H channel (hue), because for RGB representation, the correlation among the three channels is high; however, by using gray scale image, the correlation thing is not necessarily to be concerned anymore, and we can directly get the histogram of the image, and do back projection.

  • Siraj

    in case of cameshif algorithm, you have colculated only the back projection… but how to use the CamShift algorithm….i have capture vedio from my came and want to trac the face in vedio….how i can do this..???

    • Eric

      Hey Siraj,

      If you are using OpenCV, you may want to check opencv/samples/cpp/camshiftdemo.cpp
      Also, there is python version of the code inside python folders

  • Bruce

    Hi Eric,

    Have you considered the performance difference between the MeanShift and the Camshift?
    From my observation, both of their efficiency is not acceptable. I tried them on my i7, 8G RAM notebook, that’s very slow for tracking. Anyway, I am considering to implement it on GPU. Thanks~

  • eren

    Hi Eric,

    Do you have the implementation of the tutorial code shared? I would like to try it on my own, if it works or not.


  • Fa

    Can I use this for multiple moving object tracking?

  • Nivas

    Hi Eric,
    I want to use mean shift algorithm with Kalman filter for my project. Could you help me out with the source code for mean shift tracking.


  • Bilal

    Hi ii have width ,height and raw intensity of my picture . İ cant understand how to find probmap .Can you help me

  • chetan

    Hi Eric,
    Why only HSV color space.cant we do that in rgb.