我正在使用OpenCV(功能检测和匹配算法)在Python中开发对象跟踪解决方案。
跟踪工作正常,需要进行一些调整以提高性能和准确性,但我遇到了错误。该错误只是空白的Segmentation fault
消息,然后是崩溃。
令人沮丧的是,它的字面意义为0,甚至不显示最后一个回调,因此我无法查明此错误的来源。
我只能假定该错误发生在以下代码内的某个地方:
while cap.isOpened():
_, scene = cap.read()
scene = cv2.cvtColor(scene, cv2.COLOR_BGR2GRAY)
# Detecting and computing kps2 and des2
matches = []
# Filling up the matches array
good = []
# Filling up the good array with good matches
if len(good) > MIN_MATCH_COUNT:
# Declaring matchesMask
else:
matchesMask = None
draw_params = dict(matchColor = (0,0,255), singlePointColor = None, matchesMask = matchesMask, flags = 2)
img3 = cv2.drawMatches(sample,kps1,scene,kps2,good,None,**draw_params)
img3 = cv2.resize(img3, (1700, 1000), interpolation=cv2.INTER_AREA)
cv2.imshow("img3", img3)
k = cv2.waitKey(30) & 0xff
if k == ord('q'):
break
不幸的是,我无法共享某些代码,所以我添加了描述代码功能的注释。
我还应该指出,崩溃是随机发生的。它通常在崩溃前运行20秒,但可能会在前5秒或一分钟后崩溃。