8

I tried running tracking using open CV on python 3.6.6, but it shows:

AttributeError: module 'cv2' has no attribute 'TrackerKCF_create'

I also tried the python 2.7 API, but the same result:

AttributeError: module 'cv2' has no attribute 'Tracker_create'

The Open CV version is 3.4.1.

Any idea how to resolve this?

Thanks in advance.

Edit:

The problem is different to the one asked here. I tried this but it wasn't working for me. However, I solved it and I have given a solution below.

Aditya Singh
  • 603
  • 5
  • 13
  • 1
    Possible duplicate of [How to add "Tracker" in openCV python 2.7](https://stackoverflow.com/questions/42387322/how-to-add-tracker-in-opencv-python-2-7) – Dmitrii Z. Sep 08 '18 at 05:38
  • I have python 3.6.4 and OpenCV 3.4.1 and it works. Can you share your code? `tracker = cv2.TrackerKCF_create()` – Fred Guth Sep 09 '18 at 06:51
  • 2
    @DmitriiZ. I had tried that, and it didn't work. The problem was that there were clashes between opencv and opencv-contrib. I had to completely remove both versions and install opencv-contrib again. – Aditya Singh Sep 22 '18 at 12:30
  • @FredGuth I solved it already, but thanks! – Aditya Singh Sep 22 '18 at 12:31

1 Answers1

10

The issue was that I had installed opencv-python first, and then opencv-contrib-python, which led to them clashing. I removed both of them completely, and reinstalled opencv-contrib-python. That solved it!

Aditya Singh
  • 603
  • 5
  • 13
  • 1
    I wanted to reiterate on this. I had the same issue, but tried only uninstalling the opencv-python. This led to it reading the tracker but none of the other cv2 libraries. You absolutely have to uninstall both packages first, let your IDE update, and THEN install the opencv-contrib-python. – Aspen Nov 05 '18 at 02:11