以下例子是在FFmpeg的Frame中利用OpenCV进行边缘检测的例子
int width=pCodecCtx->width, height = pCodecCtx->height;
cv::Mat tmp_img = cv::Mat::zeros(height *3/2, width,CV_8U1);
memcpy(tmp_img.data, m_pFrameYUVIngest->data[0], width * height);
memcpy(tmp_img.data + width * height, m_pFrameYUVIngest->data[1], width * height /4);
memcpy(tmp_img.data + width * height * 5 /4, m_pFrameYUVIngest->data[2], width * height/4);
Mat dst;
Canny(tmp_img, dst, 20,300);
memcpy(m_pFrameYUVIngest->data[0], dst.data, width * height);
memcpy(m_pFrameYUVIngest->data[1], dst.data + width * height, width * height /4);
memcpy(m_pFrameYUVIngest->data[2], dst.data + width * height * 5 /4, width * height/4);