图片,视频保存完成

This commit is contained in:
2025-11-20 15:46:39 +08:00
parent f6bb0bd55f
commit 0854bcd5ae
2 changed files with 12 additions and 1 deletions

Binary file not shown.

View File

@@ -130,7 +130,9 @@ void saveAlarmImage(const Mat &frame)
{
// 保存路径
string fileName = warningPath + "alarm_" + getCurrentTimeStr() + ".jpg";
imwrite(fileName, frame);
cout << "imgpath = " << fileName << endl;
if (!imwrite(fileName, frame))
cerr << "图片保存失败" << endl;
}
// 保存视频
void saveAlarmVideo(deque<Mat> bufferSnapshot)
@@ -264,6 +266,12 @@ void warnThread()
//刚进入报警状态
isAlarming = true;
setGPIOLevel(alarmLevel);
//保存报警图片
saveAlarmImage(videoDeque.back());
//保存报警视频
saveAlarmVideo(videoDeque);
cout << "保存成功" << endl;
}
}
else
@@ -495,6 +503,9 @@ bool processFrame(VideoCapture &cap, FILE *pipe, Mat &frame, int64 &count, chron
{
lock_guard<mutex> lk(bufferMutex);
videoDeque.push_back(handleFrame);
// 当数量大于 缓存 大小时,移除最旧的一帧
if (videoDeque.size() > MAX_BUFFER_SIZE)
videoDeque.pop_front();
}
// 可选:显示窗口