// #include #include #include #include #include #include "display.h" #include // #include void display_spectral_image(unsigned char *raw_data, long long width, long long height,std::string window_name) { cv::Mat img = cv::Mat(height, width,CV_16U, raw_data); img.convertTo(img, CV_16F); img = img / 4095 * 255; img.convertTo(img, CV_8U); cv::applyColorMap(img, img, cv::COLORMAP_TURBO); cv::namedWindow("Spectral Image", 0); cv::resizeWindow("Spectral Image", width , height ); uint16_t *p = (uint16_t *)raw_data; cv::Vec3b white= img.at(0, 0); white[0]=0; white[1]=0; white[2]=0; int over_exposure_num=0; int max_intensity=0; for(int i=0;i(j,i)=white; over_exposure_num++; } if (*(p+(j*width+i))>max_intensity){ max_intensity=*(p+(j*width+i)); } } } std::string add_text=std::string("Over Exposure:")+std::to_string(over_exposure_num)+std::string(" Max Intensity:")+std::to_string(max_intensity); cv::putText(img,add_text.c_str(),cv::Point(30,400),cv::FONT_HERSHEY_SIMPLEX,1,CV_RGB(255,255,255),1,8); cv::imshow(window_name, img); cv::waitKey(1); } void display_img(cv::Mat img, std::string window_name) { cv::imshow(window_name, img); cv::waitKey(1); // Wait for a keystroke in the window }