Coder Social home page Coder Social logo

Comments (10)

jiangjiajun avatar jiangjiajun commented on May 13, 2024

paddlex是否有对应的接口,可以根据deeplabv3+获取的结果截图,或者告诉我返回值都是什么,我怎么来用矩形把结果在图片中框起来并截图。

如果是想框起来,为什么不用目标检测呢

from paddlex.

Sunyingbin avatar Sunyingbin commented on May 13, 2024

是这样的,我检测的是电,水表盘上的数字,但是由于各种拍摄角度的问题,很多情况下都是歪的,用目标检测标注的话不好标,所以尝试用语义分割的方法,可以明确位置然后截取并识别,才会有这样的需求,不知道这样的方式对不对

from paddlex.

jiangjiajun avatar jiangjiajun commented on May 13, 2024

是这样的,我检测的是电,水表盘上的数字,但是由于各种拍摄角度的问题,很多情况下都是歪的,用目标检测标注的话不好标,所以尝试用语义分割的方法,可以明确位置然后截取并识别,才会有这样的需求,不知道这样的方式对不对

可以采取如下方法

1. 预测

import paddlex as pdx
model = pdx.load_model('output/unet/best_model')
result = model.predict('optic_disc_seg/JPEGImages/N0158.jpg')
pdx.seg.visualize('optic_disc_seg/JPEGImages/N0158.jpg', result, weight=0.0, save_dir='./')

采用如上方法后,我们可视化得到的效果如下图
image

2.将mask转为多边形polygon

import cv2
contours, hier = cv2.findContours(result['label_map'], cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) 

image = cv2.imread('optic_disc_seg/JPEGImages/N0158.jpg')
tmp = cv2.polylines(image, contours, 1, (0,0,255), 3)
cv2.imwrite('visualize_N0158.1.jpg', tmp)

可视化之后图像如下
image

3.将多边形polygon转矩形

x_min = contours[0][:, :, 0].min()
y_min = contours[0][:, :, 1].min()
x_max = contours[0][:, :, 0].max()
y_max = contours[0][:, :, 1].max()
image = cv2.imread('optic_disc_seg/JPEGImages/N0158.jpg')
tmp = cv2.rectangle(image, (x_min, y_min), (x_max, y_max), (0, 0, 255), 3)
cv2.imwrite('visualize_N0158.3.jpg', tmp)

可视化后,结果如下图
image

from paddlex.

Sunyingbin avatar Sunyingbin commented on May 13, 2024

非常感谢!!!

from paddlex.

Sunyingbin avatar Sunyingbin commented on May 13, 2024

您好,请问有什么办法可以将矩形是带角度的那种吗,因为表盘可能是歪的,所以矩形希望可以跟表盘数字有相同的角度。我用了上面那种方法,发现跟我想要的还不太一样

from paddlex.

jiangjiajun avatar jiangjiajun commented on May 13, 2024

您好,请问有什么办法可以将矩形是带角度的那种吗,因为表盘可能是歪的,所以矩形希望可以跟表盘数字有相同的角度。我用了上面那种方法,发现跟我想要的还不太一样

这个可以在网上搜一下方法,如何对一个多边形polygon拟合一个rotated rectangle

from paddlex.

Sunyingbin avatar Sunyingbin commented on May 13, 2024

好的,谢谢

from paddlex.

Sunyingbin avatar Sunyingbin commented on May 13, 2024

你好,我拟合出了这个矩形了,得到了四个坐标点,请问百度有没有好用的根据四个坐标点切图的方法,网上没有能用的。。。要不然我只能自己写了

from paddlex.

jiangjiajun avatar jiangjiajun commented on May 13, 2024

你好,我拟合出了这个矩形了,得到了四个坐标点,请问百度有没有好用的根据四个坐标点切图的方法,网上没有能用的。。。要不然我只能自己写了

PaddleX目前没有相关的脚本或工具

from paddlex.

Sunyingbin avatar Sunyingbin commented on May 13, 2024

好的,我自己写就可以了~感谢

from paddlex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.