将YUYV格式转换为jpeg(jpg)的过程中使用libjpeg库,
自己安装了两个版本的库 v62 和 v80 路径不同 (参考 http://webhostingneeds.com/wrong_jpeg_library_version:_library_is_62,_caller_expects_80)
62在/usr/lib 将目录下的所有包换linjpeg的库全部删除
80在/usr/local/lib
链接过程中使用的是/usr/lib,修改ld.so.conf或在ld.so.conf.d文件夹下添加一个新项指定路径
在ld.so.conf.d目录下新建一个jpeg-i386.conf
echo '/usr/local/lib' >jpeg-i386.conf
ldconfig ------------>生效
编译时需要使用 -ljpeg 选项
若出现要求 JPEG_LIB_VERSION版本,将测试程序中添加此定义
#define JPEG_LIB_VERSION 80
不出现不用管
OK
可以成功保存
程序参考 http://blog.youkuaiyun.com/weed_hz/article/details/8939830
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <linux/types.h>
#include <linux/videodev2.h>
#include <setjmp.h>
#include <jpeglib.h>
//#include "jpeglib.h"
//#include "v4l2grab.h"
typedef int BOOL;
#define TRUE 1
#define FALSE 0
#define FILE_VIDEO "/dev/video0"
//#define BMP "image_bmp.bmp"
#define YUV "image_yuv.yuv"
#define JPEG "image_jpeg.jpg"
#define IMAGEWIDTH 1024
#define IMAGEHEIGHT 768
//#define JPEG_LIB_VERSION 62 /*一般在jpeglib.h头文件中进行定义,v62中没有定义所以在此处定义*/
static int fd;
static struct v4l2_capability cap;
struct v4l2_fmtdesc fmtdesc;
struct v4l2_format fmt,fmtack;
struct v4l2_streamparm setfps;
struct v4l2_requestbuffers req;
struct v4l2_buffer buf;
enum v4l2_buf_type type;
unsigned char frame_buffer[IMAGEWIDTH*IMAGEHEIGHT*3];
struct buffer
{
void * start;
unsigned int length;
} * buffers;
int init_v4l2(void)
{
int i;
int ret = 0;
//opendev
if ((fd &#