Find the coordinates of the Corners marked with CornerHarris method in OpenCV for python

ⅰ亾dé卋堺 提交于 2019-12-11 07:27:11

问题


I'm trying to find the coordinates of all the shapes that HarrisCorner method marked on my image.

I have it set up so it's marking the correct corners and showing the correct results, but I can't figure out where to find the coordinates after all is said and done. I need a list of all of the corners that are marked by this algorithm so I can find their area, center of gravity, shape, & size. Separately I have a list of all of the pixels contained within each shape, so it would be easy for me to match the coordinates with the corresponding shape. I'm sorry if this is a green question. I've been reading everything I can find. Thank you OpenCV pros!

    im = cv.LoadImage("image.jpg")
    imgray = cv.LoadImage("image.jpg", cv.CV_LOAD_IMAGE_GRAYSCALE)

    cornerMap = cv.CreateMat(im.height, im.width, cv.CV_32FC1)
    cv.CornerHarris(imgray,cornerMap,3)
    for y in range(0,imgray.height):
       for x in range (0, imgray.width):
          harris = cv.Get2D(cornerMap, y, x)
          if harris[0] >10e-06:
              temp = cv.Circle(im, (x,y),2,cv.RGB(115,0,25))

    cv.ShowImage('my window', im)
    cv.SaveImage("newimage3.jpg",im)
    cv.WaitKey()

回答1:


The corners are the (x,y) coordinates for which your corner-ness test passes:

if harris[0] > 10e-06


来源:https://stackoverflow.com/questions/15855409/find-the-coordinates-of-the-corners-marked-with-cornerharris-method-in-opencv-fo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!