Reputation: 53
I'm trying to run Python3 code on my Raspberry Pi 3 and I'm getting weird error.
My line is :
contours, hier = cv2.findContours(fgmask, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
Once I'm compiling it on my computer it works great, when I'm compiling it on my Raspberry Pi i'm getting the error :
"valueError: too many values to unpack (expected 2)"
When I'm deleting the " cv2.CHAIN_APPROX_SIMPLE"
I'm getting the error :
"TypeError: Required argument 'method' (pos 3) not found"
Is there any other method to make it work on the Raspberry Pi?
Thank you
Upvotes: 0
Views: 139
Reputation: 18925
My guess would be, that you have varying OpenCV versions on your computer and your Raspberry Pi.
Any OpenCV version before 4.0.0 has the following syntax:
image, contours, hierarchy = cv2.findContours(...)
All OpenCV versions starting from 4.0.0 have that syntax:
contours, hierarchy = cv2.findContours(...)
So, it seems you have some OpenCV 4.x.x on your computer, but for example some OpenCV 3.x.x or even 2.x.x on your Raspberry Pi. If so, you obviously should try to synchronize the used OpenCV versions on both devices.
EDIT: As FlyingTeller already points out in his comment, the actual error is, that cv2.findContours(...)
for any OpenCV version before 4.0.0 generates a tuple of three values, which you try unpack into two variables, which isn't possible. So, it has nothing to do with the number of parameters you provide to cv2.findContours(...)
.
Hope that helps!
Upvotes: 1