chenshijun
2019-06-05 134330d8a9c41d498078a78b87d06086d964d273
multiplayer display
2个文件已修改
18 ■■■■ 已修改文件
code/demo2.py 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code/utils.py 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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)
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