Ncnn: Is it possible to crop ncnn:mat?

Created on 10 May 2019  ·  5Comments  ·  Source: Tencent/ncnn

I need to crop image before passing into the model.
Currently I am doing this:

nccn mat to opencv mat. ---> cropping it--> again opencv: : mat to ncnn::mat ---> input to model.

following method crops image in opencv.

cv::Rect rr=cv::Rect(left,top,right-left,bottom-top);
cv::Mat face = rgbaMat(rr);

Can we achieve similar functionality with ncnn mat directly? so conversion time will be saved drastically.
thanks
@nihui
@cook
@tamworth
@LittlePeng
@donch1989

Most helpful comment

@soham24
hey, I checked the code,
top bottom left right here are the distance from the border that you want to crop.
so:
top: y1
bottom: height - y2
left: x1
right: width - x2

Let me know if this is correct.

All 5 comments

ncnn::copy_cut_border(const Mat& src, Mat& dst, int top, int bottom, int left, int right);

the parameters are the border width to cut

if I am not wrong
top- y1
bottom y2
left x1
right x2

@soham24
hey, I checked the code,
top bottom left right here are the distance from the border that you want to crop.
so:
top: y1
bottom: height - y2
left: x1
right: width - x2

Let me know if this is correct.

@jalola hey this is correct. even I have confirmed this.

@jalola @nihui Will it work on a mat which is normalized with
substract_mean_normalize()' this method?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

varbegin picture varbegin  ·  3Comments

xhappy picture xhappy  ·  5Comments

yizhaoyanbo picture yizhaoyanbo  ·  3Comments

SisterL picture SisterL  ·  3Comments

Abel119 picture Abel119  ·  4Comments