Format Code
This commit is contained in:
@@ -10,7 +10,8 @@ int main()
|
||||
string image_path = "../img/1.png";
|
||||
Mat image = imread(image_path);
|
||||
|
||||
if (image.empty()) {
|
||||
if (image.empty())
|
||||
{
|
||||
cout << "错误:无法加载图像,请检查路径是否正确。" << endl;
|
||||
return -1;
|
||||
}
|
||||
@@ -20,5 +21,4 @@ int main()
|
||||
cout << "B: " << (int)pixel_value[0] << " "
|
||||
<< "G: " << (int)pixel_value[1] << " "
|
||||
<< "R: " << (int)pixel_value[2] << endl;
|
||||
|
||||
}
|
||||
@@ -11,7 +11,8 @@ int main()
|
||||
Mat image = imread(image_path);
|
||||
Mat result = image.clone();
|
||||
|
||||
if (image.empty()) {
|
||||
if (image.empty())
|
||||
{
|
||||
cout << "错误:无法加载图像,请检查路径是否正确。" << endl;
|
||||
return -1;
|
||||
}
|
||||
@@ -24,5 +25,4 @@ int main()
|
||||
waitKey(0);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
// 读取图像
|
||||
cv::Mat img = cv::imread("../img/1.png");
|
||||
if (img.empty()) {
|
||||
if (img.empty())
|
||||
{
|
||||
std::cout << "无法读取图像" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user