AttributeError: 'module' object has no attribute 'boxPoints' in 2.4.9 [closed]

asked 2014-07-09 01:29:34 -0600

Kislay gravatar image

updated 2014-07-09 01:36:59 -0600

berak gravatar image

There has been a previous question asked here (http://answers.opencv.org/question/32183/cv2boxpoints-used-in-tutorials-does-not-exist-in/) but I couldn't get the solution working in my case.

I am trying to use cv2.boxPoints() in python. I am pretty sure OpenCV 2.4.9 does have this method as I compared the files changed in the following pull-request ( https://github.com/Itseez/opencv/pull/1041/commits) regarding the boxPoints and I find all the code rightly placed. Even so, my Vim editor also auto-completes the cv2.boxPoints() method.

But it throws the same error again and again.I have tried using OpenCV 3.0 technical preview too, but it has not helped. If there's anyway in which I can correct this in the current 2.4.9 installed in my system?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by berak
close date 2014-07-09 03:28:23.728687

Comments

I can't find the function in the doc, could you please post a relevant part of your code to help us understand what is wrong?

Mathieu Barnachon gravatar imageMathieu Barnachon ( 2014-07-09 01:38:18 -0600 )edit

Mathieu,

>>> import cv2

>>> cv2.__version__

'3.0.0-dev'

>>> help(cv2.boxPoints)

Help on built-in function boxPoints in module cv2:

boxPoints(...)

boxPoints(box[, points]) -> points

berak gravatar imageberak ( 2014-07-09 01:42:35 -0600 )edit

also, it is definitely not in yesterdays 2.4.9 version, the pr mentioned above is for the master version, not for 2.4

berak gravatar imageberak ( 2014-07-09 01:48:11 -0600 )edit

cv2.drawContours(carsample, contours, -1, (0,255,0), 3)

cv2.imshow("contoured image", carsample)

for i in contours: rect=cv2.minAreaRect(i)

box=cv2.boxPoints(rect)

box=np.int0(box)

cv2.drawContours(carsample, [box], 0, (0,0,255),2)

cv2.waitKey(0)

cv2.destroyAllWindows()

This when run, shows the contoured image correctly. But after that I get this: box=cv2.boxPoints(rect)

AttributeError: 'module' object has no attribute 'boxPoints'

Kislay gravatar imageKislay ( 2014-07-09 01:48:47 -0600 )edit

Thanks @berak, it's helpful indeed, but I mean on the online doc of OpenCV (better to share).

Mathieu Barnachon gravatar imageMathieu Barnachon ( 2014-07-09 01:50:40 -0600 )edit

sorry, yes, here it is: boxpoints

berak gravatar imageberak ( 2014-07-09 01:55:19 -0600 )edit

Kislay, you're bad at loosing ;)

those tutorials apply only to the master version, too.

just accept, that you're out of luck with 2.4.9.

berak gravatar imageberak ( 2014-07-09 02:00:48 -0600 )edit

Hmm... I knew something like this would happen. Thats why I cloned the latest development repo too from Github. Let me build it! That should do, right?

Kislay gravatar imageKislay ( 2014-07-09 02:05:03 -0600 )edit

yes. try git branch first, to see where you are, and git checkout master or git checkout 2.4 to select the version. then run cmake ...

berak gravatar imageberak ( 2014-07-09 02:09:11 -0600 )edit