diff --git a/src/common.cpp b/src/common.cpp index 36b358d..f7d7fbe 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -224,8 +224,7 @@ bool rdConf(shared_t *share) share->vidExt = "mp4"; share->recLoopWait = false; share->skipCmd = false; - share->statData = string(); - share->stat = stringstream(share->statData); + share->stat = string(); share->network = dnn::readNet("/etc/mow/yolov5s.onnx"); share->classNames = loadClassList(); diff --git a/src/common.h b/src/common.h index 9c3fe5e..7a42f38 100644 --- a/src/common.h +++ b/src/common.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -36,14 +35,13 @@ using namespace std; using namespace std::filesystem; #define BUF_SZ 10 -#define APP_VER "1.4.t2" +#define APP_VER "1.4.t3" struct shared_t { - stringstream stat; vector classNames; dnn::Net network; - string statData; + string stat; string recordUrl; string outDir; string postCmd; diff --git a/src/main.cpp b/src/main.cpp index ca1ad6e..d787802 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -74,7 +74,7 @@ void recLoop(shared_t *share) ofstream file(string(cleanDir(share->buffDir) + "/stat").c_str()); - file << share->statData; + file << share->stat; file.close(); diff --git a/src/mo_detect.cpp b/src/mo_detect.cpp index adfb8c3..15653d4 100644 --- a/src/mo_detect.cpp +++ b/src/mo_detect.cpp @@ -90,7 +90,11 @@ bool imgDiff(Mat prev, Mat next, Rect *block, shared_t *share) { // out of all of the results returned form the threads, pick // the block with the highest amount of pixDiff. - share->stat << "block_thread:" << " x=" << results[i].x << " y=" << results[i].y << " pixdiff=" << results[i].pixDiff << endl; + auto x = results[i].x; + auto y = results[i].y; + auto diff = results[i].pixDiff; + + share->stat += "block_thread:" + string(" x=") + to_string(x) + " y=" + to_string(y) + " pixdiff=" + to_string(diff) + "\n"; if ((results[i].pixDiff >= share->blockThresh) && (results[i].pixDiff > maxPixDiff)) { diff --git a/src/obj_detect.cpp b/src/obj_detect.cpp index 2a3b367..0214fdc 100644 --- a/src/obj_detect.cpp +++ b/src/obj_detect.cpp @@ -28,8 +28,8 @@ bool objectInImage(const Mat &src, const Rect &area, shared_t *share) float *data = (float *)outputs[0].data; - share->stat << "object_detection---" << endl; - share->stat << " outputs_size=" << outputs.size() << " looking_for_objects..." << endl; + share->stat += "object_detection---\n"; + share->stat += " outputs_size=" + to_string(outputs.size()) + " looking_for_objects...\n"; for (int i = 0; i < 25200; ++i) { @@ -44,12 +44,12 @@ bool objectInImage(const Mat &src, const Rect &area, shared_t *share) minMaxLoc(scores, 0, &maxClassScore, 0, &classId); - share->stat << " potential_object[confidence_level]=" << data[4] << endl; - share->stat << " potential_object[class_score]=" << maxClassScore << endl; + share->stat += " potential_object[confidence_level]=" + to_string(data[4]) + "\n"; + share->stat += " potential_object[class_score]=" + to_string(maxClassScore) + "\n"; if (maxClassScore > 0.2) { - share->stat << " object_confirmed" << endl; + share->stat += " object_confirmed\n"; return true; } @@ -58,7 +58,7 @@ bool objectInImage(const Mat &src, const Rect &area, shared_t *share) data += 85; } - share->stat << " no_objects_found" << endl; + share->stat += " no_objects_found\n"; return false; }