保存图片
cpp
bool opencvTool::saveImage(const std::string path, const cv::Mat image)
{
if (image.empty())
{
std::cout << "Error: empty mat " << std::endl;
return false;
}
// 保存图像文件
try
{
cv::imwrite(path, image);
std::cout << "Image saved successfully!" << std::endl;
return true;
}
catch (cv::Exception& e) {
std::cout << "Error: " << e.what() << std::endl;
return false;
}
}