Welcome to the Csdn-markdown Editor

Source: Internet
Author: User

Fast Corner Detection

In machine vision, there are several kinds of corner detection, of which the fast Corner Detection is more useful. Below, introduce fast Corner detection source code.

Readers can download the version they need. The following is an example of the OPENCV version.
Due to a problem with the OPENCV version, you will encounter errors such as.

fatal error C1083: 无法打开包括文件:“cxtypes.h”: No such file or directory

Solve:

code block
将#include <cxtypes.h>改成#include “cv.h”#include “cxcore.h”#include “highgui.h”

Below, attach the main.cpp

code block
Include <cvaux.h>#include #include "cvfast.h"intMainintargcChar* argv[]) {////////////////////////////////////////////////////////////////////////////////    //    //Process command line arguments    //    intNumargs = ARGC;//char* outfilename = argv[numargs-1];    //char* infilename = argv[numargs-2];    Const Char* Outfilename="1model_out.jpg";Const Char* Infilename="1model.jpg";intInfastthreshhold = -;intInnpixels =9;intInmodecrossesvslist =1;intInnonmaxsuppression =0;intNumremainingargs = Numargs-3;/*if (Numargs <=2) {printf ("need at least 2 arguments:input_file output_file\n"); printf ("Re-run with/?    To see usage\n ");                } if (Numargs < 3) {printf ("Perform FAST feature detection on an image.\n" "\ n"                "usage:\n" "input_image \ T input filename\n" "output_file \ t Output filename\n" "/L \t\t Output a list of corners (instead of an image) \ n" ""/t X \t\t Set threshold to X. Default I S 20\n ""/n X \t\t use x point Fast (allowed range was 9--12, default is 9) \ n ""/s \t\t perfo        RM nonmaximal suppression\n ");    return 0; } for (int j=1; J <= Numremainingargs; j + +) {if (!strcmp (Argv[j], "L")) {Inmodecrossesvs        List = 2;        } else if (!strcmp (Argv[j], "s")) {innonmaxsuppression = 1;            } else if (!strcmp (Argv[j], "/t")) {j + +; InfastthReshhold = Atoi (Argv[j]);            } else if (!strcmp (Argv[j], "/n")) {j + +;            Innpixels = Atoi (Argv[j]); if (Innpixels > | | Innpixels < 9) {printf ("x point fast requires 8 < x < A, not%d\n",                Innpixels);            return (0);            }} else {printf ("Unrecognized arguments (%s), re-run with/?\n", Argv[j]);        return (0); }    }    */    ////////////////////////////////////////////////////////////////////////////////    //    //load an image with to 8 bit grey CVD image using IPL    //iplimage* i_in = Cvloadimage (Infilename,-1); iplimage* Igray = Cvcreateimage (Cvgetsize (i_in), ipl_depth_8u,1);    Cvcvtcolor (i_in, Igray, Cv_rgb2gray); Cvpoint* Corners;intNumcorners; Cvcornerfast (Igray, Infastthreshhold, Innpixels, Innonmaxsuppression, &numcorners, & Corners);if(Inmodecrossesvslist = =1)     {//Put They grey image in to a colour buffer and draw on itCvcvtcolor (Igray, i_in, Cv_gray2rgb);//Instead of Iplcolortogray (Icanvas, icanvasgray);         for(intI=0; i < numcorners; i++) {cvline (i_in, Cvpoint (corners[i].x-1, corners[i].y), Cvpoint (corners[i].x+1, corners[i].y), Cv_rgb (255,0,0) ); Cvline (i_in, Cvpoint (corners[i].x, corners[i].y-1), Cvpoint (corners[i].x, corners[i].y+1), Cv_rgb (255,0,0) );    } cvsaveimage (Outfilename, i_in); }Else if(Inmodecrossesvslist = =2)     {//Print to TXT file.printf"Saving list of corners to file%s ...", outfilename); file* fp = fopen (Outfilename,"W"); for(intI=0; i < numcorners; i++) {fprintf (FP),"%i%i\n", corners[i].x, CORNERS[I].Y); } printf ("done.\n");    Fclose (FP); }}

Welcome to the Csdn-markdown Editor

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.