From a9e9e90b0c0a8fa7f0b78b29101a3dc13a021a5d Mon Sep 17 00:00:00 2001
From: pansen <pansen626@sina.com>
Date: 星期五, 04 一月 2019 11:01:50 +0800
Subject: [PATCH] Merge branch 'master' into Develop

---
 QiaoJiaSystem/DataManagerServer/http_configserver.cpp |   88 ++++++++++++++++++++++++++++++++------------
 1 files changed, 64 insertions(+), 24 deletions(-)

diff --git a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp
index eee56d7..65fdc9e 100644
--- a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp
+++ b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp
@@ -2001,27 +2001,11 @@
             auto t_results = m_curlDownloadImg.download_jpeg(const_cast<char *>(img_url.c_str()));
             cvutil.buffer2CvMat(t_results.buffer, image);
         } else if (img_base64.size() > 0) {
-            img_url = "http://";
             auto str_img = base64.Decode(img_base64.c_str(), img_base64.size());
             std::vector<unsigned char> buffer(str_img.size());
             memcpy(buffer.data(), str_img.data(), str_img.size());
             cvutil.buffer2CvMat(buffer, image);
 
-
-            fdfsClient.rwLock.rdlock();
-            if (fdfsClient.fastFds != nullptr) {
-                img_url.append(fdfsClient.fastFds->getIp() + "/");
-                std::string t_strImg = "";
-                if (!fdfsClient.fastFds->uploadFile(buffer, t_strImg, "jpg")) {
-                    img_url = "upload image fail";
-                } else {
-                    img_url.append(t_strImg);
-                    img_url.clear();
-                    img_url = t_strImg;
-//                    img_url.append("/").append(t_strImg);
-                }
-            }
-            fdfsClient.rwLock.unlock();
         } else {
             response->write(SimpleWeb::StatusCode::server_error_not_implemented, "{\"error\":\"not found img\"}");
             return "";
@@ -2046,10 +2030,39 @@
 //            cv::imwrite(str_path, image);
             return "";
 //            return "{\"error\":\"not found face\"}";
+        } else if (faceResults.size() > 1) {
+            response->write(SimpleWeb::StatusCode::server_error_not_implemented, "{\"error\":\" 浠呮敮鎸佸崟浜鸿劯鍥剧墖 \"}");
+            return "";
         }
 
         for (auto &item : faceResults) {
             feature_base64 = base64.Encode(item.feature.data(), item.feature.size());
+
+
+            int x = item.left;
+            int y = item.top;
+            int w = item.width;
+            int h = item.height;
+            cv::Rect t_rect = {x, y, w, h};
+            auto t_image = image(CvUtil::zoomRect(t_rect, 1.5, 1.5) & cv::Rect(0, 0, image.cols, image.rows)).clone();
+            std::vector<uchar> buffer;
+            cvutil.cvMat2Buffer(t_image, buffer);
+            img_url = "http://";
+            fdfsClient.rwLock.rdlock();
+            if (fdfsClient.fastFds != nullptr) {
+                img_url.append(fdfsClient.fastFds->getIp() + "/");
+                std::string t_strImg = "";
+                if (!fdfsClient.fastFds->uploadFile(buffer, t_strImg, "jpg")) {
+                    img_url = "upload image fail";
+                } else {
+                    img_url.append(t_strImg);
+                    img_url.clear();
+                    img_url = t_strImg;
+//                    img_url.append("/").append(t_strImg);
+                }
+            }
+            fdfsClient.rwLock.unlock();
+
         }
         auto size = feature_base64.size();
 //        std::string uuid = "";
@@ -2336,7 +2349,7 @@
             // sub = sub > 3000 ? sub - 3000 : 0000;
             //shijian yuejie buchang
             // sub = sub < 0 ? 0000 : sub;
-            int haomiao = sub % 1000;
+            int haomiao = (sub % 1000) > 50 ? ((sub % 1000) - 50) : 0;
             sub /= 1000;
             int m = sub;
             int shi, fen, miao;
@@ -2345,10 +2358,10 @@
                 shi = m / 3600;
                 fen = m / 60 % 60;
                 miao = m % 60;
-                sprintf(ch_time, "%02d:%02d:%02d.%03d", shi, fen, miao, haomiao);
-                cout << ch_time << endl;
-            } else printf("杈撳叆鏁板�煎お澶�");
+                sprintf(ch_time, "%02d:%02d:%02d.%02d", shi, fen, miao, haomiao / 10);
 
+            } else printf("杈撳叆鏁板�煎お澶�");
+            DBG("ch_time" << ch_time);
             std::string str_time(ch_time);
             //#todo 鎸夌収鏃堕棿鍛藉悕
             std::string str_imgName(AppUtil::getTimeString() + ".jpg");// = "test.jpg";
@@ -2360,7 +2373,7 @@
 
             if (str_time > str_tmpTime) {
                 ERR("{\"error\":\"Time error\"}" << str_time << " str_tmpTime " << str_tmpTime);
-                str_time = str_tmpTime.size() > 0 ? str_tmpTime.substr(0, str_tmpTime.rfind(".")) : str_time;
+                str_time = str_tmpTime.size() > 0 ? str_tmpTime : str_time;
 //            return "{\"error\":\"Time error\"}";
             }
 
@@ -2541,16 +2554,19 @@
                 DBG("path=" << vec[i]);
                 t_FilePath += vec[i] + ".mp4";
                 sub = t - t1;
-                find = true;
+                find = sub < getVideoTime(t_FilePath);
                 break;
             }
 
         } else {
             sub = t - t1;
-            if (t >= t1 && sub <= 3000) {
+            if (t >= t1) {
                 DBG("path=" << vec[i]);
                 t_FilePath += vec[i] + ".mp4";
-                find = true;
+
+                find = sub < getVideoTime(t_FilePath);
+
+                DBG("find:" << find);
                 break;
             }
         }
@@ -2565,6 +2581,30 @@
 
 }
 
+qint64 devHttpServer_c::getVideoTime(const std::string &videoPath) {
+    std::string cmd_getVideoFileTime(
+        " ffmpeg -i '" + videoPath + "' 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//");
+
+    std::string str_tmpTime = AppUtil::getCmdResult(cmd_getVideoFileTime);
+    DBG("str_tmpTime:" << str_tmpTime);//00:00:06.89
+    qint64 len_ms = 0;
+
+    QStringList list = QString::fromStdString(str_tmpTime).split(":");
+    if (list.size() == 3) {
+        len_ms = list[0].toInt() * 60 * 60 * 1000;
+        len_ms += list[1].toInt() * 60 * 1000;
+
+        QStringList s = list[2].split(".");
+        if (s.size() == 2) {
+            len_ms += s[0].toInt() * 1000;
+            len_ms += s[1].toInt() * 10;
+        }
+
+    }
+    DBG("len_ms:" << len_ms);
+    return len_ms;
+}
+
 std::vector<std::string> devHttpServer_c::forEachFile(const std::string &dir_name) {
     std::vector<std::string> v;
     auto dir = opendir(dir_name.data());

--
Gitblit v1.8.0