资源简介
linux下通用的摄像头抓图程序,v4l上直接交叉编译,拷到开发板运行即可
代码片段和文件信息
#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
相关资源
- Bluez5.50 arm交叉编译脚本亲测成功
- h5调用手机摄像头
- IIC Linux 应用层的两种操作方式
- nmon工具linux性能32位的
- 飞思卡尔智能车摄像头组完整源代码
- linux网络设备驱动
- 使用DShow进行摄像头采集并拍照
- Linux Wi-Fi open source drivers-mac80211 ath9k
- Linux Device Driver 中文版第三版
- 理发师问题Linux,c
- USB摄像头原理图电路图
- linux下cp2101/2102驱动
- kali linux 2019最新镜像包.txt
- Labwindows摄像头
- 实战Linux编程精髓源代码
- Opencv打开电脑自带USB摄像头并调用模
- ffmpeg摄像头数据h264编码并封装avi
- linux下中断处理程序,含驱动和应用程
- SLE-12-SP1-Server-DVD-x86_64-GM-DVD1
- ov7725数字摄像头编程基本知识笔记
- SLES 11 SP4 x86_64
- 01 [基础] 鸟哥私房菜 - 经典Linux零基础
- 用于jz2440的dht11驱动
- 全套linux运维教程
- linux-tpcc测试
- Centos7.1(1503)国内镜像地址.txt
- linux制作启动u盘工具
- HID 免驱 描述符
- 完整pb调用摄像录像和照相
- linuxredis实战教程视频.txt
评论
共有 条评论