我正在尝试使用opencv查找与图像匹配的帧。我还想找到找到图像的时间范围。该视频是一个蒙面视频。到目前为止的代码:
def occurence_counter(self):
img = cv2.imread('ref_img.jpg', cv2.IMREAD_COLOR)
# shrink
img = cv2.resize(img, (10, 10))
# convert to b&w
img = color.rgb2gray(img)
similarities=[]
result=self.parse_video(img,str(self.lineEdit.text()).strip(),1,False)
print result
def parse_video(self,image, video, n_matches, break_point=False,
verbose=False):
similarities = [{'frame': 0, 'similarity': 0}]
frame_count = 0
cap = cv2.VideoCapture(video)
while (cap.isOpened()):
ret, frame = cap.read()
if (type(frame) == type(None)):
break
# increment frame counter
frame_count += 1
# resize current video frame
small_frame = cv2.resize(frame, (10, 10))
# convert to greyscale
small_frame_bw = color.rgb2gray(small_frame)