Explorar o código

Fix bug in hepu target calc

qiuyang hai 1 semana
pai
achega
82fa334ba6
Modificáronse 2 ficheiros con 29 adicións e 27 borrados
  1. 2 0
      modules/Hepu/src/Hepu.cpp
  2. 27 27
      plugins/MonitorPlugin/src/MonitorPlugin.cpp

+ 2 - 0
modules/Hepu/src/Hepu.cpp

@@ -274,6 +274,8 @@ namespace gsd{
         HepuTargetMsg.token = this->token_;
         HepuTargetMsg.channelid = 0; //1 for infrared 0 for visible light
         HepuTargetMsg.trackingStatus = 1;//1 for tracking 0 for stop
+        //HepuTargetMsg.size.width = 1920;
+        //HepuTargetMsg.size.height = 1080;
         HepuTargetMsg.response = 0;
         HepuTargetMsg.objectToJson(msg);
         msg+="\r\n";

+ 27 - 27
plugins/MonitorPlugin/src/MonitorPlugin.cpp

@@ -277,20 +277,27 @@ namespace gsd
 
             if(config::getPtr()->Hepu)
             {
-                //find the biggest target
-                double tar_max = 0;
+                int x_center,y_center,w_center,h_center;
+                int dist2mid = 167936;//320*320 + 256*256;
                 for(auto &obj : cnstreamInferData->Objects)
                 {
-                    double size_temp = obj.BBox.w*obj.BBox.w + obj.BBox.h*obj.BBox.h;
-                    if( size_temp >= tar_max)
+                    int x_temp,y_temp;
+                    x_temp = obj.BBox.x * 640;
+                    y_temp = obj.BBox.y * 512;
+                    int dist2mid_temp = pow(x_temp-320,2) + pow(y_temp-256,2);
+                    if(dist2mid_temp <= dist2mid)
                     {
-                        tar_max = size_temp;
-                        target->trackingRect.x = obj.BBox.x * 1920;
-                        target->trackingRect.y = obj.BBox.y * 1080;
-                        target->trackingRect.w = obj.BBox.w * 1920;
-                        target->trackingRect.h = obj.BBox.h * 1080;
+                        x_center = x_temp;
+                        y_center = y_temp;
+                        w_center = obj.BBox.w * 640;
+                        h_center = obj.BBox.h * 512;
+                        dist2mid = dist2mid_temp;
                     }
-                }  
+                }
+                target->trackingRect.x = x_center;
+                target->trackingRect.y = y_center;
+                target->trackingRect.w = w_center;
+                target->trackingRect.h = h_center;
             }
 
             // 获取时间
@@ -345,29 +352,22 @@ namespace gsd
 
             if(config::getPtr()->Hepu)
             {
-                int x_center,y_center,w_center,h_center;
-                int dist2mid = 167936;//320*320 + 256*256;
+                //find the biggest target
+                double tar_max = 0;
                 for(auto &obj : cnstreamInferData->Objects)
                 {
-                    int x_temp,y_temp;
-                    x_temp = obj.BBox.x * 640;
-                    y_temp = obj.BBox.y * 512;
-                    int dist2mid_temp = pow(x_temp-320,2) + pow(y_temp-256,2);
-                    if(dist2mid_temp <= dist2mid)
+                    double size_temp = obj.BBox.w*obj.BBox.w + obj.BBox.h*obj.BBox.h;
+                    if( size_temp >= tar_max)
                     {
-                        x_center = x_temp;
-                        y_center = y_temp;
-                        w_center = obj.BBox.w * 640;
-                        h_center = obj.BBox.h * 512;
-                        dist2mid = dist2mid_temp;
+                        tar_max = size_temp;
+                        target->rect.x = obj.BBox.x * 1920;
+                        target->rect.y = obj.BBox.y * 1080;
+                        target->rect.width = obj.BBox.w * 1920;
+                        target->rect.height = obj.BBox.h * 1080;
                     }
                 }
                 target->size.width = 1920;
-                target->size.height = 1080;
-                target->rect.x = x_center;
-                target->rect.y = y_center;
-                target->rect.width = w_center;
-                target->rect.height = h_center;
+                target->size.height = 1080;  
             }
 
             // 获取时间