tag:blogger.com,1999:blog-8183154932516295815.post2053123318785260519..comments2024-03-13T11:35:39.167+05:30Comments on OpenCV-Python: Contours - 1 : Getting Startedabidkhttp://www.blogger.com/profile/02551137580063586047noreply@blogger.comBlogger40125tag:blogger.com,1999:blog-8183154932516295815.post-10034627058987528872013-04-06T05:53:17.218+05:302013-04-06T05:53:17.218+05:30I had the same trouble with this
"cv2.drawCo...I had the same trouble with this <br />"cv2.drawContours(im,contours,-1,(0,255,0),3)<br />TypeError: contours data type = 5 is not supported"<br />Error on python 2.7.3. with opencv 2.4.3.<br /><br />So I installed the newest version 2.4.5. of opencv.<br />Now very thing is working fine :><br /><br /><br />Danielnoreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-19362312738573088602013-03-23T17:52:13.479+05:302013-03-23T17:52:13.479+05:30http://opencvpython.blogspot.com/2013/01/contours-...http://opencvpython.blogspot.com/2013/01/contours-5-hierarchy.htmlabidkhttps://www.blogger.com/profile/02551137580063586047noreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-6972852028058089922013-03-23T01:29:52.041+05:302013-03-23T01:29:52.041+05:30thanks for the tutorial.one question though,the fi...thanks for the tutorial.one question though,the findcontours function returns hierarchy.I checked the documentation and could not comprehend what you could hierarchy for.arjunnoreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-16461839838584390842013-02-25T19:25:19.425+05:302013-02-25T19:25:19.425+05:30I am sorry, I didn't get your question.I am sorry, I didn't get your question.abidkhttps://www.blogger.com/profile/02551137580063586047noreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-55180580030232017012013-02-25T13:27:33.835+05:302013-02-25T13:27:33.835+05:30@Abid Rahman Nice. I have a question though. If I ...@Abid Rahman Nice. I have a question though. If I have many blobs(some have holes while some do not). It will go through a blobs elimination process. How can I retrieve back the blobs with the holes as well?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-60924013060237008642013-02-18T23:26:50.805+05:302013-02-18T23:26:50.805+05:30I don't understand why you got like that? You ...I don't understand why you got like that? You used the same image as above? Then you should get the opposite way, actually.<br />abidkhttps://www.blogger.com/profile/02551137580063586047noreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-78672639331159076712013-02-18T22:35:20.778+05:302013-02-18T22:35:20.778+05:30I copied and pasted your first block of code and s...I copied and pasted your first block of code and set cnt = contours[0]. Why am i getting a different data type?? len(contours) gives 995 and len(cnt) gives 1. Please help thank you!<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-20908281718803101502013-02-13T17:40:03.812+05:302013-02-13T17:40:03.812+05:30ok, sorry for that! btw, great tutorial :)ok, sorry for that! btw, great tutorial :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-25047055127517715282013-02-12T21:02:30.439+05:302013-02-12T21:02:30.439+05:30Read my statement in italics. My goal was to find ...Read my statement in italics. My goal was to find the average color of each shape. so cv2.mean() gives you R,G,B values of each shape. In order to show a shape in particular (as in my animated image), use bitwise_and() and imshow().abidkhttps://www.blogger.com/profile/02551137580063586047noreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-40307529212601666522013-02-12T20:37:23.993+05:302013-02-12T20:37:23.993+05:30then why compute the mean?then why compute the mean?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-11695473972188340002013-02-12T19:24:34.330+05:302013-02-12T19:24:34.330+05:30I think it should be bitwise_and(src,src,mask=mask...I think it should be bitwise_and(src,src,mask=mask)abidkhttps://www.blogger.com/profile/02551137580063586047noreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-58748923306023883122013-02-12T17:47:19.696+05:302013-02-12T17:47:19.696+05:30thank you. in the end bitwise_and(src,mean,mask = ...thank you. in the end bitwise_and(src,mean,mask = mask) worked perfectly.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-1767815761819571512013-02-12T16:37:08.711+05:302013-02-12T16:37:08.711+05:30cv2.imshow() should work. Check my last animated i...cv2.imshow() should work. Check my last animated image. It is created by this way only. Once you created the mask image,use imshow() to display it. Also, use bitwise_and() to perform AND operation between mask and intensity image. It will give you the only shape you want. Display that also.abidkhttps://www.blogger.com/profile/02551137580063586047noreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-12479305894973242352013-02-12T14:46:10.987+05:302013-02-12T14:46:10.987+05:30ok this is clear, then how to display this portion...ok this is clear, then how to display this portion both from the binarized image and from the intensity image? cv2.imshow() does not work. i'm missing something...Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-78610278506054029322013-02-08T16:18:56.649+05:302013-02-08T16:18:56.649+05:30It finds the mean color inside the shape specified...It finds the mean color inside the shape specified by the mask image. ie it calculates the mean of a region in image 'im', where region is specified by the mask image.abidkhttps://www.blogger.com/profile/02551137580063586047noreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-89530658189746063252013-02-08T13:52:52.349+05:302013-02-08T13:52:52.349+05:30what does the last line (mean = cv2.mean(im,mask=m...what does the last line (mean = cv2.mean(im,mask=mask) does?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-10786384321365889672013-02-06T15:28:16.214+05:302013-02-06T15:28:16.214+05:30...and also a cv2.waitkey(0) at the end....and also a cv2.waitkey(0) at the end.ChrisMhttps://www.blogger.com/profile/10839905574659540822noreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-2510025394407689922013-02-06T15:23:28.202+05:302013-02-06T15:23:28.202+05:30I think I found a solution for my problem. I neede...I think I found a solution for my problem. I needed to use cv2.namedWindow, and then cv2.imshow("windowname", im) for the results of the draw functions to display. Thanks again for the tutorial!ChrisMhttps://www.blogger.com/profile/10839905574659540822noreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-7424458006853658152013-02-05T18:53:24.786+05:302013-02-05T18:53:24.786+05:30Hi, thanks for the great tutorial! I also have the...Hi, thanks for the great tutorial! I also have the same issue. It seems like none of the drawing functions produce output. I'm also working with opencv 2.4.2, python 2.7 (32 bit) and Eclipse. Any luck with what this is?ChrisMhttps://www.blogger.com/profile/10839905574659540822noreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-21352826056335813982013-01-25T19:00:11.815+05:302013-01-25T19:00:11.815+05:30Hi, I am not sure why it happens. Can you please s...Hi, I am not sure why it happens. Can you please send me your code and image to my mail : abidrahman2@gmail.com ? abidkhttps://www.blogger.com/profile/02551137580063586047noreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-11612400196144767172013-01-25T17:18:55.369+05:302013-01-25T17:18:55.369+05:30Hi, I have the same problem, cv2.drawContours(im,...Hi, I have the same problem, cv2.drawContours(im,contours,-1,(0,255,0),3) does not produce any output, i have installed OpenCV 2.4.2 and Python 2.7..... Unknownhttps://www.blogger.com/profile/01409164198135673102noreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-91157157838298967982013-01-21T10:31:58.815+05:302013-01-21T10:31:58.815+05:30I can't say it without seeing the image. Anywa...I can't say it without seeing the image. Anyway, for finding contours, it is best to have a black background and white objects. So invert the image. Also, apply threshold before finding contours,especially if image is jpg format.abidkhttps://www.blogger.com/profile/02551137580063586047noreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-75263754454318345622013-01-20T06:22:33.352+05:302013-01-20T06:22:33.352+05:30My image have white background and a 3 drawed sign...My image have white background and a 3 drawed signs find_contour finds 100 hundred objects instead of only 3! I can change any setting or maybe i could change method to retrieve contours? it's better binary images or canny algorithm as first step (i used binary images)?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-37195661891208023372013-01-16T22:43:32.585+05:302013-01-16T22:43:32.585+05:30Of course you can view a binary image with imshow ...Of course you can view a binary image with imshow function. make sure, it has only 1 channel and of datatype= uint8. (you can use img.shape and img.dtype for that)abidkhttps://www.blogger.com/profile/02551137580063586047noreply@blogger.comtag:blogger.com,1999:blog-8183154932516295815.post-55694883804057767142013-01-16T18:03:59.436+05:302013-01-16T18:03:59.436+05:30How can i see binary images? if i execute: cv2.ims...How can i see binary images? if i execute: cv2.imshow('im',im) show up only a gray window!Anonymousnoreply@blogger.com