I am using TrackerCSRT for object tracking in a video, and currently I use the init method on the tracker to set the region of interest:
tracker = cv2.TrackerCSRT_create()
tracker.init(frame, region_of_interest)
The region of interest include my object, but it also include irrelevant pixels from the background or other objects.
I would like to use a mask to refine which pixels I'm interested in. Looking over the documentation, I can see method setInitialMask
on the C++ version, but I cannot find the equivalent method in the Python wrapper.
How do I set a mask in TrackerCSRT on openCV for Python?
i made a Pull Request to enable use of cv::TrackerCSRT::setInitialMask() for Python and Java.
additionally may the following python code will be useful to play with params.
tracker = cv2.TrackerCSRT_create()
tracker.save("default_csrt.xml") // saves default values of the Tracker
you can rename default_csrt.xml-> custom_csrt.xml
and change values in it and use it load params
fs = cv2.FileStorage("custom_csrt.xml",cv2.FILE_STORAGE_READ)
fn = fs.getFirstTopLevelNode()
tracker.read(fn)