Ask Your Question
0

cv2 'module' object has no attribute 'Tracker_create'

asked 2018-01-29 08:42:16 -0500

metal_turtle gravatar image

I have followed this tutorial exactly to install python 2.7 and opencv 3 on ubuntu 14.04. https://www.pyimagesearch.com/2015/06...

So my project involves tracking. But when i enter this python code:- tracker = cv2.Tracker_create(tracker_type)

I get an error:- AttributeError: 'module' object has no attribute 'Tracker_create'

Im not sure what is wrong. Can someone please help me?

edit retag flag offensive close merge delete

Comments

"I have followed this tutorial exactly" -- not helpful. we need to know, what you did, not someone else.

also: opencv version ? api changed since 2015

berak gravatar imageberak ( 2018-01-29 08:45:39 -0500 )edit
1

Okay what should I do to show what I have done? I'm quite new to this. I have followed the tutorial and have entered every terminal line. My opencv version is 3.0.0. I have googled for a solution but all the answers say opencv-contrib should be built. I have done that too.

metal_turtle gravatar imagemetal_turtle ( 2018-01-29 08:49:03 -0500 )edit

I have also tried cv.TrackerMIL_create() but that too is not found in the module.

metal_turtle gravatar imagemetal_turtle ( 2018-01-29 08:53:04 -0500 )edit

After typing help(cv2):-

NAME cv2

FILE /home/madan/.virtualenvs/cv/local/lib/python2.7/site-packages/cv2.so

SUBMODULES Error bgsegm bioinspired datasets detail face fisheye flann line_descriptor ml motempl ocl ogl optflow

metal_turtle gravatar imagemetal_turtle ( 2018-01-29 08:57:33 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-03-08 04:28:02 -0500

Hello, I have the same issue. And indeed, it's very frustrating ... I have the latest versions and it doesn't seem to work. Did you manage to solve this?

edit flag offensive delete link more

Comments

Is your version above 3.0.0? I still couldn't install version 3.4. The only solution i know is to delete opencv and install again which again may cause lot of problems.

metal_turtle gravatar imagemetal_turtle ( 2018-03-09 22:08:37 -0500 )edit
0

answered 2018-01-29 08:56:40 -0500

berak gravatar image

updated 2018-01-29 08:58:05 -0500

opencv3.0.0 did not have any python wrappers for the tracking module.

please try with latest 3.4 for both opencv and opencv_contrib. then use it like:

tracker = cv2.TrackerMIL_create()
tracker = cv2.TrackerKCF_create()

etc. you have to construct the resp. class now, not a general "Tracker" instance with a class string.

edit flag offensive delete link more

Comments

Okay thanks! So do I again build everything with the previous opencv 3.0.0 installed? Like I mean should i just type in the terminal:- $ sudo opencv $ git checkout 3.4.0?

metal_turtle gravatar imagemetal_turtle ( 2018-01-29 09:03:18 -0500 )edit

if you downloaded it recently, via git clone, then yes, you can do a git checkout master. (or 3.4, if you want that release)

do that for both opencv and opencv_contrib (don't mix versions !!) and rerun cmake && make && make install.

berak gravatar imageberak ( 2018-01-29 09:07:46 -0500 )edit
1

Thank you. I'm rebuilding it at the moment.

metal_turtle gravatar imagemetal_turtle ( 2018-01-29 09:30:19 -0500 )edit

I have done what you have said. But when i check the opencv version it says "3.0.0":

cv2.__version__ output: '3.0.0'. And the error is still the same. What is the problem now?

I have entered every terminal command starting from git check 3.4.0 for both opencv and opencv_contrib exactly the same as in the tutorial. So how do I use opencv 3.4?

metal_turtle gravatar imagemetal_turtle ( 2018-01-29 11:29:29 -0500 )edit

that's probably the old one. did you run a "make install" ? are there more snakes on your machine ?

look at your python/lib/site-packages folder, compare the timestamp of the cv2.so. you could also try ccopying it manually from opencv/build/lib

berak gravatar imageberak ( 2018-01-29 11:41:43 -0500 )edit

I copied cv2.so from opencv/build/lib to /usr/local/lib/python2.7/site-packages. Still the same issue. Installation is such a frustrating process.

metal_turtle gravatar imagemetal_turtle ( 2018-01-29 12:09:03 -0500 )edit

@carmen.nadrag, please do not post answers here, if you have a question or comment, thank you.

berak gravatar imageberak ( 2018-03-08 04:40:34 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-01-29 08:41:37 -0500

Seen: 10,634 times

Last updated: Jan 29 '18