| 77 | } |
| 78 | |
| 79 | void Presenter::run_loop() |
| 80 | { |
| 81 | int width = 640; |
| 82 | int height = 480; |
| 83 | int fps = 30; |
| 84 | |
| 85 | ps3eye_context ctx(width, height, fps); |
| 86 | if (!ctx.hasDevices()) { |
| 87 | printf("No PS3 Eye camera connected\n"); |
| 88 | return; |
| 89 | } |
| 90 | ctx.eye->setFlip(true); |
| 91 | |
| 92 | FaceData d = FaceData(); |
| 93 | |
| 94 | |
| 95 | ctx.eye->start(); |
| 96 | |
| 97 | int video_frame_buff_size = width * height * 3; |
| 98 | uint8_t* video_tex_pixels = new uint8_t[video_frame_buff_size]; |
| 99 | |
| 100 | |
| 101 | cv::Scalar colorR(255, 0, 0); |
| 102 | cv::Scalar color(255, 0, 255); |
| 103 | |
| 104 | double buffer_data[6]; |
| 105 | |
| 106 | while(run) |
| 107 | { |
| 108 | ctx.eye->getFrame(video_tex_pixels); |
| 109 | cv::Mat mat(height, width, CV_8UC3, video_tex_pixels); |
| 110 | |
| 111 | t->predict(mat, d); |
| 112 | |
| 113 | if (d.face_detected) |
| 114 | { |
| 115 | // Paint landmarks |
| 116 | for (int i = 0; i < 66; i++) |
| 117 | { |
| 118 | cv::Point p(d.landmark_coords[2 * i + 1], d.landmark_coords[2 * i]); |
| 119 | cv::circle(mat, p, 2, color, 3); |
| 120 | } |
| 121 | |
| 122 | cv::Point p1(d.face_coords[0], d.face_coords[1]); |
| 123 | cv::Point p2(d.face_coords[2], d.face_coords[3]); |
| 124 | cv::rectangle(mat, p1, p2, colorR, 1); |
| 125 | |
| 126 | //Send data |
| 127 | buffer_data[0] = d.translation[0] * 10; |
| 128 | buffer_data[1] = d.translation[1] * 10; |
| 129 | buffer_data[2] = d.translation[2] * 10; |
| 130 | buffer_data[3] = d.rotation[1]; // Yaw |
| 131 | buffer_data[4] = d.rotation[0]; //Pitch |
| 132 | buffer_data[5] = d.rotation[2]; //Roll |
| 133 | udp_sender->send_data(buffer_data); |
| 134 | } |
| 135 | |
| 136 | cv::cvtColor(mat, mat, cv::COLOR_BGR2RGB); |
nothing calls this directly
no test coverage detected