I attempted to use TrackerNano with the latest opencv-contrib-python
, I initiated the tracker just as using other dnn-based trackers:
params = cv2.TrackerNano_Params()
params.backbone = 'nanotrack_backbone.onnx' # an onnx file downloaded from the url displayed in (your doc)[https://docs.opencv.org/4.7.0/d8/d69/classcv_1_1TrackerNano.html]
params.neckhead = 'nanotrack_head.onnx'
tracker = cv2.TrackerNano_create(params)
frame = cv2.imread('img.png', cv2.IMREAD_GRAYSCALE) # the image is a grayscale image
cvt_frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2RGB)
box = cv2.selectROI("frame", cvt_frame)
tracker.init(cvt_frame, box)
Everything went fine here, but when I started tracking as below:
for frame in frames:
flag, box = self.tracker.update(cv2.cvtColor(frame, cv2.COLOR_GRAY2RGB))
an error came out:
(-209:Sizes of input arguments do not match) Requested and source matrices have different count of elements in function 'cv::Mat::reshape'
I’m confused what was wrong, could you please tell me the correct way to use TrackerNano
?