|
地板
楼主 |
发表于 2022-2-21 15:22:03
|
只看该作者
大哥,有没有第二条 的代码demo呢?我感觉我的操作有问题,但是又不知道改怎么写
int oldFrameSize = im.cols * im.rows *img_bgr_c;
int newFrameSize = new_unpad[0] * new_shape[1] * img_bgr_c;
unsigned char *srcBuffer[oldFrameSize];
unsigned char *dstBuffer[newFrameSize];
memcpy(srcBuffer, im.data, oldFrameSize);
Mat Liner_shrink;
if(shape[0] != new_unpad[1] && shape[1] != new_unpad[0]){
RockchipRga *mRga;
mRga->ops->initCtx(mRga);
mRga->ops->setSrcFormat(mRga, V4L2_PIX_FMT_ABGR32, shape[0], shape[1]);
mRga->ops->setDstFormat(mRga, V4L2_PIX_FMT_ABGR32, new_unpad[0], new_shape[1]);
mRga->ops->setSrcBufferPtr(mRga, srcBuffer);
mRga->ops->setDstBufferPtr(mRga, dstBuffer);
mRga->ops->go(mRga);
// cv::resize(im, Liner_shrink, Size(new_unpad[0], new_shape[1]), 0, 0, INTER_LINEAR);
}
memcpy(Liner_shrink.data, dstBuffer, newFrameSize);
int top = int(round(dh - 0.1));
int bottom = int(round(dh + 0.1));
int left = int(round(dw - 0.1));
int right = int(round(dw + 0.1));
int newSize [2] = {dw, dh};
copyMakeBorder(im, Liner_shrink, top, bottom, left, right, BORDER_CONSTANT, color); |
|