-
大小: 4KB文件類(lèi)型: .rar金幣: 2下載: 0 次發(fā)布日期: 2021-05-25
- 語(yǔ)言: 其他
- 標(biāo)簽: linux??操作系統(tǒng)??usb??
資源簡(jiǎn)介
采用的攝像頭是現(xiàn)代的,uvc免驅(qū)動(dòng)的,如果想改為單usb攝像頭的話只需要稍微修改一下就行了,linux內(nèi)核版本采用的是2.6.30的,其他版本應(yīng)該也能用

代碼片段和文件信息
#include?
#include?
#include?
#include?
#include????????????
#include?????????????
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?“fbg.h“
#include?????????
#include?
#define?CLEAR(x)?memset?(&(x)?0?sizeof?(x))
#define?PIC_NUM?100
int width=176?height=144ichoiceflag;
int? fd0fd1fd2;
unsigned?char *rgb888_buf?=?NULL;
unsigned?char *rgb565_buf?=?NULL;
static?unsigned?int?????n_buffers???????=?0;
int byte_sizesize;
static?unsigned?long? file_length;
static?char?*???????????dev_name1????????=?“/dev/video0“;//攝像頭設(shè)備名
static?char?*???????????dev_name2????????=?“/dev/video1“;//攝像頭設(shè)備名
struct?buffer?*?????????buffers1?????????=?NULL;
struct?buffer?*?????????buffers2?????????=?NULL;
struct?buffer?{
????????void?*??????????????????start;
????????size_t??????????????????length;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////
int?convert_yuv_to_rgb_pixel(int?y?int?u?int?v)
{
??unsigned?int?pixel32?=?0;
??unsigned?char?*pixel?=?(unsigned?char?*)&pixel32;
??int?r?g?b;
??r?=?y?+?(int)((1.370705?*?((float)(v-128))));
??g?=?y?-?(int)((0.698001?*?((float)(v-128))))?-?(int)((0.337633?*?((float)(u-128))));
??b?=?y?+?(int)((1.732446?*?((float)(u-128))));
??if(r?>?255)?r?=?255;
??if(g?>?255)?g?=?255;
??if(b?>?255)?b?=?255;
??if(r?0)?r?=?0;
??if(g?0)?g?=?0;
??if(b?0)?b?=?0;
?
??pixel[0]?=?b?*?31?/?255;
??pixel[1]?=?r?*?31?/?255;
??pixel[2]?=?g?*?63?/?255;
??return?pixel32;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
int?convert_yuv_to_rgb_buffer(unsigned?char?*yuv?unsigned?char?*rgb?unsigned?int?width?unsigned?int?height)
{
??unsigned?int?in?out?=?0;
??unsigned?int?pixel_16;
??unsigned?char?pixel_24[3];
??unsigned?int?pixel32;
??int?y0?u?y1?v;
??for(in?=?0;?in? pixel_16?=?yuv[in?+?3]?<24?|?yuv[in?+?2]?<16?|?yuv[in?+?1]?<?8?|?yuv[in?+?0];
y0?=?(pixel_16?&?0x000000ff);
u??=?(pixel_16?&?0x0000ff00)?>>??8;
y1?=?(pixel_16?&?0x00ff0000)?>>?16;
v??=?(pixel_16?&?0xff000000)?>>?24;
pixel32?=?convert_yuv_to_rgb_pixel(y0?u?v);
pixel_24[0]?=?(pixel32?&?0x000000ff);
pixel_24[1]?=?(pixel32?&?0x0000ff00)?>>?8;
pixel_24[2]?=?(pixel32?&?0x00ff0000)?>>?16;
rgb[out++]?=?pixel_24[0];
rgb[out++]?=?pixel_24[1];
rgb[out++]?=?pixel_24[2];
pixel32?=?convert_yuv_to_rgb_pixel(y1?u?v);
pixel_24[0]?=?(pixel32?&?0x000000ff);
pixel_24[1]?=?(pixel32?&?0x0000ff00)?>>?8;
pixel_24[2]?=?(pixel32?&?0x00ff0000)?>>?16;
rgb[out++]?=?pixel_24[0];
rgb[out++]?=?pixel_24[1];
rgb[out++]?=?pixel_24[2];
??}
??return?0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
void?convert_rgb888_to_rgb565_buffer(unsign
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件???????2423??2011-06-22?10:03??fbg.h
?????文件????????412??2011-06-22?10:03??Makefile
?????文件??????13191??2011-06-22?10:03??v4l2test.c
-----------?---------??----------?-----??----
????????????????16026????????????????????3
評(píng)論
共有 條評(píng)論