Comments (7)
for (size_t i = 0; i < dets.size(); i++) {
cv::Mat img_mask = scale_mask(masks[i], img);
auto color = colors[(int)dets[i].class_id % colors.size()];
auto bgr = cv::Scalar(color & 0xFF, color >> 8 & 0xFF, color >> 16 & 0xFF);
cv::Rect r = get_rect(img, dets[i].bbox);
for (int x = r.x; x < r.x + r.width; x++) {
for (int y = r.y; y < r.y + r.height; y++) {
//need add
if (x >= img.cols||y >= img.rows) {
continue;
}
float val = img_mask.at(y, x);
if (val <= 0.5) continue;
img.atcv::Vec3b(y, x)[0] = img.atcv::Vec3b(y, x)[0] / 2 + bgr[0] / 2;
img.atcv::Vec3b(y, x)[1] = img.atcv::Vec3b(y, x)[1] / 2 + bgr[1] / 2;
img.atcv::Vec3b(y, x)[2] = img.atcv::Vec3b(y, x)[2] / 2 + bgr[2] / 2;
}
}
cv::rectangle(img, r, bgr, 2);
// Get the size of the text
cv::Size textSize = cv::getTextSize(labels_map[(int)dets[i].class_id] + " " + to_string_with_precision(dets[i].conf), cv::FONT_HERSHEY_PLAIN, 1.2, 2, NULL);
// Set the top left corner of the rectangle
cv::Point topLeft(r.x, r.y - textSize.height);
// Set the bottom right corner of the rectangle
cv::Point bottomRight(r.x + textSize.width, r.y + textSize.height);
// Set the thickness of the rectangle lines
int lineThickness = 2;
// Draw the rectangle on the image
cv::rectangle(img, topLeft, bottomRight, bgr, -1);
cv::waitKey(0);
cv::putText(img, labels_map[(int)dets[i].class_id] + " " + to_string_with_precision(dets[i].conf), cv::Point(r.x, r.y + 4), cv::FONT_HERSHEY_PLAIN, 1.2, cv::Scalar::all(0xFF), 2);
}
}
from tensorrtx.
What does this mean? Did you find a bug? Have you fix it?
from tensorrtx.
多谢!加了这个解决了崩溃的问题
//need add
if (x >= img.cols||y >= img.rows) {
continue;
}
from tensorrtx.
What does this mean? Did you find a bug? Have you fix it?
是的 运行官方的yolov5s-seg模型和推理bus.jpg图的时候,这会报错,查看错误,发现是因为像素的地址超过了图像的范围。
from tensorrtx.
@a819411321 Can you help raise a PR to fix this?
from tensorrtx.
多谢!加了这个解决了崩溃的问题 //need add if (x >= img.cols||y >= img.rows) { continue; }
cv::Rect r = get_rect(img, dets[i].bbox);
this r out of bounds!!!!!
modify get_rect
int x = round(l);
int y = round(t);
int w = round(r - l);
int h = round(b - t);
if(x < 0) x = 0;
if(y < 0) y = 0;
if(x + w > img.cols) w = img.cols - x;
if(y + h > img.rows) h = img.rows - y;
return cv::Rect(x, y, w, h);
// return cv::Rect(round(l), round(t), round(r - l), round(b - t));
from tensorrtx.
多谢!加了这个解决了崩溃的问题 //need add if (x >= img.cols||y >= img.rows) { continue; }
x ,y will still be less than 0
from tensorrtx.
Related Issues (20)
- yolov5编译问题 HOT 2
- yolov5s.pt微调后在生成.wts报错,改了数据类别,但类别总数不变。麻烦大大帮忙看看~谢谢!!new.pt是我微调后的模型 HOT 1
- ModuleNotFoundError: No module named 'utils.torch_utils' HOT 2
- 博主你好,这个能部署到windows上面了吗 HOT 6
- win10 compile yolov8 happen:yololayer.cu(262): error : expression must have a constant value HOT 12
- 不使用cmake搭建环境 HOT 21
- yolov8-seg, output error HOT 18
- YOLOV8 Assertion `serialized_engine' failed. 使用自己的.pt 生成 .wts 是成功的,但转.engine 是报错。chat说是卷积层权重数量不匹配 HOT 5
- Unable to build engine file for Yolov7 Custom model HOT 1
- How to use file yolov8_det_trt.py to check one's own model HOT 1
- yolov5-7.0,about anchor HOT 2
- 可以使用onnx模型转换为tensorrt模型,再进行推理吗 HOT 2
- the command : ./yolov5_det -s yolov5s.wts yolov5s.engine s, error!!! HOT 2
- widonws下yolov8模型生成wts转engine文件报错 HOT 2
- ubuntu下yolov5_v5.0的.wts转.engine失败 HOT 1
- 自己数据集训练的yolov9模型tensorrt的输出结果与pytorch结果差别很大,精度完全没有对齐 HOT 9
- 虽然最终得到了engine模型,但是报了这个错误,我是否应该忽视 HOT 1
- yolov8 TRT问题 HOT 4
- There is an error in the reasoning process of yolov8
- Yolov5 v6.0 inference with FP16 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tensorrtx.