[mw_shl_code=c,true]void camera_data_crop(uint16_t x0, uint16_t y0, uint16_t width, uint16_t height)
{
DCMI_CROPInitTypeDef DCMI_CROPInitStruct;
DCMI_CROPInitStruct.DCMI_HorizontalOffsetCount = x0 * 2;
DCMI_CROPInitStruct.DCMI_CaptureCount = width * 2 - 1;
DCMI_CROPInitStruct.DCMI_VerticalStartLine = y0;
DCMI_CROPInitStruct.DCMI_VerticalLineCount = height - 1;
DCMI_CROPConfig(&DCMI_CROPInitStruct);
DCMI_CROPCmd(ENABLE);
}
void camera_data_show(void)
{
DCMI_Stop();
OV2640_RGB565Mode(); //摄像头输出必须为非JPEG格式数据
OV2640_OutSizeSet(320, 240);
DCMI->CR &= ~DCMI_CR_JPEG; //未压缩的视频格式
DCMI->CR &= ~DCMI_CaptureMode_SnapShot; //连续模式
DMA2_Stream1->M0AR = (uint32_t)&LCD_RAM;
DMA2_Stream1->NDTR = 1;
DMA2_Stream1->CR = (DMA2_Stream1->CR & 0xFFFF9FFF) | DMA_MemoryDataSize_HalfWord;
DMA2_Stream1->CR &= ~DMA_MemoryInc_Enable;
camera_data_crop(80, 60, 160, 120);
LCD_SetWindow(80, 60, 160, 120);
LCD_WR_PRE();
DCMI_Start();
}[/mw_shl_code]
以上程序在320x240的LCD中心显示160x120大小的经裁剪的图像。[/mw_shl_code]
一周热门 更多>