From 134330d8a9c41d498078a78b87d06086d964d273 Mon Sep 17 00:00:00 2001
From: chenshijun <csj_sky@126.com>
Date: 星期三, 05 六月 2019 13:26:15 +0800
Subject: [PATCH] multiplayer display

---
 code/demo2.py |   12 ++++++++++--
 code/utils.py |    6 +++---
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/code/demo2.py b/code/demo2.py
index be61416..16c2c30 100644
--- a/code/demo2.py
+++ b/code/demo2.py
@@ -86,9 +86,12 @@
 
     txt_out = open('/home/basic/code/deep-head-pose/output/images/%s.txt' % 's', 'w')
 
+    yaw_predicted, pitch_predicted, roll_predicted, x_max, x_min, y_max, y_min, bbox_height = (0, 0, 0, 0, 0, 0, 0, 0)
+    frames_parameters = []
+    frames_parameters.append((yaw_predicted, pitch_predicted, roll_predicted, x_max, x_min, y_max, y_min, bbox_height))
     frame_num = 1
     start = time.time()
-    while frame_num <= 10000:
+    while frame_num <= 1000:
         # print(frame_num)
         
         
@@ -99,11 +102,15 @@
         frame = cv2.resize(frame, (1024, 534), interpolation=cv2.INTER_LINEAR)
         if frame_num % 8 != 0:
             frame_num += 1
+            for frames_parameter in frames_parameters:
+                yaw_predicted, pitch_predicted, roll_predicted, x_max, x_min, y_max, y_min, bbox_height = frames_parameter
+                utils.draw_axis(frame, yaw_predicted, pitch_predicted, roll_predicted, tdx = (x_min + x_max)/2, tdy= (y_min + y_max)/2, size = bbox_height*4)
             cv2.imshow("frame", frame)
             if cv2.waitKey(1) & 0xFF == ord('q'):
                 break
             # out.write(frame)
             continue
+        frames_parameters.clear()
         cv2_frame = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
         
          
@@ -152,7 +159,8 @@
                 txt_out.write(str(frame_num) + ' %f %f %f\n' % (yaw_predicted, pitch_predicted, roll_predicted))
                 # utils.plot_pose_cube(frame, yaw_predicted, pitch_predicted, roll_predicted, (x_min + x_max) / 2, (y_min + y_max) / 2, size = bbox_width)
                 # utils.draw_axis(frame, yaw_predicted, pitch_predicted, roll_predicted, tdx = (x_min + x_max) / 2, tdy= (y_min + y_max) / 2, size = bbox_height/2)
-                utils.draw_axis(frame, yaw_predicted, pitch_predicted, roll_predicted, tdx = (x_min + x_max)/2, tdy= (y_min + y_max)/2, size = bbox_height*3)
+                frames_parameters.append((yaw_predicted, pitch_predicted, roll_predicted, x_max, x_min, y_max, y_min, bbox_height))
+                utils.draw_axis(frame, yaw_predicted, pitch_predicted, roll_predicted, tdx = (x_min + x_max)/2, tdy= (y_min + y_max)/2, size = bbox_height*4)
                 # Plot expanded bounding box
                 # cv2.rectangle(frame, (x_min, y_min), (x_max, y_max), (0,255,0), 1)
         cv2.imshow("frame", frame)
diff --git a/code/utils.py b/code/utils.py
index ff98fd3..8276ff6 100644
--- a/code/utils.py
+++ b/code/utils.py
@@ -110,8 +110,8 @@
     x3 = size * (sin(yaw)) + tdx
     y3 = size * (-cos(yaw) * sin(pitch)) + tdy
 
-    cv2.line(img, (int(tdx), int(tdy)), (int(x1),int(y1)),(0,0,255),3)
-    cv2.line(img, (int(tdx), int(tdy)), (int(x2),int(y2)),(0,255,0),3)
-    cv2.line(img, (int(tdx), int(tdy)), (int(x3),int(y3)),(0,0,0),5)
+    cv2.line(img, (int(tdx), int(tdy)), (int(x1),int(y1)),(0, 255, 255),3)
+    cv2.line(img, (int(tdx), int(tdy)), (int(x2),int(y2)),(0,0,255),3)
+    cv2.line(img, (int(tdx), int(tdy)), (int(x3),int(y3)),(0,255,0),3)
 
     return img

--
Gitblit v1.8.0