顯示標頭檔案如下:
#ifndef _displayfb_h_
#define _displayfb_h_
extern "c"
#define fb_dev "/dev/fb0"
#define __fnc__ __function__
class cdisplayfb
~cdisplayfb();
public:
int initfb(char * fb_device,const int width,const int height);
int initfb(char * fb_device);
int exitfb();
int copyimagetofb(unsigned char * source, int width,int height);
unsigned short rgb888torgb565(unsigned char red,unsigned char green, unsigned char blue);
int fb_open(char *fb_device);
int fb_close(int fd);
int fb_stat(int fd, unsigned int *width, unsigned int *height, unsigned int * depth);
void *fb_mmap(int fd, unsigned int screensize);
void *fd_mmap(int fd, unsigned int filesize);
int fb_munmap(void *start, size_t length);
int fb_pixel(void *fbmem, int width, int height,
int x, int y, unsigned short color);
public:
int fd;
unsigned char *buffer;
struct stat st;
int fbdev;
char *fb_device;
unsigned char *fbmem;
unsigned char *fdmem;
unsigned int screensize;
unsigned int fb_width;
unsigned int fb_height;
unsigned int fb_depth;
unsigned int x;
unsigned int y;
struct fb_fix_screeninfo fb_finfo;
struct fb_var_screeninfo fb_vinfo;
}; #endif
顯示原始檔如下:
#include "displayfb.h"
int cdisplayfb::fb_open(char *fb_device)
return fd;
}int cdisplayfb::fb_close(int fd)
/* get framebuffer's width, height, and depth.
* return 0 if success, else return -1.
*/int cdisplayfb::fb_stat(int fd, unsigned int *width, unsigned int *height, unsigned int * depth)
if (ioctl(fd, fbioget_vscreeninfo, &fb_vinfo))
*width = fb_vinfo.xres;
*height = fb_vinfo.yres;
*depth = fb_vinfo.bits_per_pixel;
return 0;
}/* map shared memory to framebuffer device.
* return maped memory if success
* else return -1, as mmap dose
*/void * cdisplayfb::fb_mmap(int fd, unsigned int screensize)
return fbmem;
}/* map shared memmory to a opened file */
void *cdisplayfb::fd_mmap(int fd, unsigned int filesize)
return fdmem;
}/* unmap map memory for framebuffer device */
int cdisplayfb::fb_munmap(void *start, size_t length)
/* convert 24bit rgb888 to 16bit rgb565 color format */
unsigned short cdisplayfb::rgb888torgb565(unsigned char red,
unsigned char green, unsigned char blue)
/* display a pixel on the framebuffer device.
* fbmem is the starting memory of framebuffer,
* width and height are dimension of framebuffer,
* width and height are dimension of framebuffer,
* x and y are the coordinates to display,
* color is the pixel's color value.
* return 0 if success, otherwise return -1.
*/int cdisplayfb::fb_pixel(void *fbmem, int width, int height,
int x, int y, unsigned short color)
int cdisplayfb::initfb(char * fb_device,const int width,const int height)
if(fb_height < height)
printf("fb_width= %d \n", fb_width);
printf("fb_height= %d \n",fb_height);
/* map framebuffer device to shared memory */
screensize = fb_width * fb_height * fb_depth / 8;
fbmem = (unsigned char *)fb_mmap(fbdev, screensize);
if (ioctl(fbdev, fbioget_fscreeninfo, &fb_finfo))
printf("ioctl fbioget_fscreeninfo ok\n");
if (ioctl(fbdev, fbioget_vscreeninfo, &fb_vinfo))
printf("ioctl fbioget_vscreeninfo ok\n");
return 0;
}int cdisplayfb::initfb(char * fb_device)
printf("ioctl fbioget_fscreeninfo ok\n");
if (ioctl(fbdev, fbioget_vscreeninfo, &fb_vinfo))
printf("ioctl fbioget_vscreeninfo ok\n");
return 0;
} int cdisplayfb::copyimagetofb(unsigned char * source, int width,int height)
return 0;
}int cdisplayfb::exitfb()
DM8148 攝像頭採集 顯示 識別測試 四
人臉識別檢測標頭檔案 ifndef objdetect h define objdetect h extern c include opencv highgui.h include opencv cv.h include opencv cxcore.h include opencv cvaux.h ...
攝像頭採集方案概述
有人問 cmos攝像頭與usb攝像頭有什麼區別嗎?有人答 cmos指的是感光材料,usb指的是連線方式。又有人答 監控攝像頭的安裝,一般需要使用幾公尺至幾十公尺不等的傳輸距離,但按照usb的標準規定,usb裝置的最長的傳輸距離是5公尺,所以usb都不能長距離使用,這就是我們使用usb攝像頭做監控遇到...
工業攝像頭資訊採集的製作
工業攝像頭資訊採集系統簡介 1 插入攝像頭,安裝驅動vcap2800 usb2.0 drv windows 7 或者vcap2820 sdk,兩者依次嘗試 2將e 大三 攝像頭 usb2800 vcap2820 sdk vcap2820 sdk目錄下的devwdm.ax放到c windows sys...