根据距离标框完成

This commit is contained in:
2025-11-19 11:06:53 +08:00
parent 29c66a752c
commit 8530821351
16 changed files with 12106 additions and 12 deletions

Binary file not shown.

View File

@@ -36,7 +36,7 @@ bp::child net_proc; // 开启网络进程
// 文件设置路径
string filepath = "../../InitAuth/conf/.env";
string cameraPath = "/opt/rknn-yolov11/.env";
// string filepath = "/opt/rknn-yolov11/.env";
// string passwd = "/home/orangepi/InitAuth/pwd/.env";
// 云端Web认证接口
@@ -170,7 +170,7 @@ void getMsgCallback(mqtt::const_message_ptr msg)
string buffer = payload;
if (buffer.empty())
return;
// SET_DISTANCES: 解析 JSON 并更新 cameraPath 文件
// SET_DISTANCES: 解析 JSON 并更新 filepath 文件
if (buffer.find("SET_DISTANCES") != string::npos)
{ //设置报警距离
auto res = nlohmann::json::parse(buffer);
@@ -191,9 +191,9 @@ void getMsgCallback(mqtt::const_message_ptr msg)
double warn = toDouble(warning_json);
double safe = toDouble(safe_json);
ReadFile rf(cameraPath);
ReadFile rf(filepath);
if (!rf.Open()) {
cerr << "文件打开失败: " << cameraPath << "\n";
cerr << "文件打开失败: " << filepath << "\n";
} else {
auto lines = rf.ReadLines();
for (auto &line : lines) {
@@ -208,19 +208,19 @@ void getMsgCallback(mqtt::const_message_ptr msg)
if (i + 1 < lines.size()) out += "\n";
}
rf.Close();
WriteFile wf(cameraPath);
WriteFile wf(filepath);
wf.overwriteText(out);
}
return;
}
// media: 更新 cameraPath 的 MEDIA_* 设置
// media: 更新 filepath 的 MEDIA_* 设置
if (buffer.find("media") != string::npos)
{//设置摄像头参数
CalculateInfo(media, buffer);
ReadFile rf(cameraPath);
ReadFile rf(filepath);
if (!rf.Open()) {
cerr << "文件打开失败: " << cameraPath << "\n";
cerr << "文件打开失败: " << filepath << "\n";
} else {
auto lines = rf.ReadLines();
for (auto &line : lines) {
@@ -235,7 +235,7 @@ void getMsgCallback(mqtt::const_message_ptr msg)
if (i + 1 < lines.size()) out += "\n";
}
rf.Close();
WriteFile wf(cameraPath);
WriteFile wf(filepath);
wf.overwriteText(out);
}
return;