waitKey(1) freezes display output, is there a fix?
I'm using opencv(4.1.2) with ubuntu(18.04), as I understand my build uses GTK, so it uses that libraries function for reading the keypresses?
My problem now is that when you hold a key down, the frames no longer get drawn on screen. I suspect this has to do with waitkey not getting enough time to do the drawing, but how do you go about solving this?
The reason I want this is to control parameters using key inputs but having a freeze happen when sending many inputs is not preferable.
The code is as follows:
//basic needed classes
#include <iostream>
#include <string>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/opencv.hpp>
#include "opencv2/imgcodecs.hpp"
using namespace cv;
Mat currentFrame;
int main(){
//create gstreamer rtspsrc pipe
std::string pipe = "rtspsrc location=rtsp://192.168.1.113:554/user=admin_password=_channel=1_OSD_stream=1.sdp latency=0 ! decodebin ! videoconvert ! appsink ";
VideoCapture cap = cv::VideoCapture(pipe, cv::CAP_GSTREAMER);
while(true){
cap.grab();
cap.retrieve(currentFrame);
cv::imshow("out", currentFrame);
waitKeyEx(1);
}
return 0;
}
could you show your code ?
I've distilled my code down to the basic things i do and added it, when i hold the keypress down it seems to stop on the current frame and then takes a while to clear the buffer(?) before it can resume
I've updated it again to make it compilable. this is the full code with which i can generate an executable and get the behaviour.
And finally, here's my build-info in case you needed that too https://pastebin.com/THtLdTBd
Link waitKeyEx()
I'm already using waitKeyEx(), if I use waitKeyEx(0) the frames won't get drawn unless I hold down a keypress, but holding down a keypress for too long freezes the display.