Closed zhangshitoday closed 5 years ago
你好, 输出是左上右下 ,但是是将长宽归一化的相对位置,位置分别乘上实际的长宽即可得到实际位置。
可参考 example/yolov2.cpp, 108行到121行
int img_h = bgr.rows;
int img_w = bgr.cols;
std::vector<Object> objects;
for (int i = 0; i < out.h; i++)
{
const float *values = out.row(i);
Object object;
object.label = values[0];
object.prob = values[1];
object.rect.x = values[2] * img_w;
object.rect.y = values[3] * img_h;
object.rect.width = values[4] * img_w - object.rect.x;
object.rect.height = values[5] * img_h - object.rect.y;
objects.push_back(object);
}
`
label和prob是一致的,框对不上,dog.jpg这张图上的dog框的size,原版yolov3-tiny是240x330,用您的工具是240x247,麻烦您帮忙看一下
hello,
int img_h = bgr.rows; int img_w = bgr.cols;
object.rect.x = values[2] * img_w; object.rect.y = values[3] * img_w - (img_w - img_h)/2; object.rect.width = (values[4] - values[2]) * img_w; object.rect.height = (values[5] - values[3]) * img_w;
这里的img_w 和 img_h 都是相对于送入网络的图片的, 实例代码进行了letter操作对图片进行了处理,绘图也是在处理后的图片上进行的, 并不是对于原图片, 如何相对于原图片, 还需要做平移变换。
此外可以不做letter操作, 直接将原图片进行缩放到网络输入的大小, 这时便不需要做平移变换,希望可以帮到你,
ncnn::Mat in = ncnn::Mat::from_pixels_resize(image_data, ncnn::Mat::PIXEL_RGB2BGR, image_width, image_height, InputWidth_, InputHeight_);
const float norm_vals[3] = {1 / 255.0, 1 / 255.0, 1 / 255.0};
in.substract_mean_normalize(0, norm_vals);
好的,谢啦
请指教