Java-based OPENCV implementation of Digital Image recognition (I.)

Source: Internet
Author: User

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.)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.