update the start
This commit is contained in:
1 parent
183d7fea8d
commit
2fb7d72939
4 files changed
+36
-1
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
out
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace cv;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
string image_path = "../img/1.png";
|
||||||
|
Mat image = imread(image_path);
|
||||||
|
|
||||||
|
if (image.empty()) {
|
||||||
|
cout << "错误:无法加载图像,请检查路径是否正确。" << endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
namedWindow("Display Image", WINDOW_AUTOSIZE);
|
||||||
|
imshow("Display Image", image);
|
||||||
|
|
||||||
|
int key = waitKey(0);
|
||||||
|
|
||||||
|
// 4. 根据用户按键执行操作
|
||||||
|
if (key == 's') { // 如果按下 's' 键
|
||||||
|
// 保存图像
|
||||||
|
string output_path = "saved_image.jpg";
|
||||||
|
imwrite(output_path, image);
|
||||||
|
cout << "图像已保存为 " << output_path << endl;
|
||||||
|
} else { // 如果按下其他键
|
||||||
|
cout << "图像未保存。" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
destroyAllWindows();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loaded 3 of 4 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user