API Description:
#include<opencv2/opencv.hpp> #include<iostream> using namespace std; using namespace cv; Mat src, dst; int threshold_value = 38; int threshold_max = 255; void canny_demo(int, void*); int main(int argc, char** argv) { src = imread("D:/OpenCVprj/image/test3.jpg"); if (!src.data) { printf("Coluld not load image.....\n"); return -1; } imshow("src", src); namedWindow("dst", CV_WINDOW_AUTOSIZE); createTrackbar("threshold", "dst", &threshold_value, threshold_max, canny_demo); canny_demo(0, 0); waitKey(0); return 0; } void canny_demo(int, void*) { Src_gray MAT, TEMP; cvtColor (the src, src_gray, COLOR_BGR2GRAY); Blur (src_gray, src_gray, Size (. 3,. 3), Point (-1, -1)); the Canny (src_gray, TEMP, threshold_value, threshold_value * 2,. 3, to true); DST .create (src.size (), src.type ()); src.copyTo (DST, TEMP); // first: A.copyTo (B), shows a matrix copy A to B; and the second : A.copyTo (B, mask), mask represents an additional mask to obtain a matrix B. imshow ( "DST", DST); }