色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 無線圖像(視頻)傳輸系統(tǒng)ARM9+Atmega16+OV7620+nrf24l01(三)

          無線圖像(視頻)傳輸系統(tǒng)ARM9+Atmega16+OV7620+nrf24l01(三)

          作者: 時(shí)間:2012-09-10 來源:網(wǎng)絡(luò) 收藏

          支持的像素是:VGA(640*480)、QVGA(320*240),我用的是QVGA模式(配合液晶屏顯示)。使用關(guān)鍵還是正確配置其內(nèi)部寄存器,還有就是SCCB數(shù)據(jù)傳輸協(xié)議的實(shí)現(xiàn)。

          本文引用地址:http://cafeforensic.com/article/148440.htm

          首先有必要說下所支持的格式,因?yàn)?,我?a class="contentlabel" href="http://cafeforensic.com/news/listbylabel/label/圖像">圖像這塊不熟悉,這里只說明OV支持的幾種輸出格式,以及相關(guān)寄存器的配置。

          RGB16/8 bit ,這些格式都不是真正的RGB數(shù)據(jù)流,而是Bayer矩陣,所以在終端顯示時(shí),必須將Bayer矩陣轉(zhuǎn)換為RGB。轉(zhuǎn)換的核心思想是通過插值算法將Bayer矩陣中的每個(gè)像素值(一個(gè)字節(jié))轉(zhuǎn)換為RGB三個(gè)字節(jié)(我不懂,只能說出方法,具體算法后面我會貼出)。

          本次采用的是RGB raw16 bit 模式,由于OV7620只引出了Y通道,所以配置為one line mode(這里出現(xiàn)了問題,明明RGB三個(gè)分量都有,但是通過插值后顯示出來的盡然還是灰度圖像,后面再分析原因)。下面貼出OV7620相關(guān)寄存器的配置:

          unsigned char reg_12_w_reset[2]={0x12,0x80};//先清零

          unsigned char reg_11_w[2]={0x11,0x00}; //配置PCLK速率 PCLK=(CLK_input/(CLK5:0>+1)*2)),本次為1/2時(shí)鐘頻率

          unsigned char reg_12_w[2]={0x12,0x2c}; //使能AGC,選擇raw data outtput,并且使能自動白平衡

          unsigned char reg_14_w[2]={0x14,0x24};//QVGA digital output format ,RGB gamma on

          unsigned char reg_28_w[2]={0x28,0xa0}; //one-line RGB data format ,select Progressive scan mode

          下面是Bayer轉(zhuǎn)RGB24的算法(在液晶屏上顯示時(shí)還要轉(zhuǎn)為RGB16):

          void bayer2rgb24(unsigned char *dst, unsigned char *src, long WIDTH, long HEIGHT)

          {

          long int i;

          unsigned char *rawpt, *scanpt;

          long int size;

          rawpt = src;

          scanpt = dst;

          size = WIDTH*HEIGHT;

          for ( i = 0; i size; i++ )

          {

          if ( (i/WIDTH) % 2 == 0 ) //奇數(shù)行

          {

          if ( (i % 2) == 0 ) //奇數(shù)列

          {

          /* B */

          if ( (i > WIDTH) ((i % WIDTH) > 0) )

          {

          *scanpt++ = ((long int)*(rawpt-WIDTH-1)+(long int)*(rawpt-WIDTH+1)+

          (long int)*(rawpt+WIDTH-1)+(long int)*(rawpt+WIDTH+1))/4; /* R */

          *scanpt++ = ((long int)*(rawpt-1)+(long int)*(rawpt+1)+

          (long int)*(rawpt+WIDTH)+(long int)*(rawpt-WIDTH))/4; /* G */

          *scanpt++ = *rawpt; /* B */

          }

          else /* first line or left column */

          {

          *scanpt++ = *(rawpt+WIDTH+1); /* R */

          *scanpt++ = ((long int)*(rawpt+1)+(long int)*(rawpt+WIDTH))/2; /* G */

          *scanpt++ = *rawpt; /* B */

          }

          }

          else

          {

          /* (B)G */

          if ( (i > WIDTH) ((i % WIDTH) (WIDTH-1)) )

          {

          *scanpt++ = ((long int)*(rawpt+WIDTH)+(long int)*(rawpt-WIDTH))/2; /* R */

          *scanpt++ = *rawpt; /* G */

          *scanpt++ = ((long int)*(rawpt-1)+(long int)*(rawpt+1))/2; /* B */

          }

          else /* first line or right column */

          {

          *scanpt++ = *(rawpt+WIDTH); /* R */

          *scanpt++ = *rawpt; /* G */

          *scanpt++ = *(rawpt-1); /* B */

          }

          }

          }

          else //偶數(shù)行

          {

          if ( (i % 2) == 0 ) //奇數(shù)列

          {

          /* G(R) */

          if ( (i (WIDTH*(HEIGHT-1))) ((i % WIDTH) > 0) )

          {

          *scanpt++ = ((long int)*(rawpt-1)+(long int)*(rawpt+1))/2; /* R */

          *scanpt++ = *rawpt; /* G */

          *scanpt++ = ((long int)*(rawpt+WIDTH)+(long int)*(rawpt-WIDTH))/2; /* B */

          }

          else

          {

          /* bottom line or left column */

          *scanpt++ = *(rawpt+1); /* R */

          *scanpt++ = *rawpt; /* G */

          *scanpt++ = *(rawpt-WIDTH); /* B */

          }

          }

          else

          {

          /* R */

          if ( i (WIDTH*(HEIGHT-1)) ((i % WIDTH) (WIDTH-1)) )

          {

          *scanpt++ = *rawpt; /* R */

          *scanpt++ = ((long int)*(rawpt-1)+(long int)*(rawpt+1)+

          (long int)*(rawpt-WIDTH)+(long int)*(rawpt+WIDTH))/4; /* G */

          *scanpt++ = ((long int)*(rawpt-WIDTH-1)+(long int)*(rawpt-WIDTH+1)+

          (long int)*(rawpt+WIDTH-1)+(long int)*(rawpt+WIDTH+1))/4; /* B */

          } else {

          /* bottom line or right column */

          *scanpt++ = *rawpt; /* R */

          *scanpt++ = ((long int)*(rawpt-1)+(long int)*(rawpt-WIDTH))/2; /* G */

          *scanpt++ = *(rawpt-WIDTH-1); /* B */

          }

          }

          }

          rawpt++;

          }

          }



          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