opencv-001-读取(imread)与显示(imshow)图像 发表于 2019-03-20 | 分类于 opencv 知识点 读取图像 - imread() 显示图像 - imshow() 代码(c++,python)123456789101112131415161718192021#include <opencv2/opencv.hpp>#include <iostream>using namespace std;using namespace cv;int main() { // Mat image = imread("../images/liuyifei_1.png"); // 读取的时候加参数,使读取后为灰度图像 Mat image = imread("../images/liuyifei_1.png",IMREAD_GRAYSCALE); if (image.empty()) { cout << "could not load image..." << endl; return -1; } namedWindow("input"); imshow("input",image); waitKey(0); return 0;} 1234567import cv2 as cvsrc = cv.imread("../images/liuyifei_1.png")cv.namedWindow("input", cv.WINDOW_AUTOSIZE)cv.imshow("input", src)cv.waitKey(0)cv.destroyAllWindows() 结果 代码地址github