arm 视频采集系统

2019-07-16 09:34发布

s3c2410板子,zc301摄像头采集图像,利用framebuffer在LCD上显示,利用jpeglib.h解压图像时,出现错误,如图所示:程序源码如下;    请各位大神帮忙指点一下,,谢谢啦   /usr/include/jpeglib.h:914:parse error before "FILE"
#include <sys/types.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <linux/fb.h>
#include <jpeglib.h>
#include <jerror.h>
#include "v4l.c"
#include "v4l.h"
#include <stdio.h>
#include <stdlib.h>
//#include <unistd.h>
//#include <fcntl.h>
//#include <string.h>
//#include <linux/fb.h>

#define norm VIDEO_MODE_NTSC
#define DEFAULT_FIL_NAME "picture"
unsigned short RGB888toRGB555(unsigned char red,unsigned char green,unsigned char blue)
{unsigned short B=(blue>>3)&0x001F;
unsigned short G=((green>>2)<<5)%0x07E0;
unsigned short R=((red>>3)<<11)&0xF800;
return (unsigned short )(R|G|B);
}
int fb_pixel(void *fbmem,int width,int height,int x,int y,unsigned short color)
{if((x>width)||(y>height))
    return (-1);
unsigned short *dst=((unsigned short *)fbmem+y*width+x);
*dst=color;
return 0;
}
int main()
{int fbfd=0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
long int screensize=0;
char *fbp=0;
int x=0,y=0;
long int location=0;
int sav=0;
fbfd=open("/dev/fb0",O_RDWR);
if(!fbfd){
printf("Error:can't open framebuffer device. ");
exit(1);
}
printf("the framebufffer device was opened successfully. ");
if(ioctl(fbfd,FBIOGET_FSCREENINFO,&finfo)){
printf("Error:read fixed information . ");
exit(2);
}
if(ioctl(fbfd,FBIOGET_VSCREENINFO,&vinfo)){
printf("Error:reading variable information. ");
exit(3);
}
printf("vinfo.xres=%d ",vinfo.xres);
printf("vinfo.yres=%d ",vinfo.yres);
printf("vinfo.bits_per_bits=%d ",vinfo.bits_per_pixel);
printf("vinfo.xoffset=%d ",vinfo.xoffset);
printf("vinfo.yoffset=%d ",vinfo.yoffset);
printf("finfo.line_length=%d ",finfo.line_length);
screensize=vinfo.xres*vinfo.yres*vinfo.bits_per_pixel/8;
fbp=(char *)mmap(NULL,screensize,PROT_READ|PROT_WRITE,MAP_SHARED,fbfd,0);
if((int)fbp==-1){
printf("Error:failed to map framebuffer device to memory. ");
exit(4);
}
printf("the framebuffer device was mapped to memory successfully. ");



   int i=1;
   v4ldevice VD;
    v4ldevice  *vd=&VD;
    char *buffer=NULL;

    v4l_open("/dev/video0",vd); //打开设备

   v4l_grab_init(vd,NTSC_WIDTH,NTSC_HEIGHT);
    v4l_mmap_init(vd);

    //开始获取图     
     v4l_grab_sync(vd,vd->frame_current);//等待传完一帧



   while(1)
  {   vd->frame_current^=1;
     v4l_grab_start(vd,vd->frame_current);
     v4l_grab_sync(vd,vd->frame_current);
        buffer=(char *)v4l_get_address(vd);//得到这一帧的地址
        printf("img address %p ",buffer);

   struct jpeg_decompress_struct cinfo;
   struct jpeg_error_mgr jerr;
   FILE  * infile;
  // (void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile));

   unsigned char *buffer1;
   if((infile=fopen(buffer,"rb"))==NULL){
   fprintf(stderr,"open %s failed ",*buffer);
   exit(-1);
   }
   cinfo.err=jpeg_std_error(&jerr);
   jpeg_create_decompress(&cinfo);
   jpeg_stdio_src(&cinfo,infile);
   jpeg_read_header(&cinfo,TRUE);
   jpeg_start_decompress(&cinfo);
   if((cinfo.output_width>vinfo.xres)||(cinfo.output_height>vinfo.yres)){
   printf("too large JPEG file,can't display ");
   return (-1);
   }
   buffer1=(unsigned char *)malloc(cinfo.output_width*cinfo.output_components);
   y=0;
   while(cinfo.output_scanline<cinfo.output_height){
   jpeg_read_scanline(&cinfo,&buffer1,1);
   if(vinfo.bits_per_pixel==16){
   unsigned short color;
   for(x=0;x<cinfo.output_width;x++){
   color=RGB888toRGB565(buffer1[x*3],buffer1[x*3+1],buffer1[x*3+2]);
   fb_pixel(fbp,vinfo.xres,vinfo.yres,x,y,color);
   }
   }else if(vinfo.bits_per_pixel==24){
   memcpy((unsigned char *)fbp+y*vinfo.xres*3,buffer1,cinfo.output_width*cinfo.output_components);
   }
   y++;
   }
   jpeg_finish_decompress(&cinfo);
   jpeg_destroy_decompress(&cinfo);
   free(buffer1);
   fclose(infile);   
  }
    v4l_close(vd);
   return 0;   
}





QQ截图20140322221412.png
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
5条回答
下一站;飞翔
1楼-- · 2019-07-16 09:54
平台:   redhat 9.0
woodmice
2楼-- · 2019-07-16 09:56
解析错误,将含 FILE 定义的 #include <stdio.h> 移到 #include <jpeglib.h> 前面试一下?
wuchangwei
3楼-- · 2019-07-16 10:28
 精彩回答 2  元偷偷看……
z00
4楼-- · 2019-07-16 10:59
解析错误

Applications using the JPEG library should include the header file jpeglib.h to obtain declarations of data types and routines. Before including jpeglib.h, include system headers that define at least the typedefs FILE and size_t. On ANSI-conforming systems, including <stdio.h> is sufficient; on older Unix systems, you may need <sys/types.h> to define size_t.

将含 FILE 定义的 stdio.h移到 jpeglib.h前面
愤怒的企鹅
5楼-- · 2019-07-16 16:41
头文件放置有问题

一周热门 更多>