cvHoughLines and cvHoughCircles functions help

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

cvHoughLines and cvHoughCircles functions help

coskun kazma
Dear Friends,I am searching some sampels about cvHoughLines and cvHoughCircles functions in internet but I can not find anything about them. If you have some examples, could you send me please some examples.Thank you very much,Coskun


      Get your preferred Email name!
Now you can @ymail.com and @rocketmail.com.
http://mail.promotions.yahoo.com/newdomains/aa/

[Non-text portions of this message have been removed]

Reply | Threaded
Open this post in threaded view
|

Re: cvHoughLines and cvHoughCircles functions help

HoangNguyen
You should have found the full documentation of openCV on the website. Anyway, here's a sample code for cvHoughline:

Example. Detecting lines with Hough transform.
/* This is a standalone program. Pass an image name as a first parameter of the program.
   Switch between standard and probabilistic Hough transform by changing "#if 1" to "#if 0" and back */
#include <cv.h>
#include <highgui.h>
#include <math.h>

int main(int argc, char** argv)
{
    IplImage* src;
    if( argc == 2 && (src=cvLoadImage(argv[1], 0))!= 0)
    {
        IplImage* dst = cvCreateImage( cvGetSize(src), 8, 1 );
        IplImage* color_dst = cvCreateImage( cvGetSize(src), 8, 3 );
        CvMemStorage* storage = cvCreateMemStorage(0);
        CvSeq* lines = 0;
        int i;
        cvCanny( src, dst, 50, 200, 3 );
        cvCvtColor( dst, color_dst, CV_GRAY2BGR );
#if 1
        lines = cvHoughLines2( dst, storage, CV_HOUGH_STANDARD, 1, CV_PI/180, 100, 0, 0 );

        for( i = 0; i < MIN(lines->total,100); i++ )
        {
            float* line = (float*)cvGetSeqElem(lines,i);
            float rho = line[0];
            float theta = line[1];
            CvPoint pt1, pt2;
            double a = cos(theta), b = sin(theta);
            double x0 = a*rho, y0 = b*rho;
            pt1.x = cvRound(x0 + 1000*(-b));
            pt1.y = cvRound(y0 + 1000*(a));
            pt2.x = cvRound(x0 - 1000*(-b));
            pt2.y = cvRound(y0 - 1000*(a));
            cvLine( color_dst, pt1, pt2, CV_RGB(255,0,0), 3, 8 );
        }
#else
        lines = cvHoughLines2( dst, storage, CV_HOUGH_PROBABILISTIC, 1, CV_PI/180, 50, 50, 10 );
        for( i = 0; i < lines->total; i++ )
        {
            CvPoint* line = (CvPoint*)cvGetSeqElem(lines,i);
            cvLine( color_dst, line[0], line[1], CV_RGB(255,0,0), 3, 8 );
        }
#endif
        cvNamedWindow( "Source", 1 );
        cvShowImage( "Source", src );

        cvNamedWindow( "Hough", 1 );
        cvShowImage( "Hough", color_dst );

        cvWaitKey(0);
    }
}
/////////////////////////////////
Have fun
Hoang



--- On Fri, 16/1/09, coskun kazma <[hidden email]> wrote:
From: coskun kazma <[hidden email]>
Subject: [OpenCV] cvHoughLines and cvHoughCircles functions help
To: [hidden email]
Date: Friday, 16 January, 2009, 5:47 AM










   
            Dear Friends,I am searching some sampels about cvHoughLines and cvHoughCircles functions in internet but I can not find anything about them. If you have some examples, could you send me please some examples.Thank you very much,Coskun



Get your preferred Email name!

Now you can @ymail.com and @rocketmail. com.

http://mail. promotions. yahoo.com/ newdomains/ aa/



[Non-text portions of this message have been removed]




     

   
   
       
         
       
       








       


       
       


      New Email addresses available on Yahoo!
Get the Email name you&#39;ve always wanted on the new @ymail and @rocketmail.
Hurry before someone else does!
http://mail.promotions.yahoo.com/newdomains/aa/

[Non-text portions of this message have been removed]