相机测试:

 #include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <sys/mman.h>
#include <assert.h>
#include <linux/videodev2.h>
#include <linux/fb.h> #define CLEAR(x) memset(&(x), 0, sizeof(x))
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned int DWORD;
typedef long LONG; #define CHECKNUM 8 struct {
unsigned int type;
char *name;
} enum_fmt[]={
{V4L2_CAP_VIDEO_CAPTURE, "V4L2_CAP_VIDEO_CAPTURE"},
{V4L2_CAP_VIDEO_OUTPUT, "V4L2_CAP_VIDEO_OUTPUT"},
{V4L2_CAP_VIDEO_OVERLAY, "V4L2_CAP_VIDEO_OVERLAY"},
{V4L2_CAP_VIDEO_CAPTURE_MPLANE, "V4L2_CAP_VIDEO_CAPTURE_MPLANE"},
{V4L2_CAP_VIDEO_OUTPUT_MPLANE, "V4L2_CAP_VIDEO_OUTPUT_MPLANE"},
{V4L2_CAP_VIDEO_M2M_MPLANE, "V4L2_CAP_VIDEO_M2M_MPLANE"},
{V4L2_CAP_VIDEO_M2M, "V4L2_CAP_VIDEO_M2M"},
{V4L2_CAP_STREAMING, "V4L2_CAP_STREAMING"},
}; int open_camer_device(char *path)
{
int fd; if((fd = open(path,O_RDWR | O_NONBLOCK)) < )
{
perror("Fail to open");
exit(EXIT_FAILURE);
} printf("open cam:%s success %d\n",path, fd);
return fd;
} void enum_video_ctrls_and_menus(int fd){
/*
\* To query the attributes of a control applications set the id field of a struct
\* v4l2_queryctrl and call the VIDIOC_QUERYCTRL ioctl with a pointer to this
\* structure. The driver fills the rest of the structure or returns an EINVAL
\* error code when the id is invalid.
\*
\* To enumerate controls call VIDIOC_QUERYCTRL with successive
\* id values starting from V4L2_CID_BASE up to and exclusive V4L2_CID_LASTP1,
\* or starting from V4L2_CID_PRIVATE_BASE until the driver returns EINVAL.
*/
struct v4l2_queryctrl queryctrl; /* Query Control structure as defined in <sys/videodev2.h> */
struct v4l2_querymenu querymenu; /* Query Menu Structure as defined in <sys/videodev2.h> */ fprintf(stdout,"Discovering controls:\n"); memset (&queryctrl, , sizeof (queryctrl));
for (queryctrl.id = V4L2_CID_BASE; queryctrl.id < V4L2_CID_LASTP1; queryctrl.id++) {
if ( ioctl (fd, VIDIOC_QUERYCTRL, &queryctrl) == ) {
/* Check to see if this control is permanently disabled and should be ignored by the application */
if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED)
continue;
/* We got a video control back */
fprintf(stdout,"\nVIDIOC_QUERYCTRL(V4L2_CID_BASE+%d)\n", queryctrl.id-V4L2_CID_BASE);
fprintf(stdout," id: %d\n", queryctrl.id);
switch (queryctrl.type){
case V4L2_CTRL_TYPE_INTEGER:
fprintf(stdout, " type: INTEGER\n");
break;
case V4L2_CTRL_TYPE_BOOLEAN:
fprintf(stdout, " type: BOOLEAN\n");
break;
case V4L2_CTRL_TYPE_MENU:
fprintf(stdout, " type: MENU\n");
/* Additional information is required for menu controls, the name of menu items.
\* To query them applications set the id and index fields of struct v4l2_querymenu
\* and call the VIDIOC_QUERYMENU ioctl with a pointer to this structure. The driver
\* fills the rest of the structure or returns an EINVAL error code when the id or
\* index is invalid. Menu items are enumerated by calling VIDIOC_QUERYMENU with
\* successive index values from struct v4l2_queryctrl minimum (0) to maximum, inclusive.
*/
querymenu.id = queryctrl.id;
for (querymenu.index = queryctrl.minimum; querymenu.index < queryctrl.maximum; querymenu.index++){
fprintf(stdout, " menu id:%d\n", querymenu.index);
fprintf(stdout, " menu name:%s\n", querymenu.name);
}
break;
case V4L2_CTRL_TYPE_BUTTON:
fprintf(stdout, " type: BUTTON\n");
break;
}
fprintf(stdout," name: %s\n", queryctrl.name);
fprintf(stdout," minimum: %d\n", queryctrl.minimum);
fprintf(stdout," maximum: %d\n", queryctrl.maximum);
fprintf(stdout," step: %d\n", queryctrl.step);
fprintf(stdout," default_value: %d\n", queryctrl.default_value);
fprintf(stdout," flags: %d\n", queryctrl.flags);
} else { if (errno == EINVAL)
continue; perror("VIDIOC_QUERYCTRL");
break;
} } } /* End of enum_video_ctrls_and_menus() */ int main(int argc, char** argv)
{
int fd;
struct v4l2_fmtdesc fmt;
struct v4l2_capability cap;
struct v4l2_format stream_fmt;
struct v4l2_input input;
struct v4l2_control ctrl;
struct v4l2_streamparm stream;
int err;
int ret;
int i; if (argc < ) {
// printusage(argv[0]);
printf("please input path\n");
return -;
}
fd = open_camer_device(argv[]); for(i = ; i < CHECKNUM; i++)
{
memset(&fmt,,sizeof(fmt));
fmt.index = ;
fmt.type = enum_fmt[i].type;
//printf("enum_fmt:%s\n", enum_fmt[i].name);
while((ret = ioctl(fd,VIDIOC_ENUM_FMT,&fmt)) == )
{
fmt.index ++ ;
printf("%s:{pixelformat = %c%c%c%c},description = '%s'\n",
enum_fmt[i].name,
fmt.pixelformat & 0xff,(fmt.pixelformat >> )&0xff,
(fmt.pixelformat >> ) & 0xff,(fmt.pixelformat >> )&0xff,
fmt.description);
}
}
printf("\n\n");
enum_video_ctrls_and_menus(fd);
//查询视频设备支持的功能
ret = ioctl(fd,VIDIOC_QUERYCAP,&cap);
if(ret < ){
perror("FAIL to ioctl VIDIOC_QUERYCAP");
//exit(EXIT_FAILURE);
}
//printf("capabilities:%08x\n", cap.capabilities);
printf("\ncheck the support capabilities\n");
for(i = ; i < CHECKNUM; i++)
{
if(cap.capabilities & enum_fmt[i].type)
printf("%s\n",enum_fmt[i].name);
}
printf("\n");
if(!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE))
{
printf("The Current device is not a video capture device\n");
//exit(EXIT_FAILURE); }
else
printf("The Current device is a video capture device\n");
if(!(cap.capabilities & V4L2_CAP_STREAMING))
{
printf("The Current device does not support streaming i/o\n");
//exit(EXIT_FAILURE);
}
else
printf("The Current device support streaming i/o\n"); return ;
}

