Giter Site home page Giter Site logo

thai-license-plate-recognition's Introduction

Thai License Plate Recognition Project

Introduction

Thai License Plate Recognition คือโปรแกรมสำหรับรู้จำแผ่นป้ายทะเบียนภาษาไทยจากรูปภาพหรือภาพเคลื่อนไหว ในโครงการฝึกงาน True Academy Project

โปรแกรมนี้ใช้ library ในการทำ Image processing ด้วย OpenCV version 2.4.8

Runnable JAR

  • ThaiLPR.rar x64 (สำหรับ x86 ให้ copy file opencv/x86/opencv_java248.dll วางไว้ที่ root folder แทน)

Download

Sample Code

1.train ฐานข้อมูลตัวอักษรสำหรับรู้จำ

package samplecode;

import ocr.text.trainer.Trainer;

public class SampleTrainer {

	public static void main(String[] args) {
		Trainer.train("trainFileNameList.txt", "trainLabelList.txt", "outputModel.bin");

	}

}

2.การรู้จำตัวอักษร

package samplecode;

import java.util.ArrayList;
import java.util.List;

import ocr.text.recognition.OCR;

import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;

public class SampleOCR {

	public static void main(String[] args) {
		System.loadLibrary("opencv_java248");
		List<Mat> charImageMatList = new ArrayList<>();
		Mat charImageMat = Highgui.imread("testChar.bmp");
		charImageMatList.add(charImageMat);
		OCR.setModelPath("testmodel.bin");
		int[] asciiCodes ;
		asciiCodes = OCR.recognizeCharImage(charImageMatList);
		System.out.print("Result ascii code ");
		for (int i = 0; i < asciiCodes.length; i++) {
			System.out.print(asciiCodes[i]+",");
		}
		
	}

}

3.การอ่านป้ายทะเบียน

package samplecode;

import java.util.ArrayList;
import java.util.List;

import ocr.text.recognition.OCR;
import ocr.text.segmentation.TextSegment;

import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;

import plate.detection.Band;
import plate.detection.Car;
import plate.detection.Plate;

public class SampleDetectPlate {

	public static void main(String[] args) {
		System.loadLibrary("opencv_java248");
		Car car = new Car(Highgui.imread("testCarImage.jpg"));

		// method 1
		List<String> resultList = car.readPlate();
		for (String string : resultList) {
			System.out.println("Result " + string); // result is up to model
		}

		// method 2
		List<Band> bands = new ArrayList<Band>();
		bands = car.clipBands(1); // up to row you want to analyze
		List<Plate> plates = new ArrayList<Plate>();
		for (Band band : bands) {
			plates.addAll(band.clipPlates2(car.toMat()));
		}
		for (Plate plate : plates) {
			List<Mat> charImageMatList = TextSegment
					.getListMatOfCharImage(plate.toMat());
			int[] resultAsciiCode = OCR.recognizeCharImage(charImageMatList);
			System.out.println("\n\rResult ");
			for (int i = 0; i < resultAsciiCode.length; i++) {
				int c = resultAsciiCode[i];
				if (resultAsciiCode[i] >= 161) {
					c = 0x0e00 + (resultAsciiCode[i] - 160); // Thai char
				}
				System.out.print(String.format("%c", c));
			}
		}

		// method 3
		plates = car.clipPlates(1);
		for (Plate plate : plates) {
			List<Mat> charImageMatList = TextSegment
					.getListMatOfCharImage(plate.toMat());
			if (charImageMatList == null || charImageMatList.size() <= 0) {
				break;
			}
			int[] resultAsciiCode = OCR.recognizeCharImage(charImageMatList);
			System.out.println("\n\rResult ");
			for (int i = 0; i < resultAsciiCode.length; i++) {
				int c = resultAsciiCode[i];
				if (resultAsciiCode[i] >= 161) {
					c = 0x0e00 + (resultAsciiCode[i] - 160); // Thai char
				}
				System.out.print(String.format("%c", c));
			}
		}
	}

}

thai-license-plate-recognition's People

Contributors

ratthapon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.