| 71 | ); |
| 72 | |
| 73 | inline void showHistogramWindow(cv::Mat &b_hist, cv::Mat &g_hist, cv::Mat &r_hist, |
| 74 | std::string window_name) |
| 75 | { |
| 76 | // Draw the histograms for B, G and R |
| 77 | int hist_w = 1024; |
| 78 | int hist_h = 768; |
| 79 | int bin_w = cvRound((double)hist_w/histSize); |
| 80 | |
| 81 | cv::Mat histImage(hist_h, hist_w, CV_8UC3, cv::Scalar(0,0,0)); |
| 82 | |
| 83 | // Normalize the result to [ 0, histImage.rows ] |
| 84 | cv::normalize(b_hist, b_hist, 0, histImage.rows, cv::NORM_MINMAX, -1, cv::Mat()); |
| 85 | cv::normalize(g_hist, g_hist, 0, histImage.rows, cv::NORM_MINMAX, -1, cv::Mat()); |
| 86 | cv::normalize(r_hist, r_hist, 0, histImage.rows, cv::NORM_MINMAX, -1, cv::Mat()); |
| 87 | |
| 88 | // Draw for each channel |
| 89 | for (int i = 1; i < histSize; i++ ) |
| 90 | { |
| 91 | cv::line(histImage, |
| 92 | cv::Point(bin_w*(i-1), hist_h - cvRound(b_hist.at<float>(i-1))), |
| 93 | cv::Point(bin_w*(i), hist_h - cvRound(b_hist.at<float>(i))), |
| 94 | cv::Scalar(255, 0, 0), |
| 95 | 2, |
| 96 | 8, |
| 97 | 0); |
| 98 | |
| 99 | cv::line(histImage, |
| 100 | cv::Point(bin_w*(i-1), hist_h - cvRound(g_hist.at<float>(i-1))), |
| 101 | cv::Point(bin_w*(i), hist_h - cvRound(g_hist.at<float>(i))), |
| 102 | cv::Scalar(0, 255, 0), |
| 103 | 2, |
| 104 | 8, |
| 105 | 0); |
| 106 | |
| 107 | cv::line(histImage, |
| 108 | cv::Point( bin_w*(i-1), hist_h - cvRound(r_hist.at<float>(i-1))), |
| 109 | cv::Point( bin_w*(i), hist_h - cvRound(r_hist.at<float>(i)) ), |
| 110 | cv::Scalar( 0, 0, 255), |
| 111 | 2, |
| 112 | 8, |
| 113 | 0); |
| 114 | } |
| 115 | |
| 116 | // Display |
| 117 | cv::namedWindow(window_name, CV_WINDOW_AUTOSIZE ); |
| 118 | cv::imshow(window_name, histImage ); |
| 119 | } |
| 120 | |
| 121 | //Get the device context |
| 122 | //Create GPU array/vector |
no outgoing calls
no test coverage detected