Browse Source

init

master
diven 2 years ago
parent
commit
10322ece6f
  1. 18
      open-anpr-core/src/main/java/com/visual/open/anpr/core/domain/PlateInfo.java
  2. 3
      open-anpr-core/src/main/java/com/visual/open/anpr/core/models/TorchPlateDetection.java
  3. 4
      open-anpr-core/src/test/java/com/visual/open/anpr/core/models/TorchPlateDetectionTest.java

18
open-anpr-core/src/main/java/com/visual/open/anpr/core/domain/PlateInfo.java

@ -9,6 +9,8 @@ public class PlateInfo implements Comparable<PlateInfo>, Serializable {
public float angle; public float angle;
/**车牌框**/ /**车牌框**/
public PlateBox box; public PlateBox box;
/**是否为单行车牌**/
public boolean single;
/** /**
* 构造函数 * 构造函数
@ -16,10 +18,11 @@ public class PlateInfo implements Comparable<PlateInfo>, Serializable {
* @param box 车牌框 * @param box 车牌框
* @param angle 车牌旋转角度 * @param angle 车牌旋转角度
*/ */
private PlateInfo(float score, PlateBox box, float angle) { private PlateInfo(float score, PlateBox box, float angle, boolean single) {
this.score = score; this.score = score;
this.angle = angle; this.angle = angle;
this.box = box; this.box = box;
this.single = single;
} }
/** /**
@ -28,7 +31,16 @@ public class PlateInfo implements Comparable<PlateInfo>, Serializable {
* @param box 车牌框 * @param box 车牌框
*/ */
public static PlateInfo build(float score, PlateBox box){ public static PlateInfo build(float score, PlateBox box){
return new PlateInfo(score, box, 0); return new PlateInfo(score, box, 0, true);
}
/**
* 构造一个车牌信息
* @param score 车牌分数
* @param box 车牌框
*/
public static PlateInfo build(float score, PlateBox box, boolean single){
return new PlateInfo(score, box, 0, single);
} }
/** /**
@ -38,7 +50,7 @@ public class PlateInfo implements Comparable<PlateInfo>, Serializable {
* @param angle 车牌旋转角度 * @param angle 车牌旋转角度
*/ */
public static PlateInfo build(float score, PlateBox box, float angle){ public static PlateInfo build(float score, PlateBox box, float angle){
return new PlateInfo(score, box, angle); return new PlateInfo(score, box, angle, true);
} }
/** /**

3
open-anpr-core/src/main/java/com/visual/open/anpr/core/models/TorchPlateDetection.java

@ -60,7 +60,8 @@ public class TorchPlateDetection extends BaseOnnxInfer implements PlateDetection
PlateInfo.Point.build( PlateInfo.Point.build(
clip(item[11], 0, imageMat.getWidth()), clip(item[11], 0, imageMat.getWidth()),
clip(item[12], 0, imageMat.getHeight())) clip(item[12], 0, imageMat.getHeight()))
)); ), item[13] == 0);
//添加数据
plateInfos.add(plateInfo); plateInfos.add(plateInfo);
} }
//返回 //返回

4
open-anpr-core/src/test/java/com/visual/open/anpr/core/models/TorchPlateDetectionTest.java

@ -11,8 +11,8 @@ import java.util.List;
public class TorchPlateDetectionTest { public class TorchPlateDetectionTest {
public static void main(String[] args) { public static void main(String[] args) {
TorchPlateDetection torchPlateDetection = new TorchPlateDetection("open-anpr-core/src/main/resources/models/plate_detect.onnx", 1); TorchPlateDetection torchPlateDetection = new TorchPlateDetection("open-anpr-core/src/main/resources/models/plate_detect.onnx", 1);
String imagePath = "/Users/diven/workspace/idea/gitee/open-anpr/open-anpr-core/src/test/resources/images/image003.jpg"; // String imagePath = "/Users/diven/workspace/idea/gitee/open-anpr/open-anpr-core/src/test/resources/images/image003.jpg";
// String imagePath = "/Users/diven/workspace/pycharm/github/Chinese_license_plate_detection_recognition/imgs3/double_yellow.jpg"; String imagePath = "/Users/diven/workspace/pycharm/github/Chinese_license_plate_detection_recognition/imgs3/double_yellow.jpg";
ImageMat imageMat = ImageMat.fromImage(imagePath); ImageMat imageMat = ImageMat.fromImage(imagePath);
List<PlateInfo> plateInfos = torchPlateDetection.inference(imageMat, 0.3f,0.5f, new HashMap<>()); List<PlateInfo> plateInfos = torchPlateDetection.inference(imageMat, 0.3f,0.5f, new HashMap<>());
System.out.println(plateInfos); System.out.println(plateInfos);

Loading…
Cancel
Save