Reputation: 25
I am in the middle of using OpenCV along with the WXLibrary to create a Rect object for image processing.
Here is our code for contour in contours:
#print cv2.boundingRect(contour)
#rec = Rect(a)
a= cv2.boundingRect(contour)
rec = wx.Rect(a)
and our error is:
traceback (most recent call last):
File "/home/pi/Desktop/OpenCV(c++).py", line 149, in <module>
processImage()
File "/home/pi/Desktop/OpenCV(c++).py", line 101, in processImage
rec = wx.Rect(a)
File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py", line 1145, in __init__
_core_.Rect_swiginit(self,_core_.new_Rect(*args, **kwargs))
TypeError: in method 'new_Rect', expected argument 1 of type 'int'
Syntax-wise, it seems fine. What is the issue?
Upvotes: 0
Views: 70
Reputation: 1136
wx.Rect's constructor doesn't directly accept the output from OpenCV. Try passing each parameter in separately.
x, y, w, h = cv2.boundingRect(contour)
rect = wx.Rect(x, y, w, h)
Upvotes: 1