DCMI里面提供了函数:
HAL_DCMI_ConfigCrop(&hdcmi, 0, 0, 640, 480);
HAL_DCMI_EnableCrop(&hdcmi);
测试了下,不起作用,研究了下还是不行。
直接改用DMA2D做裁剪了,非常方便,原理是复制摄像头输出图像到显示屏显存即可,可以指定位置和大小进行复制。
/**
* @brief Return Pixel format for a given layer
* @param LayerIndex : Layer Index
* @retval Status ( 0 : 0k , 1: error)
*/
void DMA2D_CopyBuffer(uint32_t LayerIndex, void * pSrc, void * pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLineSrc, uint32_t OffLineDst)
{
uint32_t PixelFormat;
PixelFormat = LCD_LL_GetPixelformat(LayerIndex);
DMA2D->CR = 0x00000000UL | (1 << 9);
/* Set up pointers */
DMA2D->FGMAR = (uint32_t)pSrc;
DMA2D->OMAR = (uint32_t)pDst;
DMA2D->FGOR = OffLineSrc;
DMA2D->OOR = OffLineDst;
/* Set up pixel format */
DMA2D->FGPFCCR = PixelFormat;
/* Set up size */
DMA2D->NLR = (uint32_t)(xSize << 16) | (uint16_t)ySize;
DMA2D->CR |= DMA2D_CR_START;
/* Wait until transfer is done */
while (DMA2D->CR & DMA2D_CR_START)
{
}
} |