android攝像頭(camera)之 V4L2程式設計中用到的各種結構體
阿新 • • 發佈:2019-01-24
2,查詢buffer資訊:
struct v4l2_buffer buf
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.index = 2; //查詢第二個buffer的資訊
ret = ioctl(dev_fd, VIDIOC_QUERYBUF, &buf);
LOGD("buf.m.offset = 0x%x\n", buf.m.offset);
LOGD("buf.length; = 0x%x\n", buf.length);
3,將buffer放入工作佇列中,準備排程:
struct v4l2_buffer buf;
memset(&buf, 0 ,sizeof(struct v4l2_buffer));
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
buf.index = 2; //將第二個buffer放入佇列
ret = ioctl(dev_fd, VIDIOC_QBUF, &buf);
4,將已經填充圖形資料的buffer出佇列:
struct v4l2_buffer dq_buf;
memset(&dq_buf, 0 ,sizeof(struct v4l2_buffer));
dq_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
dq_buf.memory = V4L2_MEMORY_MMAP;
ret = ioctl(dev_fd, VIDIOC_DQBUF, &dq_buf);
return dq_buf.index ;
ioctl返回時dq_buf中,核心應經告知到底是哪個buffer出了佇列
===================================================================================
開始抓取圖片:
int type = V4L2_BUF_TYPE_VIDEO_CAPTURE; //為1
ioctl(dev_fd, VIDIOC_STREAMOFF, &type);
第三個採引數時就是給一個整型指標
停止獲取影象
int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
struct v4l2_buffer buf
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.index = 2; //查詢第二個buffer的資訊
ret = ioctl(dev_fd, VIDIOC_QUERYBUF, &buf);
LOGD("buf.m.offset = 0x%x\n", buf.m.offset);
LOGD("buf.length; = 0x%x\n", buf.length);
3,將buffer放入工作佇列中,準備排程:
struct v4l2_buffer buf;
memset(&buf, 0 ,sizeof(struct v4l2_buffer));
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
buf.index = 2; //將第二個buffer放入佇列
ret = ioctl(dev_fd, VIDIOC_QBUF, &buf);
4,將已經填充圖形資料的buffer出佇列:
struct v4l2_buffer dq_buf;
memset(&dq_buf, 0 ,sizeof(struct v4l2_buffer));
dq_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
dq_buf.memory = V4L2_MEMORY_MMAP;
ret = ioctl(dev_fd, VIDIOC_DQBUF, &dq_buf);
return dq_buf.index ;
ioctl返回時dq_buf中,核心應經告知到底是哪個buffer出了佇列
===================================================================================
開始抓取圖片:
int type = V4L2_BUF_TYPE_VIDEO_CAPTURE; //為1
ioctl(dev_fd, VIDIOC_STREAMOFF, &type);
第三個採引數時就是給一個整型指標
停止獲取影象
int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;