⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cntrl.cpp

📁 用VC編的數碼相機仿真程序 包括圖像的預處理 DCT變換 壓縮等 最后可用verify.exe做比較
💻 CPP
字号:
/*
* Copyright 2008, writen by shikosan
* 控制模塊
*/

#include <iostream.h>
#include "ccdPP.h"
#include "codec.h"
#include "uart.h"

#define SZ_ROW          64
#define SZ_COL          128
#define NUM_ROW_BLOCKS  (SZ_ROW / 8)
#define NUM_COL_BLOCKS  (SZ_COL / 8)
static short buffer[SZ_ROW][SZ_COL], i, j, k, l, temp;

// This function is for consistency with other modules only
void CntrlInitialize(void) {}

// This function uses CCDPP module to input image and place in buffer 
void CntrlCaptureImage(void) 
{
  CcdppCapture();
  for(i=0; i<SZ_ROW; i++)
    for(j=0; j<SZ_COL; j++)
      buffer[i][j] = CcdppPopPixel();
	// cout << buffer[14][20] << endl;
}

// This function breaks the 64 x 128 buffer into 8 x 8 blocks 分塊
// and performs FDCT on each block using the CODEC module
void CntrlCompressImage(void) 
{
  for(i=0; i<NUM_ROW_BLOCKS; i++)
    for(j=0; j<NUM_COL_BLOCKS; j++) 
    {
      for(k=0; k<8; k++)
        for(l=0; l<8; l++){
			CodecPushPixel((short)buffer[i * 8 + k][j *8 +l]);
          
        }

		CodecDoFdct();/* part 1 - FDCT */

      for(k=0; k<8; k++)
        for(l=0; l<8; l++){ 
          buffer[i*8 + k][j * 8 + l]= CodecPopPixel();

        }
    }
}

// This function transmits encoded image serially using UART module
void CntrlSendImage(void) 
{
 for(i=0; i<SZ_ROW; i++)
    for(j=0; j<SZ_COL; j++) 
    {
        temp = buffer[i][j];
	
		// UartSend(temp);
		// Change char into uchar 
        UartSend(((char*)&temp)[0]); 
		// UartSend(((unsigned char*)&temp)[0]); 
           /* send upper byte */
		// Change char into uchar 
        UartSend(((char*)&temp)[1]); 
		// UartSend(((unsigned char*)&temp)[1]); 
           /* send lower byte */
    }   
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -