| 2090 | } |
| 2091 | |
| 2092 | int rtcpm() { |
| 2093 | const auto timer_begin = std::chrono::high_resolution_clock::now(); |
| 2094 | |
| 2095 | // Opening processing deep net threads |
| 2096 | pthread_t gpu_threads_pool[NUM_GPU]; |
| 2097 | for(int gpu = 0; gpu < NUM_GPU; gpu++) { |
| 2098 | int *arg = new int[1]; |
| 2099 | *arg = gpu+_start_device; |
| 2100 | int rc = pthread_create(&gpu_threads_pool[gpu], NULL, processFrame, |
| 2101 | (void *) arg); |
| 2102 | if (rc) { |
| 2103 | LOG(ERROR) << "Error:unable to create thread," << rc << "\n"; |
| 2104 | return -1; |
| 2105 | } |
| 2106 | } |
| 2107 | LOG(INFO) << "Finish spawning " << NUM_GPU << " threads." << "\n"; |
| 2108 | |
| 2109 | // Setting output resolution |
| 2110 | if (!_no_display) { |
| 2111 | cv::namedWindow("video", CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO); |
| 2112 | if (_fullscreen) { |
| 2113 | cv::resizeWindow("video", 1920, 1080); |
| 2114 | cv::setWindowProperty("video", CV_WND_PROP_FULLSCREEN, |
| 2115 | CV_WINDOW_FULLSCREEN); |
| 2116 | global.uistate.is_fullscreen = true; |
| 2117 | } else { |
| 2118 | cv::resizeWindow("video", DISPLAY_RESOLUTION_WIDTH, |
| 2119 | DISPLAY_RESOLUTION_HEIGHT); |
| 2120 | cv::setWindowProperty("video", CV_WND_PROP_FULLSCREEN, CV_WINDOW_NORMAL); |
| 2121 | global.uistate.is_fullscreen = false; |
| 2122 | } |
| 2123 | #if DEBUG > 0 |
| 2124 | cv::namedWindow("video2", CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO); |
| 2125 | if (_fullscreen) { |
| 2126 | cv::resizeWindow("video2", 1920, 1080); |
| 2127 | cv::setWindowProperty("video2", CV_WND_PROP_FULLSCREEN, |
| 2128 | CV_WINDOW_FULLSCREEN); |
| 2129 | global.uistate.is_fullscreen = true; |
| 2130 | } else { |
| 2131 | cv::resizeWindow("video2", DISPLAY_RESOLUTION_WIDTH, |
| 2132 | DISPLAY_RESOLUTION_HEIGHT); |
| 2133 | cv::setWindowProperty("video2", CV_WND_PROP_FULLSCREEN, CV_WINDOW_NORMAL); |
| 2134 | global.uistate.is_fullscreen = false; |
| 2135 | } |
| 2136 | #endif |
| 2137 | } |
| 2138 | // Openning frames producer (e.g. video, webcam) threads |
| 2139 | usleep(3 * 1e6); |
| 2140 | int thread_pool_size = 1; |
| 2141 | pthread_t threads_pool[thread_pool_size]; |
| 2142 | for(int i = 0; i < thread_pool_size; i++) { |
| 2143 | int *arg = new int[i]; |
| 2144 | int rc = pthread_create(&threads_pool[i], NULL, getFrames, (void *) arg); |
| 2145 | if (rc) { |
| 2146 | LOG(ERROR) << "Error: unable to create thread," << rc << "\n"; |
| 2147 | return -1; |
| 2148 | } |
| 2149 | } |