数据已正确填充。但是在执行了2-3次弹出操作之后,我抛出了异常:读取访问冲突m为nullptr错误。您认为是什么原因?
#define bufferSize 60
Mat frame1Current;
vector<Mat> colorImages(4);
deque<Mat> frameQueue9001;
Mat returnImage;
string gst_pipe[] = {
"udpsrc port=9001 caps = application/x-rtp ! rtph264depay ! h264parse ! nvh264dec ! videoconvert ! appsink sync=false"};
void func1() {
videoCap[0] = VideoCapture(gst_pipe[0], CAP_GSTREAMER);
colorImages[0].create(Size(rsSplitWidth, rsSplitHeight), CV_8UC3);
int i = 0;
while (true)
{
videoCap[0].read(frame1Current);
frameQueue9001.push_back(frame1Current.clone());
if (frameQueue9001.size() > bufferSize)
{
colorImages[0] = frameQueue9001.front();
frameQueue9001.pop_front();
checker9001 = true;
i++;
}
}
}
[std::queue.pop()
不检查队列是否为空,如果您尝试弹出一个空队列,它将抛出异常,以防止该使用
if(!frameQueue9001.empty())
{
frameQueue9001.pop_front();
}