백인감자

[OpenCV 3.0]동영상에서 edge 추출하기 본문

OpenCV

[OpenCV 3.0]동영상에서 edge 추출하기

백인감자 2016. 8. 8. 15:41

동영상을 입력받아서 RGB to Gray 로 바꿔준 다음 gray 영상에서 edge를 추출하여 원본(frame) 과 추출(edge) 영상을 같이 화면에 띄우는 

예제이다.


Canny 함수는 기본적으로 grayscale 화 된 이미지나 영상의 외곽선(edge) 를 추출하는것인데 openCV 2.4 이상 버전부터는 color 이미지나 영상도 바로 추출 할 수 있도록(gray화 시키는 과정 생략) 지원된다고 한다. 

이 예제에서는 직접 gray화 시키는 코드를 포함한 예제이다.


Canny함수 인자에 대한 설명 


 출처:http://docs.opencv.org/2.4/doc/tutorials/imgproc/imgtrans/canny_detector/canny_detector.html


Canny( detected_edges, detected_edges, lowThreshold, lowThreshold*ratio, kernel_size );

where the arguments are:

  • detected_edges: Source image, grayscale
  • detected_edges: Output of the detector (can be the same as the input)
  • lowThreshold: The value entered by the user moving the Trackbar
  • highThreshold: Set in the program as three times the lower threshold (following Canny’s recommendation)
  • kernel_size: We defined it to be 3 (the size of the Sobel kernel to be used internally)







실행결과





Comments