This error occurs when the input image size is empty. The function 'cv::resize' is used to resize an image, and it requires a non-empty input image. To fix this error, you need to check if the input image size is valid before calling the 'cv::resize' function. You can do this by checking if the input image is empty or not using the 'empty' function provided by OpenCV.

Here is an example code snippet that shows how to check if the input image is empty before calling the 'cv::resize' function:

cv::Mat inputImage = cv::imread('input.jpg');

if (!inputImage.empty()) {
    cv::Mat resizedImage;
    cv::resize(inputImage, resizedImage, cv::Size(640, 480));
} else {
    // handle the case where the input image is empty
}

In this example, we first read the input image using the 'imread' function. Then, we check if the input image is empty or not using the 'empty' function. If the input image is not empty, we call the 'cv::resize' function to resize the image. Otherwise, we handle the case where the input image is empty.

OpenCV Resize Error: '(-215:Assertion failed) !ssize.empty()' Solution

原文地址: https://www.cveoy.top/t/topic/n7yr 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录