-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Wrong destination size deduction in cv::gapi::resize. #19379
Copy link
Copy link
Closed
Description
System information (version)
- OpenCV => 4.5.1
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2019
Detailed description
When using cv::gapi::resize with empty size parameter, the destination size is sometimes miscalculated, resulting in unexpected reallocations during cv::GCalculation::apply.
Usually it happens, if a scale factor times an image dimension size hits a x.5-ish border, e.g. width = 13 and fx = 0.5.
Steps to reproduce
#include <iostream>
#include "opencv2/gapi.hpp"
#include "opencv2/gapi/core.hpp"
#include "opencv2/gapi/imgproc.hpp"
cv::Mat exec_gapi(cv::Mat img_in) {
cv::Mat img_out;
// Set up scale graph, just 1 resize step.
cv::GMat scale_in;
auto scale_out = cv::gapi::resize(scale_in, cv::Size(), 1.0, 0.5);
cv::GComputation computation(scale_in, scale_out);
try {
computation.apply(img_in, img_out);
std::cout << "[OK] " << " input size = " << img_in.size << ", input channels = " << img_in.channels() << ", output size = " << img_out.size << std::endl;
}
catch (std::exception const& ex) {
std::string msg(ex.what());
std::replace(msg.begin(), msg.end(), '\n', ' ');
std::cout << "[FAIL] " << "input size = " << img_in.size << ", input channels = " << img_in.channels() << ", message = \"" << msg << "\"" << std::endl;
}
return img_out;
}
void main() {
exec_gapi(cv::Mat(12, 13, CV_8UC1));
exec_gapi(cv::Mat(13, 13, CV_8UC1));
}Output:
[OK] input size = 12 x 13, input channels = 1, output size = 6 x 13
[OK] input size = 12 x 13, input channels = 3, output size = 6 x 13
[FAIL] input size = 13 x 13, input channels = 1, message = "OpenCV kernel output parameter was reallocated. Incorrect meta data was provided ?"
[FAIL] input size = 13 x 13, input channels = 3, message = "OpenCV kernel output parameter was reallocated. Incorrect meta data was provided ?"
Reactions are currently unavailable