Mat Liner_shrink;
if(shape[0] != new_unpad[1] && shape[1] != new_unpad[0]){
cv::resize(im, Liner_shrink, Size(new_unpad[0], new_shape[1]), 0, 0, INTER_LINEAR);
}
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);
bob286 发表于 2022-2-17 17:28
1. 你这种做法用RGA其实没有太大收益的,最好是在前面resize的时候就一步到位,直接resize到目标宽度(这样 ...
bob286 发表于 2022-2-17 17:28
1. 你这种做法用RGA其实没有太大收益的,最好是在前面resize的时候就一步到位,直接resize到目标宽度(这样 ...
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);
欢迎光临 Toybrick (https://t.rock-chips.com/) | Powered by Discuz! X3.3 |