Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cv::Mat imread_limitedWidth(cv::String filename, int length_limit, int imread_flag)
- {
- // Load an image
- cv::Mat image = imread(filename, imread_flag);
- if (image.empty())
- {
- std::cerr << "Cannot open image" << std::endl;
- return image;
- }
- // Resize if image length is bigger than 10000 px
- if (image.rows > 1000 | image.cols > 1000)
- {
- std::cout << "imread_resize:: Limit the image size to 1000 px in length" << std::endl;
- double fx = length_limit / static_cast<double>(image.cols);
- double newHeight = static_cast<double>(image.rows) * fx;
- double fy = newHeight / image.rows;
- cv::resize(image, image, cv::Size(0, 0), fx, fy);
- }
- return image;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement