提交 55096573 编写于 作者: F feilong

添加第一题

上级 279c186b
#include <opencv2/opencv.hpp>
using namespace cv;
int main() {
Mat img = imread("lena.png");
imshow("lena", img);
waitKey(0);
destroyAllWindows();
return 0;
}
\ No newline at end of file
# Hello World # Hello World
以下 `Hello World` 程序中,能够正确执行下述操作的是? 以下 `Hello World` 程序中,能够正确执行下述操作的是?
1. 读取目录下`lena`图片 1. 读取目录下`lena`图片
2. 显示`lena`图像窗口 2. 显示`lena`图像窗口
3. 等待用户输入任意按键后关闭窗口 3. 等待用户输入任意按键后关闭窗口
4. 销毁所有窗口
## 答案 ## 答案
```cpp ```python
#include <opencv2/opencv.hpp> import cv2
using namespace cv;
if __name__ == '__main__':
int main() { img = cv2.imread("lena.png")
Mat img = imread("lena.png"); cv2.imshow("lena", img)
imshow("lena", img); cv2.waitKey(0)
waitKey(0); cv2.destroyAllWindows()
destroyAllWindows();
return 0;
}
``` ```
## 选项 ## 选项
### 没有显示图像 ### 没有显示图像
```cpp ```python
#include <opencv2/opencv.hpp> import cv2
using namespace cv;
int main() { if __name__ == '__main__':
Mat img = imread("lena.png"); img = cv2.imread("lena.png")
waitKey(0); cv2.waitKey(0)
destroyAllWindows(); cv2.destroyAllWindows()
return 0;
}
``` ```
### imshow参数顺序错误 ### imshow参数顺序错误
```cpp ```python
#include <opencv2/opencv.hpp> import cv2
using namespace cv;
if __name__ == '__main__':
int main() { img = cv2.imread("lena.png")
Mat img = imread("lena.png"); cv2.imshow(img, "lena")
imshow(img, "lena"); cv2.waitKey(0)
waitKey(0); cv2.destroyAllWindows()
destroyAllWindows();
return 0;
}
``` ```
### 忘记销毁窗口 ### 忘记销毁窗口
```cpp ```python
#include <opencv2/opencv.hpp> import cv2
using namespace cv;
int main() { if __name__ == '__main__':
Mat img = imread("lena.png"); img = cv2.imread("lena.png")
imshow("lena", img); cv2.imshow("lena", img)
waitKey(0); cv2.waitKey(0)
return 0;
}
``` ```
### 没有等待用户输入按键 ### 没有等待用户输入按键
```cpp ```python
#include <opencv2/opencv.hpp> import cv2
using namespace cv;
if __name__ == '__main__':
int main() { img = cv2.imread("lena.png")
Mat img = imread("lena.png"); cv2.imshow("lena", img)
imshow("lena", img); cv2.destroyAllWindows()
destroyAllWindows(); ```
return 0;
}
```
\ No newline at end of file
# -*- coding: utf-8 -*-
import cv2
if __name__ == '__main__':
img = cv2.imread("lena.png")
cv2.imshow("lena", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册