当前位置: 首页 > wzjs >正文

怎么制作干花seo模拟点击算法

怎么制作干花,seo模拟点击算法,嘉定网站建设,网站劫持代码文章目录 1、前言2、环境介绍3、步骤4、应用程序编写5、测试5.1、编译应用程序5.2、运行应用程序 6、总结 1、前言 在查看摄像头类型时,大致可以分为两类:Video Capture 和 Video Capture Multiplanar。 本次应用程序主要针对类型为Video Capture的相机…

文章目录

  • 1、前言
  • 2、环境介绍
  • 3、步骤
  • 4、应用程序编写
  • 5、测试
    • 5.1、编译应用程序
    • 5.2、运行应用程序
  • 6、总结

1、前言

在查看摄像头类型时,大致可以分为两类:Video Capture 和 Video Capture Multiplanar。

本次应用程序主要针对类型为Video Capture的相机。

2、环境介绍

rk3566 + uvc摄像头

3、步骤

应用程序编写主要分为以下几个步骤:

1、打开设备节点。

2、查询设备能力。

3、枚举支持的视频格式。

4、设置格式。

5、请求buffer。

6、buffer入队列。

7、打开相机。

8、buffer出队列。

9、保存图片。

10、buffer重新入队列。

11、关闭相机。

4、应用程序编写

完整的应用程序如下:

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <linux/types.h>          
#include <linux/videodev2.h>
#include <poll.h>
#include <sys/mman.h>
#include <jpeglib.h>
#include <linux/fb.h>#define FRAME_SIZE_X    640
#define FRAME_SIZE_Y    480int main(int argc, char **argv)
{int ret;int fd;struct v4l2_fmtdesc fmtdesc;struct v4l2_frmsizeenum fsenum;void *bufs[32];int fmt_index = 0;int frame_index = 0;int buf_cnt;int i;int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;struct pollfd fds[1];char filename[32];int file_cnt = 0;if (argc != 2){printf("Usage: %s </dev/videoX>\n", argv[0]);return -1;}if (argv[1] == NULL)goto _err;/* 1. open /dev/video* */fd = open(argv[1], O_RDWR);if (fd < 0){printf("can not open %s\n", argv[1]);goto _err;}/* 2. query capability */struct v4l2_capability cap;memset(&cap, 0, sizeof(struct v4l2_capability));if (0 == ioctl(fd, VIDIOC_QUERYCAP, &cap)){        if ((cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) {fprintf(stderr, "Error opening device %s: video capture not supported.\n", argv[1]);goto _ioc_querycap_err;}if(!(cap.capabilities & V4L2_CAP_STREAMING)) {fprintf(stderr, "%s does not support streaming i/o\n", argv[1]);goto _ioc_querycap_err;}}else{printf("can not get capability\n");goto _ioc_querycap_err;}/* 3. enum formt */while (1){fmtdesc.index = fmt_index;  fmtdesc.type  = V4L2_BUF_TYPE_VIDEO_CAPTURE;  if (0 != ioctl(fd, VIDIOC_ENUM_FMT, &fmtdesc))break;frame_index = 0;printf("format %s,%d:\n", fmtdesc.description, fmtdesc.pixelformat);while (1){memset(&fsenum, 0, sizeof(struct v4l2_frmsizeenum));fsenum.pixel_format = fmtdesc.pixelformat;fsenum.index = frame_index;/* get framesize */if (ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &fsenum) == 0){printf("\t%d: %d x %d\n", frame_index, fsenum.discrete.width, fsenum.discrete.height);}else{break;}frame_index++;}fmt_index++;}/* 4. set formt */struct v4l2_format fmt;memset(&fmt, 0, sizeof(struct v4l2_format));fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;fmt.fmt.pix.width = FRAME_SIZE_X;fmt.fmt.pix.height = FRAME_SIZE_Y;fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;fmt.fmt.pix.field = V4L2_FIELD_ANY;if (0 == ioctl(fd, VIDIOC_S_FMT, &fmt)){printf("the final frame-size has been set : %d x %d\n", fmt.fmt.pix.width, fmt.fmt.pix.height);}else{printf("can not set format\n");goto _ioc_sfmt_err;}/* 5. require buffer */struct v4l2_requestbuffers rb;memset(&rb, 0, sizeof(struct v4l2_requestbuffers));rb.count = 32;rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;rb.memory = V4L2_MEMORY_MMAP;if (0 == ioctl(fd, VIDIOC_REQBUFS, &rb)){buf_cnt = rb.count;for(i = 0; i < rb.count; i++) {struct v4l2_buffer buf;memset(&buf, 0, sizeof(struct v4l2_buffer));buf.index = i;buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;buf.memory = V4L2_MEMORY_MMAP;if (0 == ioctl(fd, VIDIOC_QUERYBUF, &buf)){/* mmap */bufs[i] = mmap(0, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, buf.m.offset);if(bufs[i] == MAP_FAILED) {printf("Unable to map buffer");goto _err;}}else{printf("can not query buffer\n");goto _err;}            }}else{printf("can not request buffers\n");goto _ioc_reqbufs_err;}/* 6. queue buffer */for(i = 0; i < buf_cnt; ++i) {struct v4l2_buffer buf;memset(&buf, 0, sizeof(struct v4l2_buffer));buf.index = i;buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;buf.memory = V4L2_MEMORY_MMAP;if (0 != ioctl(fd, VIDIOC_QBUF, &buf)){perror("Unable to queue buffer");goto _ioc_qbuf_err;}}/* start camera */if (0 != ioctl(fd, VIDIOC_STREAMON, &type)){printf("Unable to start capture\n");goto _err;}printf("\nstart camera ...\n");while (1){/* poll */memset(fds, 0, sizeof(fds));fds[0].fd = fd;fds[0].events = POLLIN;if (1 == poll(fds, 1, -1)){/* dequeue buffer */struct v4l2_buffer buf;memset(&buf, 0, sizeof(struct v4l2_buffer));buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;buf.memory = V4L2_MEMORY_MMAP;if (0 != ioctl(fd, VIDIOC_DQBUF, &buf)){printf("Unable to dequeue buffer\n");goto _ioc_dqbuf_err;}/* save as .jpg */sprintf(filename, "video_raw_data_%04d.jpg", file_cnt++);int fd_file = open(filename, O_RDWR | O_CREAT, 0666);if (fd_file < 0){printf("can not create file : %s\n", filename);}printf("capture to %s\n", filename);write(fd_file, bufs[buf.index], buf.bytesused);close(fd_file);/* queue buffer */if (0 != ioctl(fd, VIDIOC_QBUF, &buf)){printf("Unable to queue buffer");goto _ioc_qbuf_err;}}}/* close camera */if (0 != ioctl(fd, VIDIOC_STREAMOFF, &type)){printf("Unable to stop capture\n");goto _ioc_streamoff_err;}close(fd);return 0;_ioc_qbuf_err:
_ioc_reqbufs_err:
_ioc_sfmt_err:
_ioc_querycap_err:
_ioc_streamoff_err:
_ioc_dqbuf_err:
_err:return -1;
}

