How to capture and record the coordinates of a grid

asked 2014-11-17 10:15:03 -0600

Agribot gravatar image

OpenCV How to capture and record the coordinates of a grid

Hi

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 intersections 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 intersect ??

) 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

I’ve read the information about SimpleBlobDetector and FeatureDetector¶ provided at http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_feature_detectors.html#simpleblobdetector

and about moments at http://docs.opencv.org/doc/tutorials/imgproc/shapedescriptors/moments/moments.html

python-opencv, finding centroid of an image

and http://en.wikipedia.org/wiki/Image_moment#Raw_moments

but that information is beyond me at the moment ( and some of it is for C++, not for someone learning Python )

My environment setting are;- I’m using;- Windows 7 Visual Studio 2013 express for Windows Desktop Anaconda Python 2.7

I think that the answer to this simple question would be useful to many newbies trying to get started with opencv.

Many Thanks for your help !

edit retag flag offensive close merge delete