When running this code
int main(int argc, char *argv[])
{
vector<cv::Mat> imgs(argc - 1);
for (auto i = 1; i < argc; ++i)
{
cv::Mat img = cv::imread(argv[i]);
cv::Mat dst;
cv::GaussianBlur(img, dst, cv::Size(3, 3), 0, 0, cv::BORDER_DEFAULT);
cv::Sobel(dst, dst, -1, 1, 1);
imgs.push_back(dst);
}
for (auto i = 1; i < argc; ++i)
{
string filename(argv[i]);
filename[0] = toupper(filename[0]);
filename.end()[-5] = 'a';
cv::imwrite(filename, imgs[i]);
}
}
I get the following error message:
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: OpenCV(4.3.0) /tmp/opencv-20200408-5080-l00ytm/opencv-4.3.0/modules/imgcodecs/src/loadsave.cpp:738: error: (-215:Assertion failed) !_img.empty() in function 'imwrite'
I don't know what I'm doing wrong.