提交 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` 程序中,能够正确执行下述操作的是?
1. 读取目录下`lena`图片
2. 显示`lena`图像窗口
3. 等待用户输入任意按键后关闭窗口
4. 销毁所有窗口
## 答案
```cpp
#include <opencv2/opencv.hpp>
using namespace cv;
int main() {
Mat img = imread("lena.png");
imshow("lena", img);
waitKey(0);
destroyAllWindows();
return 0;
}
```python
import cv2
if __name__ == '__main__':
img = cv2.imread("lena.png")
cv2.imshow("lena", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
```
## 选项
### 没有显示图像
```cpp
#include <opencv2/opencv.hpp>
using namespace cv;
```python
import cv2
int main() {
Mat img = imread("lena.png");
waitKey(0);
destroyAllWindows();
return 0;
}
if __name__ == '__main__':
img = cv2.imread("lena.png")
cv2.waitKey(0)
cv2.destroyAllWindows()
```
### imshow参数顺序错误
```cpp
#include <opencv2/opencv.hpp>
using namespace cv;
int main() {
Mat img = imread("lena.png");
imshow(img, "lena");
waitKey(0);
destroyAllWindows();
return 0;
}
```python
import cv2
if __name__ == '__main__':
img = cv2.imread("lena.png")
cv2.imshow(img, "lena")
cv2.waitKey(0)
cv2.destroyAllWindows()
```
### 忘记销毁窗口
```cpp
#include <opencv2/opencv.hpp>
using namespace cv;
```python
import cv2
int main() {
Mat img = imread("lena.png");
imshow("lena", img);
waitKey(0);
return 0;
}
if __name__ == '__main__':
img = cv2.imread("lena.png")
cv2.imshow("lena", img)
cv2.waitKey(0)
```
### 没有等待用户输入按键
```cpp
#include <opencv2/opencv.hpp>
using namespace cv;
```python
import cv2
int main() {
Mat img = imread("lena.png");
imshow("lena", img);
destroyAllWindows();
return 0;
}
if __name__ == '__main__':
img = cv2.imread("lena.png")
cv2.imshow("lena", img)
cv2.destroyAllWindows()
```
# -*- 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.
先完成此消息的编辑!
想要评论请 注册