#include <iostream> #include <filesystem> #include <string> #include <windows.h> #include <opencv2/opencv.hpp> namespace fs = std::filesystem; using namespace cv; using namespace std; int main() { //std::cout << "Hello World!\n"; //fs::path currentPath = fs::current_path(); //string filename = currentPath.string() + "\\jzh.png"; // 图片路径 string file = "F:/opencv/console/x64/Debug/jzh.png"; // 显示原图 Mat src = imread(file); imshow("src", src); // 灰度 Mat gray; cvtColor(src, gray, COLOR_BGR2GRAY); imshow("gray", gray); waitKey(0); destroyAllWindows(); return 0; }