Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to capture the coordinates of lines

I’m a newby interested in learning how to use opencv and python programming I’m trying to learn how to capture the coordinates (x and y points) of the start and finish of a grid of vertical and horizontal lines drawing in a picture and then store those coordinates in a text file for use by another program. Outline of Logic;- import cv2 import numpy as np ) Read-in the picture to an image im = cv2.imread ('grid1.jpg') ( the picture can be a simple grid of black lines on a white background, so it may not be necessary to process it to clarify the lines) ) Scan the image find the lines ?? ) Identify, or calculate the coordinates where the vertical and horizontal lines start and end ?? ) Write the coordinate of each intersection, one at a time, into a list ?? ) Write that list to a text file np.savetxt('output_file', list) Can someone show some python code that would do that ?

I’ve started to read about some of the standard opencv library methods, such as the information about SimpleBlobDetector and FeatureDetector¶ provided at

and about moments at python-opencv, finding centroid of an image

but that information is beyond me at the moment ( and some of it is for C++, not for someone learning Python ) My environment is;- Opencv 2.4 Windows 7 Visual Studio 2013 express for Windows Desktop Anaconda Python 2.7

Now, I know that many of you might think the problem is basic, but I believe many newbies trying to get develop an understanding of opencv for Python will appreciate your answers !

Many Thanks for your help