一些优化,待测试,Readme编写

This commit is contained in:
2025-11-20 16:24:15 +08:00
parent 0854bcd5ae
commit 914e208513
8 changed files with 85 additions and 18 deletions

Binary file not shown.

View File

@@ -8,6 +8,8 @@
#include <iostream>
#include <mqtt/async_client.h> //和App进行MQTT数据交互
#include <boost/process.hpp>
#include <mutex>
#include <condition_variable>
#include <nlohmann/json.hpp> //用于操作JSON文件
@@ -27,8 +29,10 @@ const string TopicRecv = "/bsd_camera/cmd"; // 接收手机传来的信息
const string TopicSend = "/bsd_camera/init"; // 发送的话题
const int Qos = 1;
atomic<bool> isRunning(true);
atomic<bool> isRunning(true); // 是否需要激活
atomic<bool> Deactivate(false); // 激活标志
mutex runMutex;
condition_variable runCv; // 条件变量,判断是否可以启动验证程序
mqtt::async_client client(mqtt_url, clientId);
@@ -65,17 +69,23 @@ int main()
// 初始化MQTT
mqttInit();
while (isRunning)
{
this_thread::sleep_for(1s); // 防止系统占用过高
}
unique_lock<mutex> lk(runMutex);
runCv.wait(lk, []()
{ return !isRunning.load(); });
// while (isRunning)
// {
// this_thread::sleep_for(1s); // 防止系统占用过高
// }
return 0;
}
// 退出程序,开始进行设备验证
void StartCheck()
{
isRunning = false; // 退出程序
// 退出程序
isRunning = false;
runCv.notify_one();
string cmd = "../../softWareInit/bin/wifi ";
system(cmd.c_str());
}
@@ -160,6 +170,7 @@ void messageCallback(mqtt::const_message_ptr msg)
if (Deactivate)
{ // 已激活
// 启动验证程序
StartCheck();
}
}

View File

@@ -7,6 +7,11 @@ ServerPwd:"17227ca72f30f8bca8158bb78f25b43e"
#以下配置存储GPIO输出高低电平--状态机
outPutMode:false
#以下配置保存摄像头的翻转和镜像
MEDIA_MIRROR=false
MEDIA_FLIP=false
#以下配置存储报警距离
NEAR_THRESHOLD=3
MID_THRESHOLD=5

44
Readme Normal file
View File

@@ -0,0 +1,44 @@
# 程序清单
## DeviceActivate(待测试)
功能:
本程序用于设备激活
当检测配置文件发现设备未激活时,则系统阻塞
进行激活,并保存密文
当检测到设备已被激活后,启动验证程序,并退出本程序
## softWareInit(待测试)
功能:
本程序用于设备验证
验证通过执行以下功能:
1.启动RTSP推流
2.启动上传服务,用于上传最新报警图片
3.启动mqtt,与App进行数据交互,设定报警等参数
认证失败则会退出程序
## GetNet
功能:
初始化4G模块,用于网络连接
## GPIOSignal
功能:
用于输出高低电平,提供报警信号
## PyApp
功能:
上传服务,用于检测是否存在最新图片,以进行上传报警图片服务服务
通过设备验证后,由StartService进行启动
## StartService
功能:
启动上传服务
## StartService
功能:
本程序用于视频分流
1.推流摄像头画面,使用UDP原生协议进行推流,交由YOLO模型进行处理
2.接收YOLO传来的坐标和度数据
3.根据获取到的数据绘制边框和相应数据
4.根据距离信息进行报警和图片视频保存
5.输出处理完毕的视频帧

View File

@@ -1,5 +1,5 @@
#开启pubimg.service
#开启pubimg.service,上传最新的照片至服务器
sudo systemctl start pubimg.service
#开启fastapi
sudo systemctl start fastApi.service
# #开启fastapi
# sudo systemctl start fastApi.service

View File

@@ -4,7 +4,7 @@
2.接收YOLO传来的坐标和度数据
3.根据获取到的数据绘制边框和相应数据
4.根据距离信息进行报警和图片视频保存
5.将绘制完毕的视频流继续推流至RTSP服务器用于输出
5.输出处理完毕的视频
*/
#include <iostream>

Binary file not shown.

View File

@@ -2,9 +2,8 @@
本程序用于设备验证
验证通过执行以下功能:
1.启动RTSP推流
2.启动系统各项服务,用于和双目交互
2.启动上传服务,用于上传最新报警图片
3.启动mqtt,与App进行数据交互
认证失败则会退出程序
*/
@@ -18,6 +17,8 @@
#include <boost/process.hpp>
#include <nlohmann/json.hpp>
#include <mutex>
#include <condition_variable>
#include "Netra.hpp"
#include "NetRequest.hpp"
@@ -48,6 +49,8 @@ const int Qos = 1;
std::atomic<bool> isRunning(true); // 全局运行标志
std::atomic<bool> confirm(true); // 发送卡和ID
condition_variable runCv;
mutex runMutex;
// 媒体对象
struct Media
@@ -120,7 +123,7 @@ int main(int argc, char *argv[])
// 初始化mqtt
mqttInit();
// 开启系统服务
// 开启系统服务(上传图片服务)
thread(StartService).detach();
// 开启推流服务器
@@ -130,10 +133,14 @@ int main(int argc, char *argv[])
// 进行RTSP视频推流
thread video(VideoStream);
while (isRunning)
{
this_thread::sleep_for(1s); // 防止mpu沾满
}
unique_lock<mutex> lk(runMutex);
runCv.wait(lk, []()
{ return !isRunning; });
// while (isRunning)
// {
// this_thread::sleep_for(1s);
// }
// Processing.join();
video.join();
@@ -372,7 +379,7 @@ void OpenRTSP()
rtsp_proc = bp::child("/bin/bash", bp::args = {"-c", commnd});
}
// 视频推流
// 视频推流:推流桌面
void VideoStream()
{
// 静音ffmpeg的统计输出保留错误避免污染日志