资源简介
linux下通用的摄像头抓图程序,v4l上直接交叉编译,拷到开发板运行即可
![](http://www.nz998.com/pic/41500.jpg)
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include /* gettimeofday() */
#include
#include
#include
#include
#ifdef HAVE_LIBZ
#include
#endif
#ifdef HAVE_LIBPNG
#include
#endif
#ifdef HAVE_LIBJPEG
#include
#endif
#include “v4l.h“
#define DEF_WIDTH 320 /* default width */
#define DEF_HEIGHT 240 /* default height */
#define FMT_UNKNOWN 0
#define FMT_PPM 1
#define FMT_PGM 2
#define FMT_PNG 3
#define FMT_JPEG 4
#define FMT_YUV4MPEG 5
#define IN_TV 0
#define IN_COMPOSITE 1
#define IN_COMPOSITE2 2
#define IN_SVIDEO 3
#define NORM_PAL 0
#define NORM_NTSC 1
#define NORM_SECAM 2
#define QUAL_DEFAULT 80
char *basename (const char *s);
/* globals
*/
static int verbose = 0;
/*
*/
void
usage (char *pname)
{
fprintf (stderr
“VidCat Version %s\n“
“Usage: %s \n“
“ -b make a raw PPM instead of an ASCII one\n“
“ -d video device (default: “VIDEO_DEV“)\n“
“ -f {ppm|jpeg|png|yuv4mpeg} output format of the image\n“
“ -g greayscale instead of color\n“
“ -i {tv|comp1|comp2|s-video} which input channel to use\n“
“ -l loop on doesn‘t make sense in most cases\n“
“ -n {pal|ntsc|secam} select video norm\n“
“ -o write output to file instead of stdout\n“
“ -p c|g|y|Y videopalette to use\n“
“ -q only for jpeg: quality setting (1-100“
“ default: %d)\n“
“ -s NxN define size of the output image (default:“
“ %dx%d)\n“
“Example: vidcat | xsetbg stdin\n“
VERSION (char*)basename(pname) QUAL_DEFAULT DEF_WIDTH DEF_HEIGHT);
exit (1);
}
/*
*/
double
ms_time (void)
{
static struct timeval tod;
gettimeofday (&tod NULL);
return ((double)tod.tv_sec * 1000.0 + (double)tod.tv_usec / 1000.0);
}
/*
* read rgb image from v4l device 从v4l设备获取rgb图像
* return: mmap‘ed buffer and size
*/
char *
get_image (int dev int width int height int palette int *size)
{
struct video_mbuf vid_buf;
struct video_mmap vid_mmap;
char *map *convmap; //map指向抓到的图片所存空间
int len;
int bytes = 3; //比特每像素
if (palette == VIDEO_PALETTE_GREY) //若为灰度图象
bytes = 1; /* bytes per pixel */
if (ioctl (dev VIDIOCGMBUF &vid_buf) == -1) {
/* to do a normal read()
*/
struct video_window vid_win;
if (verbose) {
fprintf (stderr “using read()\n“);
}
if (ioctl (dev VIDIOCGWIN &vid_win) != -1) {
vid_win.width = width;
vid_win.height = height;
if (ioctl (dev VIDIOCSWIN &vid_win) == -1) {
perror (“ioctl(VIDIOCSWIN)“); //ioctl函数功能??
return (NULL);
}
}
map = malloc (width *
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 16582 2008-11-20 21:30 arm9上摄像头抓图源代码(v4l通用)\vidcat.c
目录 0 2013-01-06 14:28 arm9上摄像头抓图源代码(v4l通用)
----------- --------- ---------- ----- ----
16582 2
相关资源
- uboot到linux logo显示不间断 补丁
- UNIX/LINUX编程实践教程的源码
- Linux任务管理器
- linux应用层的华容道游戏源代码
- ubuntu9.10 可加载内核模块和字符设备驱
- MP3文件ID3v2ID3v2APEv2标签读取
- 操作系统实验——虚存管理实验
- linux下的发包工具sendip
- 尚观培训linux许巍关于c 的笔记和讲义
- 尚观培训linux董亮老师关于数据结构的
- linux 线程池源码 c 版
- linux C 电梯程序练习
- linux下用多进程同步方法解决生产者
- Linux 操作系统实验(全)
- Linux From Scratch 中文手册
- linux 网络实验 ftp程序
- Linux命令大全离线版&在线版
- 操作系统共享内存实验
- dos 下运行Linux 命令--gnu_utils
- delphi摄像头拍照
- linux 0.12内核源代码
- linux简易shell C实现
- linux实验报告及心得体会
- 基于GTK的Linux环境下的简易任务管理器
- linux扫雷游戏代码
- CAN Linux驱动代码
- Linux系统教材
- intel 82579LM 网卡驱动Linux系统版 v1.9.
- SA1110处理器掌上电脑液晶显示器设计
- 基于Linux的串口服务器设计
评论
共有 条评论