OpenCV is the huge open-source library for computer vision, machine learning, and image processing and now it plays a major role in real-time operation which is very important in today’s systems. By using it, one can process images and videos to identify objects, faces, or even the handwriting of a human.
The idea behind meanshift is that in meanshift algorithm every instance of the video is checked in the form of pixel distribution in that frame. We define an initial window, generally a square or a circle for which the positions are specified by ourself which identifies the area of maximum pixel distribution and tries to keep track of that area in the video so that when the video is running our tracking window also moves towards the region of maximum pixel distribution. The direction of movement depends upon the difference between the center of our tracking window and the centroid of all the k-pixels inside that window.
Meanshift is a very useful method to keep track of a particular object inside a video. Meanshift can separate the static background of a video and the moving foreground object.
1.The tracking windows is tracking the football.
2.The tracking window is tracking the juggling ball.
3.The tracking window is tracking the football player.
Output: Some frames from the output video
Disadvantages of using meanshift
There are 2 main disadvantages of using the Meanshift for object tracking.
- The size of the tracking window remains the same irrespective of the distance of the object from the camera.
- The Window will track the object only when it is in the region of that object. So we must hardcode our position of the window carefully.
- OpenCV - Facial Landmarks and Face Detection using dlib and OpenCV
- Transition from OpenCV 2 to OpenCV 3.x
- OpenCV Python Program to blur an image
- Cartooning an Image using OpenCV - Python
- Opencv Python program for Face Detection
- Real-Time Edge Detection using OpenCV in Python | Canny edge detection method
- OpenCV Python Program to analyze an image using Histogram
- Detection of a specific color(blue here) using OpenCV with Python
- Python Program to detect the edges of an image using OpenCV | Sobel edge detection method
- Erosion and Dilation of images using OpenCV in python
- Line detection in python with OpenCV | Houghline method
- Template matching using OpenCV in Python
- Addition and Blending of images using OpenCV in Python
- Reading an image in OpenCV using Python
- Python | Play a video in reverse mode using OpenCV
- Python | Program to extract frames using OpenCV
- Python | Draw rectangular shape and extract objects using OpenCV
- Opening multiple color windows to capture using OpenCV in Python
- Converting Color video to grayscale using OpenCV in Python
- Python | Play a video using OpenCV
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai