#python #opencv
Вопрос:
Что я упускаю, я получаю эту ошибку. Без сопоставления с брутфорсом я могу видеть ключевые точки. Но когда я пытаюсь сопоставить их с помощью BF, я получаю эту ошибку.
import cv2
import numpy as np
cap = cv2.VideoCapture('2.mp4')
imgt = cv2.imread('a.png')
imgp = cv2.imread('down.jpg')
hT,wT,cT = imgt.shape
imgvideo = cv2.resize(imgp,(wT,hT))
orb = cv2.ORB_create(nfeatures=1000)
kp1, desp1 = orb.detectAndCompute(imgt,None)
imgt = cv2.drawKeypoints(imgt,kp1,None)
while (cap.isOpened()):
# Capture frame-by-frame
ret, frame = cap.read()
#frame = cv2.resize(frame, (540, 380), fx=0, fy=0,
# interpolation=cv2.INTER_CUBIC)
kp2, desp2 = orb.detectAndCompute(frame, None)
#frame = cv2.drawKeypoints(frame, kp2, None)
bf = cv2.BFMatcher()
matches = bf.knnMatch(desp1,desp2,k=2)
good =[]
for m,n in matches:
if m.distance < 0.75 *n.distance:
good.append(m)
print(len(good))
# Display the resulting frame
cv2.imshow('Frame', frame)
cv2.imshow('imagetarget', imgt)
cv2.imshow('imagetarget2', imgvideo)
# define q as the exit button
if cv2.waitKey(25) amp; 0xFF == ord('q'):
break
# release the video capture object
cap.release()
# Closes all the windows currently opened.
cv2.destroyAllWindows()
Ошибка
error: (-215:Assertion failed) type == src2.type() amp;amp; src1.cols == src2.cols amp;amp; (type == CV_32F || type == CV_8U) in function 'cv::batchDistance'