The source code of Corner Detection (requires support for OpenCV libraries)

xiaoxiao2021-03-06  78

This is some modifications to the source code provided by RUADHAN, which can detect angular points in the image. The application environment is: OpenCV Beta 4, VC6 compiles run.

Run file download address:

http://www.ssuredigit.com/program/corner.exe

========== # include

#include "cv.h"

#include "highgui.h"

#define max_corners 100

int main (int argc, char ** argv) {int cornerCount = max_corners; CvPoint2D32f corners [max_corners]; double qualityLevel; double minDistance; IplImage * srcImage = 0, * grayImage = 0, * corners1 = 0, * corners2 = 0; INT i; cvscalar color = CV_RGB (255, 0); char * filename = argc == 2? Argv [1]: (char *) "..///ww // pic3.png"; cvNamedWindow ( "image", 1); // create HighGUI window with name "image" // Load the image to be processed srcImage = cvLoadImage (filename, 1); grayImage = cvCreateImage (cvGetSize (srcImage), IPL_DEPTH_8U, 1); // copy the source image to copy image after converting the format cvCvtColor (srcImage, grayImage, CV_BGR2GRAY); // create empty images of same size as the copied images corners1 = cvCreateImage (cvGetSize (srcImage), IPL_DEPTH_32F, 1); corners2 = CvcreateImage (cvgetsize (srcimage), IPL_Depth_32f, 1); Cvgoodfeaturestotrack (GrayImage, Corners1, Corners2, Corners, & CornerCount, 0.05, 5, 0); Printf ("Num Corners Found:% D / N", CornerCount); // Draw Circles At Each Corner Location In The Gray Image and // Print Out A List The Corners IF (CornerCount> 0) {for (i = 0; i

{

Cvcircle (SRCIMAGE, CVPOINT (Corners [i] .x), (int) (Corners [i] .y), 6,

Color, 2, CV_AA, 0);

}

}

CvShowImage ("Image", SRCIMAGE

CVRELEASEIMAGE (& SRCIMAGE); CVRELEASEIMAGE (& grayImage);

CVRELEASEIMAGE (& CORNERS1);

CVRELEASEIMAGE (& Corners2);

CvwaitKey (0); // Wait for Key. The Function HAS

Return 0;

}

-----------------

敕敕川, 阴 山

It is like a mountain, shrouded four wild

Tiantang, wild, wind, grass, low cows and sheep

转载请注明原文地址:https://www.9cbs.com/read-121592.html

New Post(0)