資源簡介
jetson tk1 平臺上的 ov5640驅(qū)動 以及應(yīng)用捕獲程序,已驗證

代碼片段和文件信息
#include?
/*?Verification?Test?Environment?Include?Files?*/
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#define?TEST_BUFFER_NUM?3
struct?testbuffer
{
????????unsigned?char?*start;
????????size_t?offset;
????????unsigned?int?length;
};
struct?testbuffer?buffers[TEST_BUFFER_NUM];
int?g_in_width?=?176;
int?g_in_height?=?144;
int?g_out_width?=?176;
int?g_out_height?=?144;
int?g_top?=?0;
int?g_left?=?0;
int?g_input?=?0;
int?g_capture_count?=?100;
int?g_rotate?=?0;
int?g_cap_fmt?=?V4L2_PIX_FMT_UYVY;
int?g_camera_framerate?=?30;
int?g_extra_pixel?=?0;
int?g_capture_mode?=?0;
char?g_v4l_device[100]?=?“/dev/video0“;
static?void?print_pixelformat(char?*prefix?int?val)
{
printf(“%s:?%c%c%c%c\n“?prefix???prefix?:?“pixelformat“
val?&?0xff
(val?>>?8)?&?0xff
(val?>>?16)?&?0xff
(val?>>?24)?&?0xff);
}
int?start_capturing(int?fd_v4l)
{
????????unsigned?int?i;
????????struct?v4l2_buffer?buf;
????????enum?v4l2_buf_type?type;
????????for?(i?=?0;?i?????????{
????????????????memset(&buf?0?sizeof?(buf));
????????????????buf.type?=?V4L2_BUF_TYPE_VIDEO_CAPTURE;
????????????????buf.memory?=?V4L2_MEMORY_MMAP;
buf.index?=?i;
????????????????if?(ioctl(fd_v4l?VIDIOC_QUERYBUF?&buf)?0)
????????????????{
????????????????????????printf(“VIDIOC_QUERYBUF?error\n“);
????????????????????????return?-1;
????????????????}
????????????????buffers[i].length?=?buf.length;
????????????????buffers[i].offset?=?(size_t)?buf.m.offset;
????????????????buffers[i].start?=?mmap?(NULL?buffers[i].length
????????????????????PROT_READ?|?PROT_WRITE?MAP_SHARED
????????????????????fd_v4l?buffers[i].offset);
memset(buffers[i].start?0xFF?buffers[i].length);
????????}
????????for?(i?=?0;?i?????????{
????????????????memset(&buf?0?sizeof?(buf));
????????????????buf.type?=?V4L2_BUF_TYPE_VIDEO_CAPTURE;
????????????????buf.memory?=?V4L2_MEMORY_MMAP;
????????????????buf.index?=?i;
buf.m.offset?=?buffers[i].offset;
if?(g_extra_pixel){
????????????????buf.m.offset?+=?g_extra_pixel?*
???????????????? (g_out_width?+?2?*?g_extra_pixel)?+?g_extra_pixel;
}
????????????????if?(ioctl?(fd_v4l?VIDIOC_QBUF?&buf)?0)?{
????????????????????????printf(“VIDIOC_QBUF?error\n“);
????????????????????????return?-1;
????????????????}
????????}
????????type?=?V4L2_BUF_TYPE_VIDEO_CAPTURE;
????????if?(ioctl?(fd_v4l?VIDIOC_STREAMON?&type)?0)?{
????????????????printf(“VIDIOC_STREAMON?error\n“);
????????????????return?-1;
????????}
????????return?0;
}
int?stop_capturing(int?fd_v4l)
{
????????enum?v4l2_buf_type?type;
????????type?=?V4L2_BUF_TYPE_VIDEO_CAPTURE;
????????return?ioctl?(fd_v4l?VIDIOC_STREAMOFF?&type);
}
int?v4l_capture_setup(void)
{
????????struct?v4l2_format?f
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????50964??2017-06-07?10:58??ov5640_v4l2_0607.c
?????文件????????3592??2017-04-14?10:11??ov5640驅(qū)動tk1移植.txt
?????文件???????11063??2017-06-08?17:35??capture.c
評論
共有 條評論