| 71 | |
| 72 | #ifdef USE_OPENCV |
| 73 | cv::Mat ReadImageToCVMat(const string& filename, |
| 74 | const int height, const int width, const bool is_color) { |
| 75 | cv::Mat cv_img; |
| 76 | int cv_read_flag = (is_color ? CV_LOAD_IMAGE_COLOR : |
| 77 | CV_LOAD_IMAGE_GRAYSCALE); |
| 78 | cv::Mat cv_img_origin = cv::imread(filename, cv_read_flag); |
| 79 | if (!cv_img_origin.data) { |
| 80 | LOG(ERROR) << "Could not open or find file " << filename; |
| 81 | return cv_img_origin; |
| 82 | } |
| 83 | if (height > 0 && width > 0) { |
| 84 | cv::resize(cv_img_origin, cv_img, cv::Size(width, height)); |
| 85 | } else { |
| 86 | cv_img = cv_img_origin; |
| 87 | } |
| 88 | return cv_img; |
| 89 | } |
| 90 | |
| 91 | cv::Mat ReadImageToCVMat(const string& filename, |
| 92 | const int height, const int width) { |
no outgoing calls