Android Learning six---OpenCV for Android samples

Source: Internet
Author: User

After setting up the opencv4android environment, we should start to develop our own application. For a person who does not have a OPENCV foundation to develop OPENCV applications is a bit difficult, but we can learn from the samples, combining Javadoc and the universal network to develop a simple application should not be difficult. For the sake of simplicity, we are using a purely Java API that does not involve JNI, and then uses the JNI implementation after familiarity with this part.

First of all, the OpenCV Android application to a perceptual understanding, the samples in the image-manipulations installed on the mobile phone (the phone first installed OPENCV manager and binary pack see above), and then the menu out, Try Histograms,canny, Sobel and other menus, you will find the application of the camera captured image real-time processing, in a small window of the screen output processing results graph.

As a result, our focus is on the key to simple interface design, data storage, display and algorithmic application. The application of the algorithm is implemented by invoking a series of APIs. We're going to go around the next few questions.

1. Manipulate the camera and remove the image for processing

First of all you have to know how OC (OpenCV) is manipulating the camera, how to remove a frame from the image stream for processing?

Solution: Through the OPENCV official website example to understand

Java contains OPENCV Java packages. That is, through the non-synchronous way to carry out the application development, this is the official website strongly recommended way, because can reduce the amount of code and other advantages, mainly with OpenCV manager way to obtain the OPENCV library (already installed in the target system)

1.1 File, Import, Existing project in your workspace.

1.2. AddSelect OpenCV Library-2.4.9, Android, Library, Project--Properties.

1.3 A simple program

 Public classSample1javaextendsActivityImplementsCvcameraviewlistener {PrivateBaseloadercallback Mloadercallback =NewBaseloadercallback ( This) {@Override Public voidOnmanagerconnected (intstatus) {            Switch(status) { Caseloadercallbackinterface.success: {log.i (TAG,"OpenCV Loaded successfully");                Mopencvcameraview.enableview (); }  Break; default:                {                    Super. onmanagerconnected (status); }  Break;    }        }    }; @Override Public voidOnresume () {Super. Onresume (); Opencvloader.initasync (Opencvloader.opencv_version_2_4_6, This, Mloadercallback); }    ...}

Onmanagerconnected callback is called in the UI thread, and must be included before using the OPENCV call or loading the local library of the OPENCV support. When the OPENCV is successfully initialized and loaded into the local library, the default Baseloadercallback treats the application context as Activity, so Activity.finish () is called when the initialization fails . To override this behavior, you must rewrite the finish () method.

2. To understand what part of the process is written, how to achieve only this part of the modification, and the rest of the same?

The samples,imagemanipulationsactivity on the official website is written using the OpenCV Java API, which knows the whole process through a Hello OpenCV (although the program is not running successfully),

Know that the oncameraframe should be modified to process each frame of the image.

3. How to implement a simple OPENCV text location algorithm based on connected domain analysis and embed the algorithm into the application?

Algorithm flow, the color of the frame image of the binary, after the two-valued connected domain analysis, analysis of each connected domain, the connected domain analysis, to remove some non-conformance, the remaining connected domain using morphological image processing, connected to a text line, in the text line filtering, and finally get the text region position.

4. How do I debug the error to make the final implementation run?

Debug in the same way as Android, such as Logcat and endpoints, with a range of shortcut keys such as F5,f6,f7,f8 and Ctrl+r.

Android Learning six---OpenCV for Android samples

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.