资源简介
net_camera.rar
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include “camera.h“
struct v4l2_buffer buf;
VideoBuffer *buffers;
Mybuffer mybuffer;
//初始化mybuffer;
void init_mybuffer()
{
pthread_rwlock_init(&(mybuffer.rwlock)NULL);
mybuffer.date = (unsigned char *)calloc(1(buffers[0].length)*sizeof(unsigned char));
mybuffer.len = buffers[0].length;
}
//释放mybuffer
void free_mybuffer()
{
pthread_rwlock_destroy(&(mybuffer.rwlock));
free(mybuffer.date);
}
//打开设备
int myopen(const char *pathint type)
{
int fd;
if((fd = open(pathtype))<0)
{
fprintf(stderr“open err:%s\n“strerror(errno));
exit(1);
}
return fd;
}
//查看设备的功能
void out_capability(int fd)
{
struct v4l2_capability capa;
capa_info info;
memset(&info0sizeof(capa_info));
memset(&capa0sizeof(struct v4l2_capability));
if(ioctl(fdVIDIOC_QUERYCAP&capa)<0)
{
fprintf(stderr“out capability:%s\n“strerror(errno));
exit(1);
}
strcpy(info.drivercapa.driver);
strcpy(info.cardcapa.card);
strcpy(info.bus_infocapa.bus_info);
info.version = (unsigned int)capa.version;
printf(“dirver: %s\n“info.driver);
printf(“card: %s\n“info.card);
printf(“bus_info: %s\n“info.bus_info);
printf(“version: %d\n“info.version);
}
//设置帧的格式
void set_format(int fd)
{
struct v4l2_format fmt;
memset(&fmt0sizeof(struct v4l2_format));
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt.fmt.pix.field = V4L2_FIELD_ANY;
fmt.fmt.pix.width = WIDTH;
fmt.fmt.pix.height = HEIGHT;
fmt.fmt.pix.pixelformat = MJPEG;
if(ioctl(fdVIDIOC_S_FMT&fmt)<0)
{
fprintf(stderr“set format error:%s\n“strerror(errno));
exit(1);
}
}
//设置流类型相关参数
void set_parm(int fd)
{
struct v4l2_streamparm parm;
memset(&parm0sizeof(struct v4l2_streamparm));
parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
parm.parm.capture.timeperframe.numerator = 1;
parm.parm.capture.timeperframe.denominator = FPS;
if(ioctl(fdVIDIOC_S_PARM&parm)<0)
{
fprintf(stderr“set streamparm error:%s\n“strerror(errno));
exit(1);
}
}
//获取并向驱动申请帧缓冲
void query_Buffer(int fd)
{
struct v4l2_requestbuffers req;
memset(&req0sizeof(struct v4l2_requestbuffers));
//分配内存
req.count = NB_BUFFER;
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
req.memory = V4L2_MEMORY_MMAP;
if(ioctl(fdVIDIOC_REQBUFS&req)<0)
{
fprintf(stderr“reqbufs error:%s\n“strerror(errno));
exit(1);
}
buffers = (VideoBuffer *)calloc(req.count
sizeof(VideoBuffer));
int numBufs;
for(numBufs = 0;numBufs {
memset(&buf0sizeof(struct v4l2_buffer));
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.index = numBufs;
buf.memory = V4L2_MEMORY_MMAP;
//读取缓存
if(ioctl(fdVIDIOC_QUERYBUF&buf)<0)
{
fprintf(stderr“querybuf:%s\n“strerror(errno));
exit(1);
}
buffers[numBufs].length = buf.length;
// printf(“buffers[0].length:%d\n“buffers[numBufs].length);
//转换成相对地
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 20099 2007-03-13 15:07 net_camera\bin\camera
文件 12039 2007-03-13 14:09 net_camera\bin\test
文件 870 2007-03-13 15:07 net_camera\include\camera.h
文件 5701 2007-01-21 01:40 net_camera\include\huffman.h
文件 318 2007-01-21 01:40 net_camera\include\print.h
文件 5632 2007-03-13 15:07 net_camera\src\camera.c
文件 1237 2007-01-21 01:40 net_camera\src\print.c
文件 2593 2007-03-13 09:09 net_camera\src\server.c
文件 458 2007-03-13 09:32 net_camera\src\test.c
文件 4837 2007-03-13 14:37 net_camera\src\th_server.c
文件 5589 2007-03-13 13:03 net_camera\test.jpeg
目录 0 2011-03-22 16:16 net_camera\bin
目录 0 2011-03-22 16:16 net_camera\include
目录 0 2011-03-22 16:16 net_camera\src
目录 0 2011-03-22 16:16 net_camera
----------- --------- ---------- ----- ----
59373 15
- 上一篇:oephuc.doc
- 下一篇:《计算机图形学》课后题答案
相关资源
- oephuc.doc
- 百度分享地址.txt
- win2003sp2_r2_std.rar
- DarkShell_无限制版_VIP专用版.rar
- 组态王说明.txt
- HMM.sln
- 学生宿舍管理毕业设计.rar
- FTP课程设计.rar
- 5000-50003.61.rar
- SAPGUI750客户端.txt
- 展讯各芯片介绍.rar
- viqecel_10287298.zip
- iDRAC9-Ent-Eval.7z
- cuda.txt
- maxcms4.0.wpm
- 0kevpj.doc
- altiumdesigner10.972.23595破解.zip
- 学生信息管理系统.txt
- 2048.rar
- 温度检测.zip
- MBAXP(ModbusActiveXPro)破解版.rar
- 新建文本文档(2).zip
- Dict.dic
- spwp.tar
- VisualC.NET串口通信及测控应用典型程序
- p99hd4.txt
- v3fe32.rar
- u014559227_8667093.zip
- Tom的机器学习中文版byOneRoad.rar
- Kmeans.zip
评论
共有 条评论