• Tistory
    • 태그
    • 위치로그
    • 방명록
    • 관리자
    • 글쓰기
Carousel 01
Carousel 02
Previous Next

cvHoughLines2 함수를 이용한 직선 검출

Programming/OpenCV 2013. 4. 29. 15:02






  IplImage* cam_image =  캠에서 입력받은 영상이나 뭐든 여튼 이미지

  IplImage* output = cvCreateImage(cvGetSize(cam_image), 8, 1);     //edge출력을위한 1채널 영상

IplImage* gray = cvCreateImage(cvGetSize(cam_image), 8, 1);         //edge검출을위한 1채널 영상

        IplImage* color_output = cvCreateImage(cvGetSize(cam_image), 8, 3); //hough 출력을위한 3채널 영상


CvMemStorage* storage = cvCreateMemStorage(0);

CvSeq* lines = 0;


cvCvtColor(cam_image, gray,CV_RGB2GRAY);

cvCanny(gray, output, 50,200, 3);

cvCvtColor(output, color_output, CV_GRAY2RGB);


//CV_HOUGH_PROBABILISTIC MODE

lines = cvHoughLines2(output, storage, CV_HOUGH_PROBABILISTIC, 1, CV_PI/180, 50, 30, 3);


for(int i=0; i<lines->total; i++)

{

CvPoint* line = (CvPoint*)cvGetSeqElem(lines, i);

cvLine(color_output, line[0], line[1], CV_RGB(255, 0, 0), 2, 8);

}


cvNamedWindow("Hough");

cvShowImage("Hough", color_output);


cvReleaseImage(&output);

cvReleaseImage(&gray);

cvReleaseImage(&color_output);


========================================================================================================================

cvHoughLines2 함수 파라미터에 대한 설명이다

Parameters:
  • image – 8-bit, single-channel binary source image. The image may be modified by the function.
  • lines – Output vector of lines. Each line is represented by a two-element vector (\rho, \theta) . \rho is the distance from the coordinate origin (0,0) (top-left corner of the image). \theta is the line rotation angle in radians ( 0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line} ).
  • rho – Distance resolution of the accumulator in pixels.
  • theta – Angle resolution of the accumulator in radians.
  • threshold – Accumulator threshold parameter. Only those lines are returned that get enough votes ( >\texttt{threshold} ).
  • srn – For the multi-scale Hough transform, it is a divisor for the distance resolution rho . The coarse accumulator distance resolution is rho and the accurate accumulator resolution is rho/srn . If both srn=0 and stn=0 , the classical Hough transform is used. Otherwise, both these parameters should be positive.
  • stn – For the multi-scale Hough transform, it is a divisor for the distance resolution theta.
  • method –

    One of the following Hough transform variants:

    • CV_HOUGH_STANDARD classical or standard Hough transform. Every line is represented by two floating-point numbers (\rho, \theta) , where \rho is a distance between (0,0) point and the line, and \theta is the angle between x-axis and the normal to the line. Thus, the matrix must be (the created sequence will be) of CV_32FC2 type
    • CV_HOUGH_PROBABILISTIC probabilistic Hough transform (more efficient in case if the picture contains a few long linear segments). It returns line segments rather than the whole line. Each segment is represented by starting and ending points, and the matrix must be (the created sequence will be) of the CV_32SC4 type.
    • CV_HOUGH_MULTI_SCALE multi-scale variant of the classical Hough transform. The lines are encoded the same way as CV_HOUGH_STANDARD.
  • param1 –

    First method-dependent parameter:

    • For the classical Hough transform, it is not used (0).
    • For the probabilistic Hough transform, it is the minimum line length.
    • For the multi-scale Hough transform, it is srn.
  • param2 –

    Second method-dependent parameter:

    • For the classical Hough transform, it is not used (0).
    • For the probabilistic Hough transform, it is the maximum gap between line segments lying on the same line to treat them as a single line segment (that is, to join them).
    • For the multi-scale Hough transform, it is stn.



저작자표시 (새창열림)

'Programming > OpenCV' 카테고리의 다른 글

cv::Mat Class 사용법  (0) 2013.05.06
OpenCV 주요함수  (0) 2013.04.29
OpenCV 를 이용하여 동영상 재생하기.  (0) 2013.04.26
Haar Face Detection  (0) 2013.04.02
[Function] FindContour 덩어리 찾기  (0) 2013.04.02
블로그 이미지

매직블럭

작은 지식들 그리고 기억 한조각

,

카테고리

  • 살다보니.. (448)
    • 주절거림 (3)
    • 취미생활 (36)
      • 지식과 지혜 (3)
      • 풍경이 되어 (4)
      • Memories (17)
      • 엥겔지수를 높여라 (2)
    • mathematics (6)
      • Matrix Computation (2)
      • RandomProcesses (3)
    • English.. (8)
    • Programming (147)
      • C, C++, MFC (51)
      • C# (1)
      • OpenCV (17)
      • Python (58)
      • Git, Docker (3)
      • Matlab (4)
      • Windows (3)
      • Kinect V2 (2)
      • 기타 etc. (8)
    • 전공관련 (80)
      • Algorithm (6)
      • Deep Learning (54)
      • 실습 프로그램 (4)
      • 주워들은 용어정리 (8)
      • 기타 etc. (8)
    • Computer (118)
      • Utility (21)
      • Windows (31)
      • Mac (4)
      • Ubuntu, Linux (58)
      • NAS (2)
      • Embedded, Mobile (2)
    • IT, Device (41)
      • 제품 사용기, 개봉기 (14)
      • 스마트 체험단 신청 (27)
    • Wish List (3)
    • TISTORY TIP (5)
    • 미분류. 수정중 (1)

태그목록

  • Deep Learning
  • Computer Tip
  • 칼로리 대폭발
  • ColorMeRad
  • SVM
  • 에누리닷컴
  • Convolutional Neural Networks
  • 후쿠오카
  • 크롬
  • 오봉자싸롱
  • 스마트체험단
  • CStdioFile
  • utility
  • 갤럭시노트3
  • LIBSVM
  • matlab function
  • 매트랩
  • ReadString
  • 딥러닝
  • portugal
  • 일본
  • function
  • DeepLearning
  • 큐슈
  • review
  • DSLR
  • random variable
  • matlab
  • 포르투갈
  • 매트랩 함수

달력

«   2025/05   »
일 월 화 수 목 금 토
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
05-24 02:19

LATEST FROM OUR BLOG

RSS 구독하기

BLOG VISITORS

  • Total :
  • Today :
  • Yesterday :

Copyright © 2015 Socialdev. All Rights Reserved.

티스토리툴바