linux_cam_test文件的更多相关文章

  1. Mapreduce的文件和hbase共同输入

    Mapreduce的文件和hbase共同输入 package duogemap;   import java.io.IOException;   import org.apache.hadoop.co ...

  2. mapreduce多文件输出的两方法

    mapreduce多文件输出的两方法   package duogemap;   import java.io.IOException;   import org.apache.hadoop.conf ...

  3. 01.SQLServer性能优化之----强大的文件组----分盘存储

    汇总篇:http://www.cnblogs.com/dunitian/p/4822808.html#tsql 文章内容皆自己的理解,如有不足之处欢迎指正~谢谢 前天有学弟问逆天:“逆天,有没有一种方 ...

  4. SQL Server 大数据搬迁之文件组备份还原实战

    一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 解决方案(Solution) 搬迁步骤(Procedure) 搬迁脚本(SQL Codes) ...

  5. SQLSERVER将一个文件组的数据移动到另一个文件组

    SQLSERVER将一个文件组的数据移动到另一个文件组 有经验的大侠可以直接忽视这篇文章~ 这个问题有经验的人都知道怎麽做,因为我们公司的数据量不大没有这个需求,也不知道怎麽做实验 今天求助了QQ群里 ...

  6. SQL Server中的高可用性(2)----文件与文件组

        在谈到SQL Server的高可用性之前,我们首先要谈一谈单实例的高可用性.在单实例的高可用性中,不可忽略的就是文件和文件组的高可用性.SQL Server允许在某些文件损坏或离线的情况下,允 ...

  7. C# ini文件操作【源码下载】

    介绍C#如何对ini文件进行读写操作,C#可以通过调用[kernel32.dll]文件中的 WritePrivateProfileString()和GetPrivateProfileString()函 ...

  8. 【小程序分享篇 一 】开发了个JAVA小程序, 用于清除内存卡或者U盘里的垃圾文件非常有用

    有一种场景, 手机内存卡空间被用光了,但又不知道哪个文件占用了太大,一个个文件夹去找又太麻烦,所以我开发了个小程序把手机所有文件(包括路径下所有层次子文件夹下的文件)进行一个排序,这样你就可以找出哪个 ...

  9. 【原】Android热更新开源项目Tinker源码解析系列之二:资源文件热更新

    上一篇文章介绍了Dex文件的热更新流程,本文将会分析Tinker中对资源文件的热更新流程. 同Dex,资源文件的热更新同样包括三个部分:资源补丁生成,资源补丁合成及资源补丁加载. 本系列将从以下三个方 ...

