Avoid ROI crop copy in shoe detector
This commit is contained in:
parent
1a0f0cf61b
commit
cd42cd0936
@ -561,13 +561,8 @@ private:
|
||||
|
||||
if (!src || src_stride <= 0) return dets;
|
||||
|
||||
// 裁剪到临时缓冲区
|
||||
std::vector<uint8_t> crop_buf(static_cast<size_t>(win_w) * win_h * 3);
|
||||
for (int row = 0; row < win_h; ++row) {
|
||||
const uint8_t* src_row = src + (win_y + row) * src_stride + win_x * 3;
|
||||
uint8_t* dst_row = crop_buf.data() + row * win_w * 3;
|
||||
memcpy(dst_row, src_row, static_cast<size_t>(win_w) * 3);
|
||||
}
|
||||
const uint8_t* roi_src = src + static_cast<size_t>(win_y) * static_cast<size_t>(src_stride) +
|
||||
static_cast<size_t>(win_x) * 3;
|
||||
|
||||
const uint8_t* model_input_data = nullptr;
|
||||
size_t model_input_size = 0;
|
||||
@ -579,11 +574,11 @@ private:
|
||||
crop_frame.width = win_w;
|
||||
crop_frame.height = win_h;
|
||||
crop_frame.format = PixelFormat::RGB;
|
||||
crop_frame.stride = win_w * 3;
|
||||
crop_frame.data = crop_buf.data();
|
||||
crop_frame.data_size = crop_buf.size();
|
||||
crop_frame.stride = src_stride;
|
||||
crop_frame.data = const_cast<uint8_t*>(roi_src);
|
||||
crop_frame.data_size = frame->data_size;
|
||||
crop_frame.plane_count = 1;
|
||||
crop_frame.planes[0] = {crop_buf.data(), crop_frame.stride, static_cast<int>(crop_buf.size()), 0};
|
||||
crop_frame.planes[0] = {crop_frame.data, crop_frame.stride, static_cast<int>(frame->data_size), 0};
|
||||
|
||||
resized_frame.width = model_w_;
|
||||
resized_frame.height = model_h_;
|
||||
@ -614,7 +609,7 @@ private:
|
||||
}
|
||||
|
||||
if (!model_input_data) {
|
||||
ResizeRgbBilinear(crop_buf.data(), win_w, win_h, win_w * 3,
|
||||
ResizeRgbBilinear(roi_src, win_w, win_h, src_stride,
|
||||
input_buf_.data(), model_w_, model_h_, model_w_ * 3);
|
||||
model_input_data = input_buf_.data();
|
||||
model_input_size = input_buf_.size();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user