资源简介
包含源代码及编译好的文件。可直接执行。
代码片段和文件信息
#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
相关资源
- ubuntu9.10 可加载内核模块和字符设备驱
- 将yuv各种格式的图片转换为jpg格式的
- Ubuntu安装时磁盘分区图文教程
- 周立功PCI CAN卡LINUX驱动ubuntu16.04内核
- 无法进入桌面ubuntu18.04
- Ubuntu下操作Excel,qt代码
- 基于V4L2的视频采集,能够采集YUVJPE
- 磊科nw336Ubuntu驱动
- opencv3.0交叉编译用parallel.cpp
- ubuntu linux 指南 基础篇+管理篇
- 最简单的基于FFmpeg的编码器 1.2
- 最简单的基于FFMPEG的视频编码器修正
- 最简单的基于FFmpeg的libswscale的教程
- RTL8111/8168/8411的ubuntu18.04.1驱动
- 安装linux后的mbr修复工具(含64位)
- linuxubuntu下ffmpeg + alsa 的音频播放器
- ( YUV420(YV12)与YUY2(YUV422YUYV)格式
- RTL8111/8168/8411 ubuntu驱动
- OV5640自动对焦照相模组应用指南(M
- zedboard ubuntu16.04文件系统
- OV5640详细资料
- stm32f4+ov5640颜色识别.zip
- 16.04ubuntu系统配置过程
- stm32f407+ov5640颜色识别与追踪
- 张正友相机标定自己编写calibratie函数
- Ubuntu16.04中配置Qt5.9.1和OpenCV3.4.0过程
- 58\\_实战篇\\_OV5640摄像头VGA显示实验
- 搭建OMAPL138的Linux开发环境 LINUX交叉编
- NS2工作环境安装图文详解
- YUV Viewer 附测试文件格式:yuv420
评论
共有 条评论