From bb3df465221f53ae328b9599b92c3468a2281fe1 Mon Sep 17 00:00:00 2001 From: yuxue Date: Tue, 2 Jun 2020 09:14:30 +0800 Subject: [PATCH] no commit message --- .../java/com/yuxue/enumtype/PlateColor.java | 4 ++-- src/main/java/com/yuxue/util/ImageUtil.java | 2 +- src/main/java/com/yuxue/util/PlateUtil.java | 17 ++++++++--------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/yuxue/enumtype/PlateColor.java b/src/main/java/com/yuxue/enumtype/PlateColor.java index 69d89704..c305c2cf 100644 --- a/src/main/java/com/yuxue/enumtype/PlateColor.java +++ b/src/main/java/com/yuxue/enumtype/PlateColor.java @@ -8,8 +8,8 @@ package com.yuxue.enumtype; */ public enum PlateColor { - BLUE("BLUE","蓝牌", 100, 140), - GREEN("GREEN","绿牌", 8, 150), + BLUE("BLUE","蓝牌", 100, 130), + GREEN("GREEN","绿牌", 38, 100), YELLOW("YELLOW","黄牌", 15, 40), UNKNOWN("UNKNOWN","未知", 0, 0); diff --git a/src/main/java/com/yuxue/util/ImageUtil.java b/src/main/java/com/yuxue/util/ImageUtil.java index 65b29d09..31a519e3 100644 --- a/src/main/java/com/yuxue/util/ImageUtil.java +++ b/src/main/java/com/yuxue/util/ImageUtil.java @@ -71,7 +71,7 @@ public class ImageUtil { Instant start = Instant.now(); String tempPath = DEFAULT_BASE_TEST_PATH + "test/"; String filename = tempPath + "/100_yuantu.jpg"; - filename = tempPath + "/100_yuantu1.jpg"; + filename = tempPath + "/100_yuantu2.jpg"; // filename = tempPath + "/109_crop_0.png"; Mat src = Imgcodecs.imread(filename); diff --git a/src/main/java/com/yuxue/util/PlateUtil.java b/src/main/java/com/yuxue/util/PlateUtil.java index 6867b401..5bf74109 100644 --- a/src/main/java/com/yuxue/util/PlateUtil.java +++ b/src/main/java/com/yuxue/util/PlateUtil.java @@ -140,16 +140,15 @@ public class PlateUtil { */ public static PlateColor getPlateColor(Mat inMat, Boolean adaptive_minsv, Boolean debug, String tempPath) { // 判断阈值 - final float thresh = 0.49f; - - if(colorMatch(inMat, PlateColor.BLUE, adaptive_minsv, debug, tempPath) > thresh) { - return PlateColor.BLUE; + final float thresh = 0.70f; + if(colorMatch(inMat, PlateColor.GREEN, adaptive_minsv, debug, tempPath) > thresh) { + return PlateColor.GREEN; } if(colorMatch(inMat, PlateColor.YELLOW, adaptive_minsv, debug, tempPath) > thresh) { return PlateColor.YELLOW; } - if(colorMatch(inMat, PlateColor.GREEN, adaptive_minsv, debug, tempPath) > thresh) { - return PlateColor.GREEN; + if(colorMatch(inMat, PlateColor.BLUE, adaptive_minsv, debug, tempPath) > thresh) { + return PlateColor.BLUE; } return PlateColor.UNKNOWN; } @@ -275,10 +274,10 @@ public class PlateUtil { Vector rt = new Vector(); for (int i = 0; i < contours.size(); i++) { Rect mr = Imgproc.boundingRect(contours.get(i)); - if(debug) { - Mat mat = new Mat(threshold, rt.get(i)); + /*if(debug) { + Mat mat = new Mat(threshold, mr); Imgcodecs.imwrite(tempPath + debugMap.get("plateRect") + "_plateRect_" + i + ".jpg", mat); - } + }*/ if (checkCharSizes(mr)) { rt.add(mr); }