[Python] How to use OpenCV cornerSubPix() in Python?

Discussão em 'Python' iniciado por Stack, Dezembro 7, 2024.

  1. Stack

    Stack Membro Participativo

    I'm trying to get and paint corner points in an image. Now, I have a list of tuples with the following format: (row,column,scale) (scale is because I'm using a Gaussian Pyramid), obtained from harrisCornerDetector and nonMaximumSupression process manually. This list is featuresy1.

    My code is the following:

    r,g,b=cv2.split(image)
    criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
    cv2.cornerSubPix( r, featuresy1, (5,5), (-1,1), criteria )


    Where image is an image in grayscale with three identical shapes. As you can see, I'm giving to cornerSubPix as second parameter a structure like this: [(x1,y1,scale1),(x2,y2,scale2),...,(xn,yn,scalen)].

    This is throwing the following error:

    cv2.cornerSubPix( r, featuresy1, (5,5), (-1,1), criteria )
    TypeError: corners is not a numpy array, neither a scalar


    For this reason I wonder what type, format or structure should have featuresy1 to do cornerSubPix() working. Is this the only thing I'm doing wrong? There isn't much documentation about this.

    Thanks!

    Continue reading...

Compartilhe esta Página