Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

预测的框不对位置大小绘制出来不对 #36

Open
MooWeii opened this issue Jun 25, 2024 · 7 comments
Open

预测的框不对位置大小绘制出来不对 #36

MooWeii opened this issue Jun 25, 2024 · 7 comments

Comments

@MooWeii
Copy link

MooWeii commented Jun 25, 2024

使用的OpencvSharp4绘制的, 代码如下, 是SKBitmap坐标系的问题吗

var yolo = new Yolov8("box.onnx", false);
yolo.SetupLabels(new string[] { "box" });
Mat mat = new Mat(dialog.FileName);//AppDomain.CurrentDomain.BaseDirectory+""
RawImage = WriteableBitmapConverter.ToWriteableBitmap(mat);
var image = mat.ToBytes();
var predictResult = yolo.Predict(SKBitmap.Decode(image));
foreach (var predict in predictResult)
{
    Cv2.Rectangle(mat, new Rect(Convert.ToInt32(predict.Rectangle.MidX - predict.Rectangle.Width/2), Convert.ToInt32(predict.Rectangle.MidY - predict.Rectangle.Height/2), Convert.ToInt32(predict.Rectangle.Width), Convert.ToInt32(predict.Rectangle.Height)), Scalar.Red, 2);
}
AfterImage = WriteableBitmapConverter.ToWriteableBitmap(mat);
@MooWeii
Copy link
Author

MooWeii commented Jun 25, 2024

用release中的demo改了下模型和照片也是生成的预测框位置和大小不准
demo_result_yolov8

@iwaitu
Copy link
Collaborator

iwaitu commented Jun 26, 2024

按照示例代码用 skiasharp 绘制有这个问题吗?我看着你的rect 边框计算有问题啊

@MooWeii
Copy link
Author

MooWeii commented Jun 26, 2024

是的, 示例代码仅修改了模型路径和验证图片路径, 我可以把模型和验证图片发给您

@iwaitu
Copy link
Collaborator

iwaitu commented Jun 26, 2024

给我个下载地址,我帮你试试看

@MooWeii
Copy link
Author

MooWeii commented Jun 28, 2024

这个链接, 链接里是release中的demo, 已经改好了模型位置和图片路径, 运行目录下面有一张正确的预测图做对比 源码下载

@sharpwood
Copy link

位置的确不准确。

@MooWeii
Copy link
Author

MooWeii commented Jul 10, 2024

给我个下载地址,我帮你试试看

好像是因为这张图片在电脑上旋转过的原因导致了SkiaSharp获取到的宽和高互换了, 图像旋转完是3024*4032, 但是SkiaSharp读到的是4032*3024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants