AttributeError: 'module' object has no attribute 'boxPoints' in 2.4.9 [closed]
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?
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,
>>> 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
also, it is definitely not in yesterdays 2.4.9 version, the pr mentioned above is for the master version, not for 2.4
cv2.drawContours(carsample, contours, -1, (0,255,0), 3)
cv2.imshow("contoured image", carsample)
for i in contours: rect=cv2.minAreaRect(i)
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'
Thanks @berak, it's helpful indeed, but I mean on the online doc of OpenCV (better to share).
sorry, yes, here it is: boxpoints
http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_imgproc/py_contours/py_contour_features/py_contour_features.html#b-rotated-rectangle.
I was following the above link.
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.
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?
yes. try
git branch
first, to see where you are, andgit checkout master
orgit checkout 2.4
to select the version. then run cmake ...Hey @berak. I tried the master. But now the code breaks even before that. Please check this http://pastebin.com/UCw4Xf32 . Earlier this code was breaking at boxPoints() but now it breaks even before that!!
hmm. your contour seems empty.
are you sure, you're running the correct cv2 version ? (did you run make install or the INSTALL project ?)
i'm getting 'too many values to unpack' at findContours, it should return image, contours, hierarchy in 3.0
tried with the lena img, no problem apart from that.
yeah. By now I have tried the OpenCV 3.0 (as mentioned in the question). In that I was getting the error:"Too many values to unpack". Then I tried the master Now, which breaks even before that. I am doing mkdir build & cd build & cmake .. & make -j7 & sudo make install.
I still have a feeling that 2.4.9 should run this. It is there in its source code and Vim auto-completes it.
Hey @berak. I removed all the builds. Re-installed 2.4.9. Instead of cv2.boxPoints().... I used cv2.cv.BoxPoints() and SUCCESS!!!! It's working like a charm