大体框架:
1、摄像头读出数据存入VideoBuf
2、将VideoBuf转换成RGB模式(LCD为RGB模式),存入ConvertBuf
3、进行缩放,存入ZoomBuf
4、进行合并,存入FrameBuf
5、LCD读取FrameBuf,进行显示
面对对象编程:
1、VideoDevice
.iPixelFormat
.iWidth
.iHeight
2、VideoOpr
.InitDevice
.ExitDevice
.GetFrame
.PutFrame
.StartDevice
.StopDevice
我们如今只需要一个
所以我们构造:
V4l2VideoOpr
3、ConvertOpr
.isSurpport
.convert
.ConvertExit
我们需要转换:YUV2RGB, MJPEG2RGB, RGB2RGB
所以我们要构造一个Convert_manager.c
然后写三个Yuv2rgb.c mjpeg2rgb.c rgb2rgb.c 然后向Convert_manager.c进行结构体的注册RegisterVideoConvert
4、DispOpr
.DeviceInit
.ShowPixel
.CleanScreen
.ShowPage
需要写两个函数,fb和VGA。一个在屏幕上显示,一个在LCD上显示
我们可以通过main.c便可以看出整个项目的主要流程:
这是在LCD上进行显示的main函数
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <config.h>
#include <disp_manager.h>
#include <video_manager.h>
#include <convert_manager.h>
#include <render.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
/* video2lcd </dev/video0,1,...> */
int main(int argc, char **argv)
{
int iError;
T_VideoDevice tVideoDevice;
PT_VideoConvert ptVideoConvert;
int iPixelFormatOfVideo;
int iPixelFormatOfDisp;
PT_VideoBuf ptVideoBufCur;
T_VideoBuf tVideoBuf;
T_VideoBuf tConvertBuf;
T_VideoBuf tZoomBuf;
T_VideoBuf tFrameBuf;
int iLcdWidth;
int iLcdHeigt;
int iLcdBpp;
int iTopLeftX;
int iTopLeftY;
float k;
if (argc !=