| | |
| | | |
| | | 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) |
| | | |
| | | |
| | |
| | | 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) |
| | | |
| | | |
| | |
| | | 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) |
| | |
| | | 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 |