Java-based OPENCV implementation of Digital Image recognition (I.)
Recently assigned to a task, to do digital recognition, I assign the task is to separate the numbers, then a face confused, direct Baidu Java How to divide the figures in the picture, and then Baidu to use BufferedImage this class to operate; Try to do a bit, to achieve grayscale, and two value can not be done, and then almost no Java data, the most seems to be C + +, can not afford to provoke, can't afford ...
I also want to try to do in C + +, Baidu to C + + based on OPENCV to do image recognition, but to the next vs Ah, more than 10 g, my memory is so small, configuration is so troublesome, and vs each version has its own characteristics; Baidu has the following, Java based on OPENCV to do image recognition, Found also very little, but there is information ah, and the configuration is very simple ah, can do it, slowly learn; now I have done cutting pictures, using the projection method, the effect can be. You can start by looking at the following
Let's do this step by step, starting with downloading OPENCV, configuring the Java environment, and writing a test case. It must be easier than you think.
First, download OpenCV, I use the Windows system, this should be no different, Java cross-platform
Direct Baidu Search OpenCV, suggest to OpenCV Chinese website to download it; I just started to download the time, down to the time of the more than half suddenly stopped, so stopped; clearly Chinese website Ah, still need a ladder? Well, I still fq it, and then the good, step by step installation, just fine, nothing difficult. After installation, so long, I do not configure the environment;
Second, configure the Java development environment
It's also easy to add a jar from the F:\openCv\opencv\build\java directory to the environment variable, and then see how many bits you have in the system, and copy the files from the directory to your project.
An empty project, that's about it.
Third, we test, we use OPENCV two value processing a picture
Let's take a look at the code
public static void main(String[] args) { // 这个必须要写,不写报java.lang.UnsatisfiedLinkError System.loadLibrary(Core.NATIVE_LIBRARY_NAME); File imgFile = new File("C:/Users/admin/Desktop/open/test.png"); String dest = "C:/Users/admin/Desktop/open"; Mat src = Imgcodecs.imread(imgFile.toString(), Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE); Mat dst = new Mat(); Imgproc.adaptiveThreshold(src, dst, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY, 13, 5); Imgcodecs.imwrite(dest + "/AdaptiveThreshold" + imgFile.getName(), dst); }
Let's take a look.
Java-based OPENCV implementation of Digital Image recognition (I.)