diff --git a/VideoProsessing/bin/video b/VideoProsessing/bin/video index 4f5147d..879f956 100755 Binary files a/VideoProsessing/bin/video and b/VideoProsessing/bin/video differ diff --git a/VideoProsessing/src/main.cpp b/VideoProsessing/src/main.cpp index 68733e0..dccfb1a 100644 --- a/VideoProsessing/src/main.cpp +++ b/VideoProsessing/src/main.cpp @@ -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 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 lk(bufferMutex); videoDeque.push_back(handleFrame); + // 当数量大于 缓存 大小时,移除最旧的一帧 + if (videoDeque.size() > MAX_BUFFER_SIZE) + videoDeque.pop_front(); } // 可选:显示窗口