I'm on lubuntu 16.04, using OpenCV 3.2.0, Python 2.7 and encountering this error after a brief moment of imshow() displaying a window with my camera stream.
This error occurs randomly - the stream can run fine for half a minute before this happens, or it can happen right at the start when I first run the script.
ASSERT: "false" in file qasciikey.cpp, line 495 Aborted (core dumped)
My code appended below:
import numpy as np
import cv2
redcross_cascade = cv2.CascadeClassifier('rcrosscascade.xml')
cap = cv2.VideoCapture(2)
cv2.namedWindow('Haar', cv2.WINDOW_NORMAL)
while 1:
ret, img = cap.read()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
redcross = redcross_cascade.detectMultiScale(gray, 50, 50)
for (x,y,w,h) in redcross:
cv2.rectangle(img,(x,y),(x+w,y+h),(255,255,0),2)
cv2.imshow('Haar',img)
key = cv2.waitKey(1) & 0xff
if key == 27:
break
cap.release()
cv2.destroyAllWindows()
Would appreciate any assistance on this matter, thank you!
EDIT: I have identified the trigger for this error - movement from my usb optical mouse. Disconnecting the mouse prevents the error from resurfacing but I've yet to find a reason for this occurrence.
qasciikey.cpp
, find it is a Qt file. Did you compile OpenCV with flag WITH_QT=ON? Maybe change flag to WITH_QT=OFF, this is not use Qt, will work. – Kinght 金waitKey()
. Without it, I can read images fine. This is not due to mouse movement on my side. – Janos