opencv-contour

Drawing a line using centroid point in opencv

送分小仙女□ 提交于 2021-02-10 20:15:26
问题 How do I pass a line through the center of a contour? I have the center coordinates of my contour. 回答1: This is how you solve this question - Original image - Result image - You first need to do basic filtering and find the contour. Then - 1) Find out the area of contour (minAreaRect) 2) Extract points from the contour (BoxPoints) 3) Convert it to a numpy array (np.array) 4) Order the points (perspective.order_points) 5) Take out Top-left, Top-right, Bottom-right and Bottom-left(tl, tr, br,

Detect rectangles in OpenCV (4.2.0) using Python (3.7),

谁都会走 提交于 2021-02-10 09:43:40
问题 I am working on a personal project where I detect rectangles (all the same dimensions) and then place those rectangles inside a list in the same order (top-bottom) and then process the information inside each rectangle using some function. Below is my test image. I have managed to detect the rectangle of interest, however I keep getting other rectangles that I don't want. As you can see I only want the three rectangles with the information (6,9,3) into a list. My code import cv2 width=700

OpenCV shape matching between two similar shapes

和自甴很熟 提交于 2021-02-06 09:18:07
问题 I'm trying to match a slightly irregular shape to a database of shapes. For example, here the contour I'm trying to match: For more information, this is an outline of an HDMI connector, represented as a contour. It is slightly rough as this was taken with a phone while holding the HDMI. This is my database of connectors: HDMI: DVI: 5PinDIN: DB25: These are a lot clearer as these are contours gathered from connector images from the internet. For what I have tried: cv2.matchShapes() Since these

Finding object boundaries which are close to each other

时光总嘲笑我的痴心妄想 提交于 2021-01-27 18:01:06
问题 I am working on a computer vision problem, in which one step in the problem is find the locations where the objects are close to each other. Example, in the image below I am interesting in finding the regions marked in gray. Input : Output : My current approach is to first invert the image, followed by morphological gradient follower by erosion, then removing some non-interesting contours. Script is as follows: img = cv2.imread('mask.jpg', 0) img = (255 - img) kernel = np.ones((11,11), np

How do I detect vertical text with OpenCV for extraction

女生的网名这么多〃 提交于 2021-01-27 07:33:56
问题 I am new to OpenCV and trying to see if I can find a way to detect vertical text for the image attached. In this case on row 3 , I would like to get the bounding box around Original Cost and the amount below ($200,000.00). Similarly I would like to get the bounding box around Amount Existing Liens and the associated amount below. I then would use this data to send to an OCR engine to read text. Traditional OCR engines go line by line and extract and loses the context. Here is what I have

How do i separate overlapping cards from each other using python opencv?

醉酒当歌 提交于 2020-07-20 07:19:28
问题 I am trying to detect playing cards and transform them to get a bird's eye view of the card using python opencv. My code works fine for simple cases but I didn't stop at the simple cases and want to try out more complex ones. I'm having problems finding correct contours for cards.Here's an attached image where I am trying to detect cards and draw contours: My Code: path1 = "F:\\ComputerVisionPrograms\\images\\cards4.jpeg" g = cv2.imread(path1,0) img = cv2.imread(path1) edge = cv2.Canny(g,50

Detect corners of grid

北城余情 提交于 2020-06-28 04:50:08
问题 I am trying to detect the corners of a grid within various pictures I have to process. Images can be skewed and some might be relatively well oriented but we cannot guarantee that all images will be like this. To determine the corners of the grid, I have tried using Hough lines but to no avail. Sometimes the Hough lines don't identify the edge of the grid and it is hard to determine which of the lines drawn belong to the edge of the grid and which of them are grid lines. I then decided to use