I wanted to use some code that I found for detecting the Rubiks cube from this site: cubefinder.py.
After managing to install all the OpenCV libraries, I get this error when I show the cube to the camera:
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
Traceback (most recent call last):
File "C:\Users\user\Desktop\cubefinder.py", line 574, in <module>
cv.Line(sg,pt[0],pt[1],(0,255,0),2)
TypeError: CvPoint argument 'pt1' expects two integers
Edit: Sorry for that big bunch of code, I just saw that this was dumb and unnecessary.
The function
cv.Lineis expecting points to be specified as pairs of integers, but you are passing in pairs of floats. You need to round the points to the closest integer points before passing them tocv.Line. Perhaps with a helper function like this:So then your
becomes
(Another possibility would be to avoid making floating-point coordinates in the first place. But that depends on whether your application needs the extra precision or not.)