[原创]基于 Blackfin DSP摄像头图像捕捉程序
0赞
发表于 4/11/2012 10:51:16 PM
阅读(12470)
读了陈锋老师的《基于 Blackfin DSP图像处理》,感触很深啊,能给人很多想法,ADI的Blackfin 果然强悍。
趁着热乎劲,自己写了个基于Blackfin的摄像头画面扑捉程序,生成的图像是 JPEG,程序比较长,我把我的关键程序给大家展示一下,
主要是main函数这部分,希望大家能一起探讨!
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "spcav4l.h"
struct vdIn videoIn;
int main (int argc, char *argv[])
{
char videodevice[] = "/dev/video0";
char jpegfile[] = "/tmp/1.jpg";
int grabmethod = 0;
int format = VIDEO_PALETTE_JPEG;
int width = 352;
int height = 288;
{
char videodevice[] = "/dev/video0";
char jpegfile[] = "/tmp/1.jpg";
int grabmethod = 0;
int format = VIDEO_PALETTE_JPEG;
int width = 352;
int height = 288;
memset(&videoIn, 0, sizeof (struct vdIn));
if(init_videoIn(&videoIn, videodevice, width, height, format,grabmethod)== 0)
{
v4lGrab(&videoIn, jpegfile);
if(grabmethod==1)
printf("you use mmap method!\n");
else if(grabmethod==0)
printf("you use read method!\n");
printf("you have get a picture in %s\n",jpegfile);
}
else
printf("can't open your camera!\n");
close_v4l (&videoIn);
return 0;
}
if(init_videoIn(&videoIn, videodevice, width, height, format,grabmethod)== 0)
{
v4lGrab(&videoIn, jpegfile);
if(grabmethod==1)
printf("you use mmap method!\n");
else if(grabmethod==0)
printf("you use read method!\n");
printf("you have get a picture in %s\n",jpegfile);
}
else
printf("can't open your camera!\n");
close_v4l (&videoIn);
return 0;
}
程序比较简单,就不划流程图了,大家有兴趣的可以和我交流哦!