OpenCV之图片读取与显示

2021-07-19 15:47:38 浏览数 (1)

python代码:

代码语言:javascript复制
import cv2 as cv

src = cv.imread("./test.png")
cv.namedWindow("input", cv.WINDOW_AUTOSIZE)
cv.imshow("input", src)
cv.waitKey(0)
cv.destroyAllWindows()

c 代码:

代码语言:javascript复制
#include <opencv2/opencv.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main(int artc, char** argv) {
	// Mat src = imread("./test.png");
	Mat src = imread("./test.png", IMREAD_GRAYSCALE);

	if (src.empty()) {
		printf("could not load image...n");
		return -1;
	}
	namedWindow("input", CV_WINDOW_AUTOSIZE);
	imshow("input", src);

	waitKey(0);
	return 0;
}

OpenCV学习笔记代码,欢迎follow:

MachineLP/OpenCV-​github.com

0 人点赞