Beispiel #1
0
maxStrength = 0.0
threshold = 0.01
nonMaxSize = 3

cv.CornerHarris(img, dst_32f, neighbourhood, aperture, k)

minv, maxv, minl, maxl = cv.MinMaxLoc(dst_32f)

dilated = cv.CloneImage(dst_32f)
cv.Dilate(
    dst_32f, dilated
)  #nos aseguramos que el pixel local su maximo valor no cambia y todos los otros pixeles si

localMax = cv.CreateMat(dst_32f.height, dst_32f.width, cv.CV_8U)
cv.Cmp(
    dst_32f, dilated, localMax, cv.CV_CMP_EQ
)  #comparamos y guardamos solo los pixeles modificados los que son los maximos valores locales que son esquinas

threshold = 0.01 * maxv
cv.Threshold(dst_32f, dst_32f, threshold, 255, cv.CV_THRESH_BINARY)

cornerMap = cv.CreateMat(dst_32f.height, dst_32f.width, cv.CV_8U)
cv.Convert(dst_32f, cornerMap)  #convertir y utilizar la operacion logica AND
cv.And(cornerMap, localMax, cornerMap)  #Borrar todos los pixeles modificados

radius = 3
thickness = 2

l = []
for x in range(cornerMap.height
               ):  # crea la lista de todos los pixeles que no son 0 (no negro)
Beispiel #2
0
maxStrength = 0.0
threshold = 0.01
nonMaxSize = 3

cv.CornerHarris(im, dst_32f, neighbourhood, aperture, k)

minv, maxv, minl, maxl = cv.MinMaxLoc(dst_32f)

dilated = cv.CloneImage(dst_32f)
cv.Dilate(
    dst_32f, dilated
)  # By this way we are sure that pixel with local max value will not be changed, and all the others will

localMax = cv.CreateMat(dst_32f.height, dst_32f.width, cv.CV_8U)
cv.Cmp(
    dst_32f, dilated, localMax, cv.CV_CMP_EQ
)  #compare allow to keep only non modified pixel which are local maximum values which are corners.

threshold = 0.01 * maxv
cv.Threshold(dst_32f, dst_32f, threshold, 255, cv.CV_THRESH_BINARY)

cornerMap = cv.CreateMat(dst_32f.height, dst_32f.width, cv.CV_8U)
cv.Convert(dst_32f, cornerMap)  #Convert to make the and
cv.And(cornerMap, localMax, cornerMap)  #Delete all modified pixels

radius = 3
thickness = 2

l = []
for x in range(
        cornerMap.height
import cv2.cv as cv

capture=cv.CaptureFromCAM(0)

frame1 = cv.QueryFrame(capture)
frame1gray = cv.CreateMat(frame1.height, frame1.width, cv.CV_8U)
cv.CvtColor(frame1, frame1gray, cv.CV_RGB2GRAY)

res = cv.CreateMat(frame1.height, frame1.width, cv.CV_8U)

frame2gray = cv.CreateMat(frame1.height, frame1.width, cv.CV_8U)

while True:
    frame2 = cv.QueryFrame(capture)
    cv.CvtColor(frame2, frame2gray, cv.CV_RGB2GRAY)
    
    cv.Smooth(frame2gray, frame2gray, cv.CV_BLUR, 12,12)
    
    cv.Cmp(frame1gray, frame2gray, res, cv.CV_CMP_EQ) #Call the compare with the tow frames
    
    cv.ShowImage("Image", frame2)
    cv.ShowImage("Res", res)

    cv.Copy(frame2gray, frame1gray)
    c=cv.WaitKey(1)
    if c==27: #Break if user enters 'Esc'.
        break