资源简介
包含源代码及编译好的文件。可直接执行。
代码片段和文件信息
#include
#include
#include
#include
#include /* getopt_long() */
#include /* low-level i/o */
#include
#include
#include
#include
#include
#include
#include
#include /* for videodev2.h */
#include
#include “camera.h“
int c_camera_type = 0;
Camera::Camera(char *DEV_NAME int w int h int camera_type)
{
memcpy(dev_nameDEV_NAMEstrlen(DEV_NAME));
io = IO_METHOD_MMAP;//IO_METHOD_READ;//IO_METHOD_MMAP;
cap_image_size=0;
width=w;
height=h;
if(1 == camera_type)
{
c_camera_type = 1;
}
}
Camera::~Camera(){
}
unsigned int Camera::getImageSize(){
return cap_image_size;
}
void Camera::CloseDevice() {
stop_capturing();
uninit_device();
close_device();
}
void Camera::errno_exit(const char * s) {
fprintf(stderr “%s error %d %s\n“ s errno strerror(errno));
exit(EXIT_FAILURE);
}
int Camera::xioctl(int fd int request void * arg) {
int r;
do
r = ioctl(fd request arg);
while (-1 == r && EINTR == errno);
return r;
}
int Camera::read_frame(unsigned char *image) {
struct v4l2_buffer buf;
CLEAR (buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
if (-1 == xioctl(fd VIDIOC_DQBUF &buf)) {
switch (errno) {
case EAGAIN:
printf(“************** %s line = %d\n“ __FUNCTION__ __LINE__);
return 0;
case EIO:
printf(“************** %s line = %d\n“ __FUNCTION__ __LINE__);
/* Could ignore EIO see spec. */
/* fall through */
default:
printf(“************** %s line = %d\n“ __FUNCTION__ __LINE__);
errno_exit(“VIDIOC_DQBUF“);
}
}
printf(“************** %s line = %d\n“ __FUNCTION__ __LINE__);
assert(buf.index < n_buffers);
printf(“************** %s line = %d\n“ __FUNCTION__ __LINE__);
memcpy(imagebuffers[0].startcap_image_size);
if (-1 == xioctl(fd VIDIOC_QBUF &buf))
errno_exit(“VIDIOC_QBUF“);
return 1;
}
void Camera::stop_capturing(void) {
enum v4l2_buf_type type;
switch (io) {
case IO_METHOD_READ:
/* Nothing to do. */
break;
case IO_METHOD_MMAP:
case IO_METHOD_USERPTR:
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (-1 == xioctl(fd VIDIOC_STREAMOFF &type))
errno_exit(“VIDIOC_STREAMOFF“);
break;
}
}
bool Camera::start_capturing(void) {
unsigned int i;
enum v4l2_buf_type type;
printf(“************** %s line = %d\n“ __FUNCTION__ __LINE__);
for (i = 0; i < n_buffers; ++i) {
struct v4l2_buffer buf;
CLEAR (buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMOR
相关资源
- ubuntu下安装ns2方法
- yuv序列间隔丢失宏块,再按照JM8.6误码
- ubuntu openssh 7.8p1 升级安装包
- ubuntu-16.04.3-desktop-amd64.iso.torrent
- ubuntu下安装VMware tools
- ubuntu-10.10镜像文件链接
- Gnome-OSC-HS--2-themes.tar.xz
- ubuntu 16.04Server版 torrent
- ubuntu opencv qt 三位一体的摄像头源码
- ubuntu-16.04.1-server-arm64.iso
- 百度网盘qimo for kids带中文版qimo 2.0
- Ubuntu升级openssh7.8p1快速命令集
- ubuntu下安装jdk和NSG2教程(有详尽步骤
- ubuntu-14.04-desktop-amd64.iso
- Ubuntu64位的交叉编译工具arm-linux-gcc-
- rgba8888转yuvsp420
-
YUVpla
yer1.3 - linux下LaTex配置完全指南
- ubuntu的划词工具实现添加单词到本地
- ubuntu12.04环境下直接Floodlight+miniet搭建
- Hadoop安装ubuntu16.04+ hadoop-2.9.1.tar.gz+j
- ubuntu 开机动画实现
- Dell 不重装系统Sata operation RAID ON 改
- 操作系统课设 Ubuntu下运行读者写者问
- cuda 9.0 ubuntu16.04百度云链接
- shadowsocks-libev_2.5.5-1_amd64_Ubuntu14.04.de
- Ubuntu系统:为Qt配置ROS开发环境
- minidwep-gtk-40420-ubuntu-64bit.deb
- ov5640自动对焦固件
- YUV422转换为YUV420数据格式
评论
共有 条评论