0
votes

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.

3
Make sure all resources are opened correctly.Kinght 金
@Silencer May I know how I should go about doing that or what I ought to check?hw_gn
I was wrong. You said it run fine at first... Then I search for 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 金
I am using various USB camera modules. This error happens to me reliably with one specific camera, at a specific resolution: 1920x1080.At higher (2048x1536) and lower (1280x720) resolutions it does not happen. It happens after the first waitKey(). Without it, I can read images fine. This is not due to mouse movement on my side.Janos

3 Answers

0
votes

I was receiving this error when I was running my python program (which used cv2) via an SSH terminal. When I ran the program from the machine itself, the error went away. I assume this is due to some X11 issue.

0
votes

I was receiving this error before. Different webcam has different performance. My method is to write the cv2.waitKey function after cv2.imshow function.

-1
votes

I have encountered the same issue. My app is similar to yours. None of the fixes suggested here have worked for me. I found that if I start single stepping in debug mode through the cap.read(), I can continue running a full speed and the problem will go away, although this is not a good fix.