opencv-contour

OpenCV finding corners of contours

╄→гoц情女王★ 提交于 2020-01-06 08:14:20
问题 I am completely new to OpenCV. For practice I decided to do a "Sudoku Solver". So far I was able to do this : public Mat processImage(final Mat originalImage, final CvCameraViewFrame frame) { image = originalImage.clone(); image = frame.gray(); /* We load the image in grayscale mode. We don't want to bother with the colour information, so just skip it. Next, we create a blank image of the same size. This image will hold the actual outer box of puzzle. */ Mat outerBox = new Mat(image.size(),

Find a contour checked in java with openCv

天涯浪子 提交于 2020-01-04 09:16:12
问题 I want my program to input an image (attachment) input and output a string like : Question 1: box 2 checked Question 2: box 1 checked Question 3: box 3 checked Question 4: box 2 checked Etc ... (as many question as I have per image) I can simply locate empty boxes with this program: import java.util.ArrayList; import java.util.List; import org.opencv.core.Core; import org.opencv.core.CvType; import org.opencv.core.Mat; import org.opencv.core.MatOfPoint; import org.opencv.core.Point; import

OpenCV : How to find the pixels inside a contour in c++

放肆的年华 提交于 2020-01-01 05:48:10
问题 Suppose if we are working on an image, is there any way to access the pixels inside the contour? I have already found the contour using the function findContours() and even found the moments but I couldn't find the pixels inside the contour. Any suggestions are Welcome!! Thank you! 回答1: As @Miki already mentioned you can use connectedComponents to perform a labeling. Then you iterate through the bounding box of your object like @Amitay Nachmani suggested. But instead of using pointPolygonTest

Navigate through hierarchy of contours found by FindContours method?

僤鯓⒐⒋嵵緔 提交于 2019-12-30 06:42:47
问题 This must be simple for C++ developers using OpenCV directly. However what I'm using is Emgu (an OpenCV wrapper for .NET) and in the latest version we have the method CvInvoke.FindContours returning void, the output result is passed by parameter reference and is of type VectorOfVectorOfPoint . Here is a simple call: //outputResult is a VectorOfVectorOfPoint CvInvoke.FindContours(inputImage, outputResult, null, RetrType.Tree, ChainApproxMethod.ChainApproxSimple); For RetrType.List mode, we can

segmentation fault in findContours

为君一笑 提交于 2019-12-25 07:05:26
问题 I am getting segmentation fault error during run time for the below code to find contours. I have referred this post on this form but didn't help me much. I got to know there are some issues with findContours This is another issue of findContours. Please check both the links and help me to resolve this error. I don't know why I am getting segmentation fault error. #include "opencv2/objdetect/objdetect.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include

`cv::findContours` method doesn't work properly when detect text regions on white background. (OpenCV)

南笙酒味 提交于 2019-12-24 21:07:13
问题 What problem I face is that when I run the opencv code to detect contours in an image,I can't get inside the boundary of the image and thus the program gets me a contour on the boundary of the image. Mat3b xyres; cvtColor(img, xyres, COLOR_GRAY2BGR); for (int i = 0; i < rects.size(); ++i) { rectangle(xyres, rects[i], Scalar(0, 0, 255), 2); } Size size2(700, 800); resize(xyres, xyres, size2); imshow("XY-Cut Result", xyres); waitKey(); The image output looks something like this: I need

OpenCV draw rectangles around only large contours?

丶灬走出姿态 提交于 2019-12-24 05:44:07
问题 first time posting, hope I put the code in the right way. I'm trying to detect and count vehicles in a video, and so if you look at my code below I find the contours of the image after thresholding and dilating, and then I use drawContours and rectangle to draw a box around the detected contours. I tried to put a filter on the drawContours/rectangle if statement by saying if the area of the rectangle isn't bigger than 40,000, then don't draw it. Now if you look at the picture I attached, you

opencv - plot contours in an image

南笙酒味 提交于 2019-12-23 03:43:08
问题 I am trying to draw contour around an image. I can see that contours being found but I am not able to draw the outline. The color of the contour seem to be either of the two (black and white) colors. import cv2 import numpy as np import matplotlib.pyplot as plt from skimage import io %matplotlib inline im = io.imread('http://matlabtricks.com/images/post-35/man.png') plt.imshow(im) imgray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY) plt.figure() plt.imshow(imgray) #Contoured image ret,thresh = cv2

DrawContours() not working opencv python

心已入冬 提交于 2019-12-23 03:30:29
问题 I was working on the example of finding and drawing contours in opencv python. But when I run the code, I see just a dark window with no contours drawn. I don't know where I am going wrong. The code is: import numpy as np import cv2 im = cv2.imread('test.png') imgray=cv2.cvtColor(im,cv2.COLOR_BGR2GRAY) ret,thresh = cv2.threshold(imgray,127,255,0) image, contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) img=cv2.drawContours(image,contours,0,(0,255,0),3) cv2

Drawing convexHull in openCV2 Python

坚强是说给别人听的谎言 提交于 2019-12-21 20:49:03
问题 So I am trying to draw the convexHull from a contour in python, however when i print the image it is not changing. roi=mask[y:y+h,x:x+w] roi = cv2.fastNlMeansDenoisingColored(roi,None,15,15,7,21) hull = cv2.convexHull(cnt) cv2.drawContours(roi,[hull],0,(147,0,255),2) cv2.imshow(str(i),roi) blank_image[y:y+h,x:x+w] = roi However, the images that show are the exact same if I did not include the code. I looked online, but cannot seem to find the answer. Here is a sample Image: 回答1: I used the