linux video属性_Video4Linux

Video Capture Initialization

IOCTLcalls:Input/Output control (system calls) for device specific input/output operations.

eg: volume control for an audio device, display configuration for video device etc...

Programming a V4L2 device consist of:

Opening the device

This set up uses the open function to return a file descriptor. The call to open as follows:

char* deviceName = "/dev/video*";

int deviceHandle = open(deviceName,O_RDONLY);

if call success , the deviceHandle will contain valid handler to the device.

Query the capabilities of the device

ioctl(device_handle,VIDIOC_QUERYCAP,v4l2_capability)

This provides information about the device such as whether device capture video, supports video overlay etc...

Initialize MemoryMap

Memory Mapped Input|Output(MIMO) interface:This method uses the MIMO interface to map video buffers into our process memory space. From here we can obtain pointers directly to the captured buffer to perform reading.

ioctl(device_handle,VIDIOC_REQBUFS,v4l2_requestbuffers)

Above ioctl call checks whether it supports memory mapping or not.

ioctl(device_handle,VIDIOC_QUERYBUF, v4l2_buffer)

It is used for streaming I/O methods.

mmap(NULL,v4l2_buffer.length,PROT_READ,MAP_SHARED,device_handle,v4l2_buffer.m.offset)

creates a new mapping in the virtual address space.if address is null kernel chooses the address. PROT_READ(to read pages), MAP_SHARED(share the mapping)

Closing the Device

Device is closed using the ioctl call .

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值