其实要说轮廓的检测,是计算机视觉当中基础的内容,进一步延伸可以用来实现基于轮廓的图像检索。现在是刚看到的一段代码,通知canny算子实现轮廓的检测,特别用到了opencv当中的findContours函数,及drawContours函数实现轮廓的绘制。学习实例源代码如下:
#include "stdafx.h"
/**
* @function findContours_Demo.cpp
* @brief Demo code to find contours in an image
* @author OpenCV team
*/
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace cv;
using namespace std;
Mat src; Mat src_gray;
int thresh = 100;
int max_thresh = 255;
RNG rng(12345);
/// Function header
void thresh_callback(int, void* );
/**
* @function main
*/
int main( int argc, char** argv )
{
/// Load source image and convert it to gray
src = im