一、环境介绍
上一版本的QT+OpenCV例子在这里:https://blog.csdn.net/xiaolong1126626497/article/details/105295367
上一版的代码里,OpenCV的内存释放没有处理好,导致在处理实时视频时,长时间运行内存会持续上升,最终会因为内存不足,导致程序崩溃。
二、核心代码示例
widget.cpp文件代码:
#include "widget.h"
#include "ui_widget.h"
class VideoAudioEncode videoaudioencode_0;
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
//驾驶室摄像头
//工作对象
videoRead_WorkClass_0=new VideoReadThread_0;
videoRead_Workthread_0=new QTh