<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

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

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

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

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

          本文引用地址:http://www.ex-cimer.com/article/148440.htm

          首先有必要說下所支持的格式,因為,我對這塊不熟悉,這里只說明OV支持的幾種輸出格式,以及相關(guān)寄存器的配置。

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

          本次采用的是RGB raw16 bit 模式,由于OV7620只引出了Y通道,所以配置為one line mode(這里出現(xiàn)了問題,明明RGB三個分量都有,但是通過插值后顯示出來的盡然還是灰度圖像,后面再分析原因)。下面貼出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時鐘頻率

          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的算法(在液晶屏上顯示時還要轉(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)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();