OpenCV에서 IP Camera로부터 영상을 가져오는 방법은 cv::VideoCapture() 혹은 cv::cudacodec::createVideoReader()
를 이용하는 것이다.
하지만 IP Camera가 연결이 되어 있지 않은 상태에서 해당 객체를 통해 영상을 가져오려고 한다면 어떻게 될까?
두 방법 모두 Exception이 발생하고 프로그램은 중단 될 것이다.
Exception 발생을 방지 하기 위해서는 다양한 방법이 있겠지만 필자는 Socket 통신을 이용하여 먼저 확인하는 것을 추천한다.
IP Camera 설정 Page에 가면 통신 가능한 port 번호를 확인 할 수 있다.
Socket 연결이 정상이라면 IP Camera가 정상적으로 연결 되어 있는 것을 확인 할 수 있다.
참고 자료 1 : docs.opencv.org/3.4/d8/dfe/classcv_1_1VideoCapture.html#a57c0e81e83e60f36c83027dc2a188e80
OpenCV: cv::VideoCapture Class Reference
Class for video capturing from video files, image sequences or cameras. More... #include VideoCapture () Default constructor. More... VideoCapture (const String &filename) Open video file or image file sequence or a capturing device or a IP vide
docs.opencv.org
참고 자료 2: docs.opencv.org/3.4.12/d0/d61/group__cudacodec.html#gafd67042ff937f5152fa1b682c5c589ed
OpenCV: Video Encoding/Decoding
formatSurface format of input frames ( SF_UYVY , SF_YUY2 , SF_YV12 , SF_NV12 , SF_IYUV , SF_BGR or SF_GRAY). BGR or gray frames will be converted to YV12 format before encoding, frames with other formats will be used as is.
docs.opencv.org
'Image Processing > OpenCV' 카테고리의 다른 글
| Video Codec SDK 사용 시 주의점 (0) | 2020.12.09 |
|---|---|
| Gpu에서 영상 다루기[2] - CUDA (0) | 2020.07.16 |
| Gpu에서 영상 다루기[1] - OpenCL (0) | 2020.07.16 |