这是我在opencv中的实时摄像机的代码。
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
# Our operations on the frame come here
# Display the resulting frame
cv2.rectangle(frame, (0,0,int(frame.shape[0]/3),frame.shape[1]),(255,0,0),2)
cv2.rectangle(frame, (int(frame.shape[0]),0,int(frame.shape[0]*(1/3)),frame.shape[1]),(0,0,255),2)
#
# leftPortion = frame[:,0:int(frame.shape[0]/3),:]
# rightPortion = frame[:,int(frame.shape[0]*(3/3)):,:]
# BOXES = detect_hands(frame,graph,sess)
# boxes = predict(BOXES,frame.shape[0],frame.shape[1])
#
# x_min, x_max, y_min, y_max = boxes[0]
# x = int((x_min + x_max) / 2)
# y = int((y_min + y_max) / 2)
# cv2.circle(frame, (x, y), 5, (255,0,0), -1)
# if len(boxes) == 1:
# x_min, x_max, y_min, y_max = boxes[0]
# x = int((x_min + x_max) / 2)
# y = int((y_min + y_max) / 2)
# cv2.circle(frame, (x, y), 20, (255,0,0), -1)
cv2.imshow('window',frame)
if cv2.waitKey(1)==ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
问题是,它运行良好。很好,但是经过一定时间后(每次都不完全相同),相机崩溃,退出代码为-1073741819(0xC0000005)。没有错误,没事。除了笔记本电脑无法检测到相机时的一个注册表编辑设置外,我什至不记得进行任何设置调整,但是后来我恢复了所做的一切。对这个问题有什么解决办法吗?
答案 0 :(得分:1)
如果您在Raspberry Pi上运行它,则在内存已满时它会崩溃,您必须重新加载它才能绕过此错误