摄像头画面显示的程序比较简单,友善之臂的光盘里面已经提供了相关的代码,这里对其进行简单的封装,以便后续工程的使用。
首先从main函数看起,代码如下。
/*
* main.cpp
*
* Created on: 2015年12月4日
* Author: Westlor
*/
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include "camera.h"
#include "Fb.h"
#define CAM_DEV "/dev/video0"
#define FB_DEV "/dev/fb0"
Camera *camera;
Fb *fb;
void sign_func(int sign_num)
{
switch(sign_num)
{
case SIGINT:
printf("I have get SIGINT<Ctrl+c>, I'm going now..\n");
camera->CloseDevice();
fb->CloseDevice();
exit(0);
break;
}
}
int main(void) {
int width=640;
int height=480;
unsigned char* image;
camera=new Camera(CAM_DEV, width, height);
if(!camera->OpenDevice()){
printf("Cam Open error\n");
return -1;
}
fb = new Fb(FB_DEV, 80, 0, width, height);
if(!fb->OpenDevice()){


1085

被折叠的 条评论
为什么被折叠?



