Object tracking jitter

I’m working on an application that crops out relevant bits of a video frames. The cropped photos are then superimposed and further processed, but the problem is that cv2 trackers seem to have a lot of jitter which throws off the other functions because they’re not superimposed properly.

Here’s some code to demonstrate what’s going on.

cv2 Object tracking example

import cv2

tracker = cv2.TrackerCSRT_create()
video = cv2.VideoCapture('project.mp4')
bbox = cv2.selectROI(frame)
ok = tracker.init(frame,bbox)
while True:
    if not ok:
    if ok:
        (x,y,w,h)=[int(v) for v in bbox]
    if cv2.waitKey(1) & 0XFF==27:

To help explain this, I created a video using the same image repeated 100 times or so. There is no movement in the video as the frame change, so the object box ideally wouldn’t be changing.

link to download test video

But you can see if you run the code with that video that the tracker ROI box jitters back and forth every frame despite there being no movement.

Any ideas?

undeclared crosspost:

I made the post in both forums. Do I need to declare this?

it would be the polite thing to do. crossposting (without crosslinking), on the internet, has always been frowned upon for various reasons.

Cross-posting has the potential to waste people’s time both in reading and in responding.