#include<iostream> #include "opencv2/opencv.hpp" using namespace std; using namespace cv; int main(int argc, char* argv[]) { Mat im = imread("pic.jpg", 0); if (im.empty()) { cout << "Can not load Image." << endl; return -1; } Mat result; Canny(im, result, 50, 150); imwrite("pic-canny.png", result); return 0; } </iostream> 1. 原图像 2. 边缘检测后图像