人工智能Java SDK:反光衣检测,给出检测框和置信度

反光衣检测SDK

实现施工区域或者危险区域人员穿戴检测.

SDK功能

  • 反光衣检测,给出检测框和置信度

运行例子 - ReflectiveVestDetectExample

  • 测试图片


    pedestrian
/**
 * 行人检测例子 http://aias.top/
 *
 * @author Calvin
 */
public final class ReflectiveVestDetectExample {

  private static final Logger logger = LoggerFactory.getLogger(ReflectiveVestDetectExample.class);

  private ReflectiveVestDetectExample() {}

  public static void main(String[] args) throws IOException, ModelException, TranslateException {
    Path imageFile = Paths.get("src/test/resources/vest.jpg");
    Image image = ImageFactory.getInstance().fromFile(imageFile);

    Criteria<Image, DetectedObjects> criteria = new ReflectiveVest().criteria();

    try (ZooModel model = ModelZoo.loadModel(criteria);
         Predictor<Image, DetectedObjects> predictor = model.newPredictor()) {
      DetectedObjects detections = predictor.predict(image);
      List<DetectedObjects.DetectedObject> items = detections.items();

      List<String> names = new ArrayList<>();
      List<Double> prob = new ArrayList<>();
      List<BoundingBox> boxes = new ArrayList<>();
      for (int i = 0; i < items.size(); i++) {
        DetectedObjects.DetectedObject item = items.get(i);
        if (item.getProbability() < 0.5f) {
          continue;
        }
        names.add(item.getClassName() + " " + item.getProbability());
        prob.add(item.getProbability());
        boxes.add(item.getBoundingBox());
      }

      detections = new DetectedObjects(names, prob, boxes);
      ImageUtils.saveBoundingBoxImage(image, detections, "reflective_detect_result.png", "build/output");

      logger.info("{}", detections);
    }
  }
}

运行成功后,命令行应该看到下面的信息:

[INFO ] - [
    class: "safe 0.936024010181427", probability: 0.93602, bounds: [x=0.316, y=0.628, width=0.259, height=0.370]
    class: "safe 0.9202641248703003", probability: 0.92026, bounds: [x=0.000, y=0.106, width=0.176, height=0.341]
    class: "safe 0.9085375070571899", probability: 0.90853, bounds: [x=0.578, y=0.501, width=0.221, height=0.485]
    class: "safe 0.8891122937202454", probability: 0.88911, bounds: [x=0.802, y=0.465, width=0.197, height=0.532]
    class: "unsafe 0.781899094581604", probability: 0.78189, bounds: [x=0.177, y=0.432, width=0.190, height=0.416]
]

目录:

http://www.aias.top/

Git地址:

https://github.com/mymagicpower/AIAS
https://gitee.com/mymagicpower/AIAS

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容