Ask Your Question
0

Error 'module' object has no attribute 'TrackerMIL_create'

asked 2018-10-05 08:38:43 -0600

updated 2020-05-21 06:57:47 -0600

supra56 gravatar image

OpenCV 3.4

Python 2.7

My code:

import cv2
import numpy as np
from datetime import datetime
import time

now = datetime.now()
i=0

cap= cv2.VideoCapture(0);
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out= cv2.VideoWriter('videos/'+str(now)+'.avi', fourcc,20.0,(480,640))

tracker=cv2.TrackerMIL_create()

bbox = (100,100,200,200)

ret, frame = cap.read()

ok=tracker.init(frame,bbox)

My error:

Traceback (most recent call last):
  File "test.py", line 17, in <module>
    tracker=cv2.TrackerMIL_create()
AttributeError: 'module' object has no attribute 'TrackerMIL_create'

hellp me plese.

i'm use python 2.7 because others versions not work in my windows 7

edit retag flag offensive close merge delete

Comments

how did you install it ? (most pre-built cv2's don't have contrib modules)

berak gravatar imageberak ( 2018-10-05 09:00:54 -0600 )edit

I'm install and nothing happen

Marinho112 gravatar imageMarinho112 ( 2018-10-05 09:49:54 -0600 )edit

goto comment 1 (please answer my question)

berak gravatar imageberak ( 2018-10-05 10:01:22 -0600 )edit
1

I tried use the exe file in oficial site, https://opencv.org, i tried using pip , pip3 and conda to.

I saw a lot of videos in youtube but te same erro happening in all cases

Marinho112 gravatar imageMarinho112 ( 2018-10-06 05:46:36 -0600 )edit

ok, the prebuilt opencv package does not have any contrib modules. try again with:

pip install opencv-contrib-python

or go all the way, checkout latest opencv & contrib repos & build from src.

berak gravatar imageberak ( 2018-10-06 05:52:15 -0600 )edit

I already have italled the opencv-contrib-python, i use the lest version for opencv 3.4

Marinho112 gravatar imageMarinho112 ( 2018-10-07 13:37:17 -0600 )edit

do you have more than 1 python installed ? (are you using the right one ?)

berak gravatar imageberak ( 2018-10-08 04:31:21 -0600 )edit

I have only one istallation of python

Marinho112 gravatar imageMarinho112 ( 2018-10-08 06:31:04 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-11-19 20:29:29 -0600

supra56 gravatar image

This should work. Actually the error coming from before lines 17.

video_filename = 'video_{0}.avi'.format(datetime.datetime.now().strftime("%Y-%m-%d"))
out = cv2.VideoWriter(video_filename, fourcc, 20.0, (640,480)) 

Output:
output_2018-19-11.avi
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-10-05 08:38:43 -0600

Seen: 2,180 times

Last updated: May 21 '20