Open CV Vs NDK for Image processing - android

I am writing a program to manipulate images,ie change its color,brightness,contrast etc...
The DVM doesn't support the manipulation of images of size beyond a limit...Can any one tell me whether using Open CV will solve the issue(as this seems to be a better option than NDK)?
Or will I have to use NDK?
I have done a lot of search and was not able to find answer..

First of all, there are different options for Image processing in Android, see here for a comparison of the most popular options: see Android Computer Vision JavaCV OpenCV FastCV comparison and Image processing library for Android and Java
Coming back to your question: If the images you deal are really very large so that they do not fit into the memory of the device, you need to process the images in small chunks called tiles.
If your images are not that big, I recommend you to use OpenCv, if you have to do anything more than very simple tasks such as brightness/contrast adjustment.

Related

How to reduce Android app size by compressing images?

I am developing an Android app which has hundreds of .jpg files (over 300) each one of around 40kB. I would like to know if there is a way of reducing the size of my app. I looked at a similar question here Reducing Android App Size, but the problem still exists. Is there perhaps a way to compress the images and decompress them in real time when needed, or any other way to make my app more space efficient while not sacrificing speed?
If you have used tinypng for every resource you did your best with this kind of solution. In general, it's better to use vector graphics where the general icon will be <1kb. Also, a vector resource can be animated. If it's quite simply bitmaps, you can generate them in code on demand. Also, you can divide your app by dynamic features and each will be downloaded on demand with their part of the resources.
Is there perhaps a way to compress the images and decompress them in real-time when needed?
There is no standard Android solution out of the box. Probably, you can write something on your own. But this looks like too much effort.
Still, the most practical solution: use vector graphics as max as possible, generate in code what you can generate, compress with tinypng the others. That should be enough or you should have a very good reason for making some extra work.
For more info about vector graphics in android. For standard vector graphic import right in the android studio.
Web-site where you can download icons and insert them into the project.

Can Android handle computations in image processing and ttf rendering?

I am planning to create an Android application that will enable users to draw their own font. One similar app I found, they render the drawings online and sends the ttf file via email. What I want in my study is to render offline and saves the ttf directly into the sd card. Do you think Android can possibly do it? I am worried if it can handle all the computations of the first step which is image processing and handle those parameter requirement in rendering into .ttf (TrueType) format.
There's no reason why it wouldn't be able to.
If you can't find a API function that can do this, you can always write a small native library (using NDK), and use the FreeType open source library to do the rendering.
If you need an example of character rendering to OpenCV images, look in this short code:
https://github.com/amirgeva/optmatch/blob/master/src/chrmatch/ftfont.cpp

Opencv with Android- OCR

I want to do OCR for Sindhi, in an Android application, the idea is to let the person write on screen and then capture up the frame and then compare it with the images of the words pre saved in the mobile, and the image that matches up the most(using FLANN?) with the frame would have some text against it, and I just want to pronounce that text then. So please tell me if my approach is wrong, as I am new to Android and OpenCV both, or else tell me how do I start?
If I understand well your aim, you want to compare the text written on the screen of the mobile with images where text is present, right?
I've done a bit of OCR on Android and I used OpenCV and Tesseract.
Tesseract is a real OCR engine but you need to have images that are as "clean" as possible. That's why you need OpenCV to clean them up before using Tesseract.
OpenCv for Android : http://opencv.org/platforms/android.html
Tesseract for Android : https://github.com/rmtheis/tess-two
So to give you the main lines of my workflow for a similar application :
Grab the text written by the user in a string or an array of strings.
Go fetch your pre-saved images
Process them through OpenCV, OpenCV is mainly used here to clean the images by getting rid of noise especially. You should try using a Glaussian Blur, then an Adaptive Threshold and a Bitwise-NOT (OCR engines deal better with black and white images that you obtain with the Bitwise-NOT)
After you get some clean images with OpenCV, process these images through Tesseract. That will give you a string for each image that contains the detected text on the images.
Compare your different strings gathered on Tesseract with the user's text by parsing each word to find out the text that matches the best.
For the audio part of your app, I'm not sure how to proceed, they must be some libraries out there that might help.
You must be aware that using all these libraries on Android is quite a struggle, you might have problems with the build of the project, follow well the different documentation that is provided on the official websites.

Android image processing library that facilitates C/C++ processing

My ideal image processing library for android just provides a means to load images into memory in a standard format without any extra lossiness as it is loaded from the file/camera and then allows me to painlessly call my own C or C++ routines that operate on that format and finally allows me to save the result in a standard format to a file (possibly with loss, e.g. jpeg) . This seems to be quite different than the approach taken by most android image processing libraries. Is there such a library that has a good reputation?
Yes, OpenCV (Open Source Computer Vision).
Also recommend taking a look at Tutorial on Using OpenCV for Android Projects.

Better option to handle JPEG byte array decoding

Given a JPEG Encoded byte array taken from a camera, I need to decode it and display its image (bitmap) in my application. From searching around, I've found that there are two primary ways to go about this: use NDK Jpeg Decoding library or use BitmapFactory.decodeByteArray. This is for an experimental embedded device being developed that runs on Android with a built-in camera.
I would greatly prefer to develop the application in SDK not NDK if possible at all, but many people seemed to handle this problem by going straight to NDK, which bugged me a bit.
Is there some sort of inherent limitation in BitmapFactory.decodeByteArray that forces you to handle this problem by using libjpeg in NDK (Perhaps speed? Incompatibility?)
Performance isn't a big consideration unless if it takes say more than 45 seconds to decode the image and display it.
This is an important decision I need to make upfront, so I'd appreciate any thoughtful answers. Thank you so much.
Here is a really good example / explanation how you can decode images on device efficiently without using NDK : Displaying Bitmap Efficiently. You have an option to decode bitmap from stream or file so it depends on your needs. But in most of my applications I am using the same method and it's working great. So I suggest you to take a look at the SDK example.
Hope it will helps you.

Categories

Resources