vivekhsridhar/tracktor

Issue using example video

Closed this issue · 3 comments

Hello,

I have been getting this response when I try to run the 'fish video' example.
is this due to using newer versions of python and opencv?

TypeError Traceback (most recent call last)
Input In [4], in <cell line: 21>()
25 frame = cv2.resize(frame, None, fx = scaling, fy = scaling, interpolation = cv2.INTER_LINEAR)
26 thresh = tr.colour_to_thresh(frame, block_size, offset)
---> 27 final, contours, meas_last, meas_now = tr.detect_and_draw_contours(frame, thresh, meas_last, meas_now, min_area, max_area)
28 row_ind, col_ind = tr.hungarian_algorithm(meas_last, meas_now)
29 final, meas_now, df = tr.reorder_and_draw(final, colours, n_inds, col_ind, meas_now, df, mot, this)

File ~\Documents\tracktor-master\tracktor-master\examples\tracktor.py:81, in detect_and_draw_contours(frame, thresh, meas_last, meas_now, min_area, max_area)
79 area = cv2.contourArea(contours[i])
80 if area < min_area or area > max_area:
---> 81 del contours[i]
82 else:
83 cv2.drawContours(final, contours, i, (0,0,255), 1)

TypeError: 'tuple' object doesn't support item deletion

I have this same issue. Were you able to find the solution? There are a few other errors later too I would guess you had too. I agree that they seem like they may be due to newer versions.

Hello, I found a solution to the problem.

The last time the docs were updated were in July '19 so I rolled back my version of CV2 to one from that period. It seems like Tracktor does not support OpenCV 4.0 or above.

I achieved this by first removing OpenCV. I used pip to install OpenCV, so I typed

pip uninstall opencv-python

into the terminal to uninstall, but you may have to use a different method if you didn't use pip to install.

I then installed OpenCV 3.4.6.27 using

pip install opencv-contrib-python==3.4.6.27 --user

After restarting my kernel, this seemed to work.

Hi all, sorry for the extreme delay. It is hard to manage software as a single individual. As @kostamanser already pointed out, this bug came from an update in OpenCV. That said, it is now fixed and all tracktor examples should run with the newest version of OpenCV