Remove key points from edges of an object

asked 2020-04-20 06:46:22 -0600

omar786 gravatar image

I am finding it difficult to remove key points from the given image. I used canny edge detection and contours to detect and draw the edges of the objects in it. Then I used both SIFT and SURF to detect key points in the object. I tried to append the key points in a new list if it's not in the contour but shows an error when I use cv2.drawKeypoints function because the new list is not of type keypoint. This is the work I have done so far. image description image description

import cv2 as cv
import numpy as np 
import matplotlib.pyplot as plt
img = cv.imread(image)
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
edges = cv.Canny(gray, 100,200)
image, contours, hierarchy = cv.findContours(edges, cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)
outimg = cv.drawContours(img, contours, -1, (0,255,0), 3)
sift = cv.xfeatures2d_SIFT.create()
kp, des = sift.detectAndCompute(outimg,None)
k = cv.KeyPoint()
for i in zip(kp1,kp2): 

    (x, y) =i.pt
    dist = cv.pointPolygonTest(contours[0], (x,y), True)
    if dist>=0:
        k1.append(k)

I am pretty new at opencv so please help me out with a solution containing a detailed example. thanks in advance.

edit retag flag offensive close merge delete