프로젝트

[감시 카메라] Obscura :: [V4L] Chapter 10. 리눅스에서 V4L 을 이용한 캡쳐

appHunter 2009. 5. 6. 16:05

V4L (Video4Linux) 이란 ?

Video4Linux는 리눅스에서 비디오 디바이스를 제어하고 사용하기 위한 API

1. 소스 파일 만들기

  다음 파일 참고 


2. 소스 파일 실행하기

root# ./video /dev/video0 wow.ppm

===========================================
OV511+ 디바이스 드라이버를 이용한 웹켐          <== 별로 안 중요함 -_-)
1. 묘듈 확인  : # lsmod
  a. 없을 시 : # modprobe usb-uhci 
                # modprobe ov511
                # chmod 666 /dev/video*
                # lsmod
  b. 있을 시 : # /파일명 /dev/video0 파일명 -lm
==========================================
=================== INFO ==================
파일 기술자 : 3
===========================================
=================== INFO ==================
The video capabilities are as follows:
name of the interface is CPiA2 Camera
can capture(VID_TYPE_CAPTURE)
number of channels present is 1
number of audios present is 0number of channels present is 1
number of audios present is 0
max capture width is 640 pixels
max capture height is 480 pixels
min capture width is 176 pixels
min capture height is 144 pixels
===========================================
=================== INFO ==================
name of the channel is Camera
number of tuners for this input is 0
properties channel.falgs are not defined
Camera Input(VIDEO_TYPE_CAMERA)
PAL(VIDEO_MODE_PAL)
===========================================
Image properties ars as follows :
brightness = 4600,hue = 7f00.color = 7f00,depth = 18
=================== INFO ==================
Image properties are as follows:
brightness = 17920 hue = 0, color = 32512
contrast = 37632, whiteness = 0
depth = 24, palette = 4
===========================================
지원 이미지 : RGB 24
*** glibc detected *** ./video: free(): invalid pointer: 0xb7f66000 ***
======= Backtrace: =========
/lib/libc.so.6[0x57c424]
/lib/libc.so.6(__libc_free+0x 

.. 생략 ..

3. 파일을 다운로드 한다.

다음과 같은 파일을 받을 수 있다. ( RGB24 파일 형식 )


JPEG 파일로 변환한 그림






참고 사항

파일 저장 시 Read 방식과 mmap 두가지 방식이 있다.

Read 방식이 안 되면 mmap 방식을 참고 바란다.

또한, 카메라가 지원하는 파일 형식을 보고 저장해야 한다.

YUV 방식일 때와 RGB 방식일 때 저장하는 식이 다르다.

참고 문서
상명리눅스연구회 ELF (http://elf.smu.ac.kr/) 에서 제작한 문서 파일