-
Notifications
You must be signed in to change notification settings - Fork 2.5k
ValueError: not enough values to unpack (expected 3, got 2) #339
Comments
The problem is in this line in maskrcnn-benchmark/demo/predictor.py: _, contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) # fails with error "not enough values to unpack (expected 3, got 2)" Change it to: contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) Restart the kernel and run. Your problem should be fixed |
That's what I have tried and it worked too. Just wondering why expecting a 3rd parameter at all. Cheers for help! |
Hi, This is a problem with your OpenCV version. The current implementation works fine for OpenCV |
@fmassa Hello, |
I also got the above error and fix mentioned above works. However, I am using opencv version '4.0.0' |
@mythrireddy, a simple solution to this problem is to follow the advice of @kishorepv above. |
@kishorepv your solution worked. Thanks man. |
@kishorepv reddy saab , problem solved thanks man, can i have your mail id? |
ret,contours, hierarchy = cv2.findContours(bordered, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) Change it to |
How do I get the modified img in this case then? Does it mean that the source img is modified? |
@AnnMLin, since you are using 4.1.0, the source image is not modified in this case. Take a look at documentation here.
What do you mean by modified image? If you want to modify your input image (in whatever way you choose), you can read each counter from contours and apply it as your wish. I hope this helps. |
@AnnMLin @barrelsrider |
|
@rahesh, you need to remove the "underscore" from relevent file. The solution has been explained in detail above. |
@Rahesh31 bro, refer above discussions you will have clear idea. |
from opencv 4.0 on, contours, find_h = cv2.findContours(im, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
contour_img = np.zeros(im.shape)
cv2.drawContours(contour_img, contours, -1, tuple([255]*im.shape[-1]), 1) contour_img will have only the contours drawn in white |
Tq so much 😊i got it
…On Thu 5 Sep, 2019, 6:17 PM Falcatrua, ***@***.***> wrote:
from opencv 4.0 on,
contours, find_h = cv2.findContours(im, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
contour_img = np.zeros(im.shape)
cv2.drawContours(contour_img, contours, -1, tuple([255]*im.shape[-1]), 1)
contour_img will have only the contours drawn in white
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#339?email_source=notifications&email_token=AM7K3BH5CI67ZN3YB5NGRIDQID5WZA5CNFSM4GPURHUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5666AQ#issuecomment-528346882>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AM7K3BDTCMQDQPOFDJJFIV3QID5WZANCNFSM4GPURHUA>
.
|
just modify L74 to |
Hey sorry for posting on wrong post but really thanks for replying the issue i am getting is solved now!!!!!! |
I had the same issue. Working fine with the above fix. Thanks :D |
thanks dear. its working |
Only this given photo works. If I tried some other photos which have garden in background then it doesn't worked. |
Scalar value for argument 'color' is longer than 4 . this error is showed when used your code |
@fmassa it fixed the problem .thank you |
i changed it to " contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)" in error: OpenCV(4.1.2) C:\projects\opencv-python\opencv\modules\imgproc\src\contours.cpp:197: error: (-210:Unsupported format or combination of formats) [Start]FindContours supports only CV_8UC1 images when mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only in function 'cvStartFindContours_Impl' |
help me anyone |
@fmassa that works thank you |
Error as metioned in facebookresearch/maskrcnn-benchmark#339
---> 34 image, contours, hierarchy= cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE ) ValueError: not enough values to unpack (expected 3, got 2) |
The solution above fixed my problem,thanks a lot! |
@kishorepv Your solution work for me. Thank you. |
|
import cv2 def distance(x1, y1, x2, y2): def find_color1(frame):
def find_color2(frame):
cap = cv2.VideoCapture(0) while(1):
cap.release() error Traceback (most recent call last): Process finished with exit code 1 |
❓ Questions and Help
So I followed the jupyter notebook tutorial and putted the code sequences into one file .
When I compile with python I get this error result:
Traceback (most recent call last):
File "demo.py", line 42, in
predictions = coco_demo.run_on_opencv_image(image)
File "/home/nero/Documents/workspace/github/maskrcnn-benchmark/demo/predictor.py", line 179, in run_on_opencv_image
result = self.overlay_mask(result, top_predictions)
File "/home/nero/Documents/workspace/github/maskrcnn-benchmark/demo/predictor.py", line 292, in overlay_mask
thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE
ValueError: not enough values to unpack (expected 3, got 2)
Seems that the last saved value in predictor.py in overlay_mask() can't be found.. not sure what to do.
Running on Ubuntu 18.04
Cuda 10 & 9.1
The text was updated successfully, but these errors were encountered: