opencv-drawcontour

OpenCV 3.0.0 MSER Binary Mask

帅比萌擦擦* 提交于 2019-12-30 06:14:06
问题 I am trying to use MSER algorithm in OpenCV 3.0.0 beta to extract text regions from an image. At the end I need a binary mask with the detected MSER regions, but the algorithm only provides contours. I tried to draw these contours but I don't get the expected result. This is the code I use: void mserExtractor (const Mat& image, Mat& mserOutMask){ Ptr<MSER> mserExtractor = MSER::create(); vector<vector<cv::Point>> mserContours; vector<cv::Rect> mserBbox; mserExtractor->detectRegions(image,

How to detect and draw contours using OpenCV in Python?

此生再无相见时 提交于 2019-12-13 12:32:33
问题 I wrote the following code to detect and draw contours: img = cv2.imread('test2.tif'); if not img is None: imgray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY); ret,thresh = cv2.threshold(imgray,127,255,0); contours,hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE); #draw a three pixel wide outline cv2.drawContours(img,contours,-1,(0,255,0),3); And here is the error I received: Traceback (most recent call last): File "C:/Users/R.K.singh/Desktop/Image processing/intro-to

drawContours around detected document using opencv for android gives strange bug

僤鯓⒐⒋嵵緔 提交于 2019-12-06 13:18:43
问题 I am new to OpenCv4Android. I am trying to auto detect document using OpenCv4Android sdk. Initially i have gone through issue of landscape opencv camera . Somehow i managed to change the orientation of opencv JavaCameraview to portrait. I made following changes in default classes of opencv sdk to orient opencv camera in portrait : 1) In CameraBridgeViewBase class Matrix matrix = new Matrix(); matrix.setRotate(90f); Bitmap bitmap = Bitmap.createBitmap(mCacheBitmap, 0, 0, mCacheBitmap.getWidth(

Python Opencv drawContours fail when I draw just the bigger contour object

≯℡__Kan透↙ 提交于 2019-12-06 12:00:28
问题 I'm trying to draw the contour of the biggest object. First I will show an image drawing all contours: To find the biggest object I used this code: maxsize = 0 best = 0 count = 0 for cnt in contours: if cv2.contourArea(cnt) > maxsize: maxsize = cv2.contourArea(cnt) best = count count += 1 cv2.drawContours(img_rgb, contours[best], -1, (0,0,255), 2) And the result is the next: Why the contours are not connected? Thanks in advance. 回答1: See that on your code you are telling by the -1 parameter

cv2.drawContours() - unfill circles inside characters (Python, OpenCV)

半世苍凉 提交于 2019-12-06 10:47:35
问题 As suggested by @Silencer, I used the code he posted here to draw contours around the numbers in my image. At some point, working with numbers like 0,6,8,9 I saw that their inside contours (the circles) are being filled as well. How can I prevent this ? Is there a min/max area of action to set for cv2.drawContours() so I can exclude the inner area ? I tried to pass cv2.RETR_EXTERNAL but with this parameter only the whole external area is considered. The code is this (again, thanks Silencer.

Issue with drawContours OpenCV c++

霸气de小男生 提交于 2019-12-06 04:20:30
I have a code in python and I am porting it to c++. I am getting a weird issue with drawContours function in OpenCV c++. self.contours[i] = cv2.convexHull(self.contours[i]) cv2.drawContours(self.segments[object], [self.contours[i]], 0, 255, -1) this is the function call in python and the value -1 for the thickness parameter is used for filling the contour and the result looks like I am doing exactly the same in c++, cv::convexHull(cv::Mat(contour), hull); cv::drawContours(this->objectSegments[currentObject], cv::Mat(hull), -1, 255, -1); but this is the resulting image: (please look careful to

drawContours around detected document using opencv for android gives strange bug

爱⌒轻易说出口 提交于 2019-12-04 19:19:05
I am new to OpenCv4Android. I am trying to auto detect document using OpenCv4Android sdk. Initially i have gone through issue of landscape opencv camera . Somehow i managed to change the orientation of opencv JavaCameraview to portrait. I made following changes in default classes of opencv sdk to orient opencv camera in portrait : 1) In CameraBridgeViewBase class Matrix matrix = new Matrix(); matrix.setRotate(90f); Bitmap bitmap = Bitmap.createBitmap(mCacheBitmap, 0, 0, mCacheBitmap.getWidth(), mCacheBitmap.getHeight(), matrix, true); 2) now in drawbitmap method replace above bitmap with

cv2.drawContours() - unfill circles inside characters (Python, OpenCV)

谁说胖子不能爱 提交于 2019-12-04 15:33:18
As suggested by @Silencer, I used the code he posted here to draw contours around the numbers in my image. At some point, working with numbers like 0,6,8,9 I saw that their inside contours (the circles) are being filled as well. How can I prevent this ? Is there a min/max area of action to set for cv2.drawContours() so I can exclude the inner area ? I tried to pass cv2.RETR_EXTERNAL but with this parameter only the whole external area is considered. The code is this (again, thanks Silencer. Was searching for this for months..): import numpy as np import cv2 im = cv2.imread('imgs\\2.png')