Browse Source

init

master
diven 2 years ago
parent
commit
6d78f81eb5
  1. BIN
      open-anpr-core/src/main/resources/models/model.onnx
  2. BIN
      open-anpr-core/src/main/resources/models/model3.onnx
  3. BIN
      open-anpr-core/src/main/resources/models/new_model.onnx
  4. 95
      open-anpr-core/src/test/java/com/visual/open/anpr/core/models/PaddlePlateDetectionTest.java
  5. BIN
      open-anpr-core/src/test/resources/images/image006.jpg
  6. BIN
      open-anpr-core/src/test/resources/images/image010.jpg
  7. 2
      pom.xml

BIN
open-anpr-core/src/main/resources/models/model.onnx

Binary file not shown.

BIN
open-anpr-core/src/main/resources/models/model3.onnx

Binary file not shown.

BIN
open-anpr-core/src/main/resources/models/new_model.onnx

Binary file not shown.

95
open-anpr-core/src/test/java/com/visual/open/anpr/core/models/PaddlePlateDetectionTest.java

@ -3,6 +3,7 @@ package com.visual.open.anpr.core.models;
import com.visual.open.anpr.core.domain.DrawImage; import com.visual.open.anpr.core.domain.DrawImage;
import com.visual.open.anpr.core.domain.ImageMat; import com.visual.open.anpr.core.domain.ImageMat;
import com.visual.open.anpr.core.domain.PlateInfo; import com.visual.open.anpr.core.domain.PlateInfo;
import org.opencv.imgcodecs.Imgcodecs;
import java.awt.*; import java.awt.*;
import java.util.HashMap; import java.util.HashMap;
@ -11,31 +12,79 @@ import java.util.List;
public class PaddlePlateDetectionTest { public class PaddlePlateDetectionTest {
public static void main(String[] args) { public static void main(String[] args) {
PaddlePlateDetection detection = new PaddlePlateDetection("open-anpr-core/src/main/resources/models/det.onnx", 1); PaddlePlateDetection detection = new PaddlePlateDetection("open-anpr-core/src/main/resources/models/model3.onnx", 1);
String imagePath = "open-anpr-core/src/test/resources/images/image005.jpg"; String imagePath = "open-anpr-core/src/test/resources/images/image010.jpg";
ImageMat imageMat = ImageMat.fromImage(imagePath); for(int wi=1; wi <=128; wi++){
for(int wy=3; wy>=0;wy--){
int width = wi * 32 - wy;
for(int hi=1; hi <=128; hi++) {
for (int hy = 3; hy >= 0; hy--) {
int height = hi * 32 - hy;
ImageMat imageMat = null;
try {
imageMat = ImageMat.fromImage(imagePath).resizeAndDoReleaseMat(width, height);
List<PlateInfo> plateInfos = detection.inference(imageMat, 1,1, new HashMap<>()); List<PlateInfo> plateInfos = detection.inference(imageMat, 1,1, new HashMap<>());
System.out.println(plateInfos);
System.out.println("success:"+width+":"+height);
}catch (Throwable t){
System.out.println("error:"+width+":"+height);
}finally {
if(imageMat != null){
imageMat.release();
}
}
}
}
}
}
// for(int w=351; w <=351; w++){
// for(int h=351; h <=351; h++){
// ImageMat imageMat = null;
// try {
// imageMat = ImageMat.fromImage(imagePath).resizeAndDoReleaseMat(w, h);
// List<PlateInfo> plateInfos = detection.inference(imageMat, 1,1, new HashMap<>());
// System.out.println(plateInfos);
// System.out.println("success:"+w+":"+h);
// }catch (Throwable t){
// System.out.println("error:"+w+":"+h);
// }finally {
// if(imageMat != null){
// imageMat.release();
// }
// }
// }
// }
// String image1Path = "open-anpr-core/src/test/resources/images/imagetmp.jpg";
// Imgcodecs.imwrite(image1Path, imageMat.toCvMat());
DrawImage drawImage = DrawImage.build(imagePath); // DrawImage drawImage = DrawImage.build(image1Path);
for(PlateInfo plateInfo : plateInfos){ // for(PlateInfo plateInfo : plateInfos){
PlateInfo.Point [] points = plateInfo.box.toArray(); // PlateInfo.Point [] points = plateInfo.box.toArray();
for(int i =0; i< points.length; i++){ // for(int i =0; i< points.length; i++){
if(i+1 == points.length){ // if(i+1 == points.length){
drawImage.drawLine( // drawImage.drawLine(
new DrawImage.Point((int)points[i].x, (int)points[i].y), // new DrawImage.Point((int)points[i].x, (int)points[i].y),
new DrawImage.Point((int)points[0].x, (int)points[0].y), // new DrawImage.Point((int)points[0].x, (int)points[0].y),
2, Color.RED // 2, Color.RED
); // );
}else{ // }else{
drawImage.drawLine( // drawImage.drawLine(
new DrawImage.Point((int)points[i].x, (int)points[i].y), // new DrawImage.Point((int)points[i].x, (int)points[i].y),
new DrawImage.Point((int)points[i+1].x, (int)points[i+1].y), // new DrawImage.Point((int)points[i+1].x, (int)points[i+1].y),
2, Color.RED // 2, Color.RED
); // );
} // }
} // }
} // }
ImageMat.fromCVMat(drawImage.toMat()).imShow(); // ImageMat.fromCVMat(drawImage.toMat()).imShow();
} }
} }

BIN
open-anpr-core/src/test/resources/images/image006.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
open-anpr-core/src/test/resources/images/image010.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

2
pom.xml

@ -22,7 +22,7 @@
</modules> </modules>
<properties> <properties>
<opencv.version>4.5.1-2</opencv.version> <opencv.version>4.6.0-0</opencv.version>
<onnxruntime.version>1.13.1</onnxruntime.version> <onnxruntime.version>1.13.1</onnxruntime.version>
<fastjson.version>1.2.58</fastjson.version> <fastjson.version>1.2.58</fastjson.version>
<hibernate.version>6.0.13.Final</hibernate.version> <hibernate.version>6.0.13.Final</hibernate.version>

Loading…
Cancel
Save