xinntao / Real-ESRGAN-ncnn-vulkan

NCNN implementation of Real-ESRGAN. Real-ESRGAN aims at developing Practical Algorithms for General Image Restoration.
https://github.com/xinntao/Real-ESRGAN
Other
1.46k stars 182 forks source link

Convert result image to OpenCV `cv::Mat` ERROR #24

Open Sun-ZhenXing opened 2 years ago

Sun-ZhenXing commented 2 years ago

I have test ncnn::Mat.to_pixels() with inimage, but outimage report error when converting:

// (main.cpp 376 line)
ncnn::Mat out = v.outimage;
cv::Mat res(out.h, out.w, CV_8UC3);
out.to_pixels(res.data, ncnn::Mat::PIXEL_BGR2RGB); // ERROR here
cv::imshow("res", res);
cv::waitKey();
cv::destroyAllWindows();

With OpenCV 4.6.0 Windows 10x, always get this:

Exception has occurred: W32/0xC0000005
Unhandled exception thrown: read access violation.
ptr1 was 0x1ACAC042000.

/src/ncnn/src/mat_pixel.cpp 734 line, is the problem with out.data or other ?