5、测试

5.1、编译应用程序

如果你使用的buildroot系统,需要交叉编译。

这里测试所使用的板子跑的是ubuntu,执行如下命令直接编译:

sudo gcc -o uvc_to_jpg uvc_to_jpg.c 

5.2、运行应用程序

sudo ./uvc_to_jpg /dev/video10

查看某一张jpg图片:

6、总结

源码gitee仓库:

仓库主页:
https://gitee.com/cattle_l/v4l2_app.git
直接拉取:
git clone https://gitee.com/cattle_l/v4l2_app.git
http://www.dtcms.com/wzjs/301675.html

相关文章:

  • 苏州网站制作的公司友情链接平台哪个好
  • 为什么做动漫短视频网站模板网站建设开发
  • 有没有专门做飞卢小说盗版的网站挖掘关键词工具
  • 网上虚拟银行注册网站学生个人网页制作html代码
  • wordpress网站源码软文网站推荐
  • 宜家有做自己的网站吗收录是什么意思
  • 常州工厂网站建设鸣蝉智能建站
  • 制作网站的最新软件是什么seo优化关键词放多少合适
  • 做企业形象网站今日十大热点新闻
  • WORDPRESS导航条固定seo快速提升排名
  • 九九建筑网网站性能优化
  • 西安做营销型网站建设百度搜索推广的五大优势
  • 烟台网站建设九七搜索引擎广告形式有
  • 互联网网站制作公司临沂seo建站
  • 泰安网站推广 泰安网站建设东莞网站制作十年乐云seo
  • 网站开发 .net站长工具查询域名
  • 网站搜索结果页面怎么做seo网站内容优化
  • 合肥网站制作价格超级seo外链工具
  • 济南网站开发建设拉新推广怎么找渠道
  • 织梦手机网站制作石家庄网站建设seo
  • 郑州的网站建设公司有哪些中国进入一级战备状态了吗
  • 中国建设银行官网站电脑版谷歌浏览器 安卓下载2023版
  • 怎么免费网做百度收录的网站吗永久免费的培训学校管理软件
  • 东莞长安网站建设关键词提取工具app
  • 企业做网站应注意什么下载app到手机上并安装
  • 如何不要钱做网站公司怎么推广网络营销
  • 网站装修的代码怎么做的优化网站关键词的技巧
  • 服务好的企业做网站成都seo培
  • 工程公司是做什么的福州seo建站
  • 如果我的网站被百度收录了_以后如何做更新争取更多收录郴州seo