随机推荐

  1. Nginx反向代理后应用程序获取客户端真实IP

    Nginx反向代理后,Servlet应用通过request.getRemoteAddr()取到的IP是Nginx的IP地址,并非客户端真实IP,通过request.getRequestURL()获取的 ...

  2. web容器启动加载WebApplicationContext和初始化DispatcherServlet

    原文地址:http://blog.csdn.net/zghwaicsdn/article/details/51186915 ContextLoaderListener监听器,加载ROOT WebApp ...

  3. iOS使用UIBezierPath实现ProgressView

    实现效果如下: 界面采用UITableView和TabelViewCell的实现,红色的视图采用UIBezierPath绘制.注意红色的部分左上角,左下角是直角哟!!!!不多说<这里才是用UIB ...

  4. 使用robotframework做接口测试三——保持登录状态

    调用登录接口登录了,其他的接口怎么保持登录状态呢?  首先来看一看,web端或者说客户端是怎么样用cookie/token等保持登录状态的.一般来说,cookie都会在登录接口由服务端返回,而且会是在 ...

  5. 【AMAD】newspaper -- 爬取/提取新闻网页中的文本,元数据

    动机 简介 用法 源码分析 个人评分 动机 新闻网页,结构大多是类似的. 所以,能不能用一种通用的爬取方法来提取其中的数据? 简介 Newspapaer1受到requests那种简单性API的启发,通 ...

  6. CAD常用命令、快捷键和命令说明大全

    CAD常用命令.快捷键和命令说明大全 一:常用功能键 F1: 获取帮助 F2: 实现作图窗和文本窗口的切换 F3: 控制是否实现对象自动捕捉 F4: 数字化仪控制 F5: 等轴测平面切换 F6: 控制 ...

  7. Elasticsearch Metric聚合

    首先查看index文档信息 $ curl -XGET "http://172.16.101.55:9200/_cat/indices?v" 输出 health status ind ...

  8. PostgreSQL查询数据库中包含某种类型的表有哪些

    and c.relnamespace = n.oid and nspname = 'public' and a.atttypid = t.oid and typname = 'TEXT' and c. ...

  9. HanLP-停用词表的使用示例

    停用词表的修改 停用词表在“pyhanlp\static\data\dictionary”路径下的“stopwords.txt”文件中,CoreStopWordDictionary.apply方法支持 ...

  10. mysql 错误号码1129

    SQLyog连接mysql 错误号码1129: mysql error 1129: Host 'bio.chip.org' is blocked because of many connection ...