OpenCV之Canny算子边缘检测

xiaoxiao2021-02-28  105

#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/opencv.hpp> using namespace cv; int CurrentValue = 0; int main(int argc,char ** argv){ Mat srcImage; srcImage = imread("/Users/hxh/Desktop/1.jpg",0); namedWindow("显示窗口",0); createTrackbar("Value:","显示窗口",&CurrentValue,255,0); Mat dstImage,resImage; char key; while (1){ key = waitKey(10); blur(srcImage,dstImage,Size(3,3)); // 滤波 Canny(dstImage,dstImage,(double)CurrentValue,(double)(2*CurrentValue),3); // Canny边缘检测 resImage = Scalar::all(0); // 将resImage中的所有元素置为0 srcImage.copyTo(resImage,dstImage); imshow("显示窗口",resImage); if (key==27) break; } return 0; }
转载请注明原文地址: https://www.6miu.com/read-64712.html

最新回复(0)