Browse Source

version 3.5.1 msg: 修复夜间时间判断的bug

Your Name 2 years ago
parent
commit
478603a4a8

+ 3 - 3
modules/InfineFilter/include/InfineFilter.h

@@ -3,8 +3,8 @@
  * @Version: 1.0
  * @Autor: lishengyin
  * @Date: 2022-03-22 14:00:35
- * @LastEditors: lishengyin
- * @LastEditTime: 2022-03-25 09:58:35
+ * @LastEditors: Your Name lishengyin@sz-sunwin.com
+ * @LastEditTime: 2022-05-14 13:44:39
  */
 #ifndef __INFINEFILTER_H_
 #define __INFINEFILTER_H_
@@ -64,7 +64,7 @@ namespace cnstream{
 
         bool filter(cv::Mat image, std::shared_ptr<cnstream::CNInferObject>& object);
         
-        bool getNight(cv::Mat image);
+        bool getNight();
 
         std::string getTime();
 

+ 10 - 8
modules/InfineFilter/src/InfineFilter.cpp

@@ -3,8 +3,8 @@
  * @Version: 1.0
  * @Autor: lishengyin
  * @Date: 2022-03-22 14:00:46
- * @LastEditors: lishengyin
- * @LastEditTime: 2022-03-25 09:56:36
+ * @LastEditors: Your Name lishengyin@sz-sunwin.com
+ * @LastEditTime: 2022-05-15 22:07:45
  */
 #include "InfineFilter.h"
 
@@ -86,6 +86,8 @@ namespace cnstream{
             }
         }
         
+        if(!getNight()) return 0;
+        
         // 过滤星星、月亮、飞机
         for(auto iter = objs_holder->objs_.begin(); iter != objs_holder->objs_.end();){
             std::shared_ptr<cnstream::CNInferObject> object = *iter;
@@ -105,8 +107,6 @@ namespace cnstream{
      * @return {*}
      */    
     bool InfineFilter::filter(cv::Mat image, std::shared_ptr<cnstream::CNInferObject>& object){
-        if(!getNight(image)) return true;
-        
         cv::Mat img = image.clone();
         // 腐蚀
         erode(img, img, cv::Mat());
@@ -161,10 +161,12 @@ namespace cnstream{
      * @param {*}
      * @return {*}
      */    
-    bool InfineFilter::getNight(cv::Mat image){
-        time_t now = time(0);
-        tm *gmtm = gmtime(&now);
-        if(gmtm->tm_hour > this->start ||  gmtm->tm_hour < this->end){
+    bool InfineFilter::getNight(){
+        time_t rawtime;
+        struct tm *info;
+        time(&rawtime);
+        info = localtime(&rawtime);
+        if(info->tm_hour > this->start ||  info->tm_hour < this->end){
             return true;
         }
         return false;

+ 2 - 2
source/cns_launcher/configs/InfineFilter.json

@@ -8,9 +8,9 @@
                 "label":["1"]
             },
             "files": "./output/",
-            "saveFilterResult" : "false",
+            "saveFilterResult" : "true",
             "lock_period":{
-                "start": 21,
+                "start": 20,
                 "end": 6
             }
         }

BIN
source/cns_launcher/object_tracking/output/2022-05-14_05:45:20.jpg


BIN
source/cns_launcher/object_tracking/output/2022-05-14_05:45:21.jpg


BIN
source/cns_launcher/object_tracking/output/2022-05-14_05:45:22.jpg


BIN
source/cns_launcher/object_tracking/output/2022-05-14_05:45:23.jpg