widget.h头文件代码
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <jpeglib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <getopt.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <malloc.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <asm/types.h>
#include <linux/videodev2.h>
#include<QImage>
#include<QDebug>
#include<QTimer>
#define CAMERA_DEVICE "/dev/video0"
#define CAPTURE_FILE "yuyv.dat"
#define VIDEO_WIDTH 640
#define VIDEO_HEIGHT 480
#define VIDEO_FORMAT V4L2_PIX_FMT_YUYV
#define BUFFER_COUNT 1
typedef struct VideoBuffer {
void *start;
size_t length;
} VideoBuffer;
typedef long LONG;
typedef unsigned long DWORD;
typedef unsigned short WORD;
typedef struct {
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} BMPFILEHEADER_T;
typedef struct{
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BMPINFOHEADER_T;
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
int Camera_RequestBuffers(struct v4l2_requestbuffers *reqbuf__);
int convert_yuv_to_rgb_pixel(int y, int u, int v);
void Camera_RecordYUYV(struct v4l2_buffer *buf_,int width,int height);
int Camera_EnQueueBuffer(struct v4l2_buffer *buf_);
int Camera_DeQueueBufferGetFrame( struct v4l2_buffer *buf_);
int Camera_StartCameraStreaming();
void Camera_UNMap(VideoBuffer *framebuf_);
int Camera_MapAndEnqueue(struct v4l2_requestbuffers *reqbuf__, struct v4l2_buffer *buf__,VideoBuffer *framebuf_);
int Camera_SetCamFMT();
int Camera_GetCamInfo();
int Camera_OpenCam();
void savebmp(unsigned char * pdata, int width, int height );
void trans_picture(int width,int height);
int Camera_CloseCam();
int convert_yuv_to_rgb_buffer(unsigned char *yuv, unsigned char *rgb, unsigned int width,unsigned int height);
int fd_cam ;
struct v4l2_requestbuffers reqbuf;
struct v4l2_buffer buf;
VideoBuffer framebuf1[BUFFER_COUNT];
QTimer* time1;
public slots:
void DisplayVideo();
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
#ifndef WIDGET_H
#define WIDGET