All articles represent ideas and point of view of the author. Please use your judgement before taking actions. Author is not responsible for any kind of loss or damage due to actions taken following this blog. You are allowed to copy content provided a visible clickable link or courtesy is expressed to the original article in this blog. If you have suggestions or ideas, please contact admin@thecoolblogs.com

Wednesday, February 27, 2013

Connecting MK808 device to ADB using the bridge and OEM USB Drivers


MK808 is a very cheap and handy Android device to play around. Connected to an HDMI monitor, we can easily run Android applications on this device. Before starting, we need to first connect MK808 to the ADB so that we can install/run/debug applications. OEM drivers provided by Google is not sufficient to connect the MK808 device to the ADB. After installing the OEM drivers, please follow the below steps

Get Bitmap image from a YUV in Android


Android Camera preview image is in YUV format. The YUV byte[] will have gray image in the first width*height bytes and color information next. For processing preview image without taking picture from Camera using Camera.takePicture method, mostly we need to convert the YUV byte[] into a Bitmap. Following code will help do that

Friday, October 26, 2012

EXCEPTION_ACCESS_VIOLATION while using JavaCV Facerecognizer class


The below error while executing JavaCV code happen mostly when you try to invoke a method on a non-existing pointer.

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000007feea1adf5f, pid=10548, tid=8644
#
# JRE version: 7.0_07-b11
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.3-b01 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [jniopencv_contrib.dll+0xdf5f]
#

We need to understand that JavaCV is a JNI wrapper for OpenCV and other similar native libraries. The objects returned using these methods work a bit different from the normal java objects. The above error happens mainly due to trying to operate on a pointer that no longer exists.
Please refer to the below class, for example

Creating an LBPH (Local Binary Pattern Histogram) face recognizer using FaceRecognizer class in JavaCV


In this article we will discuss how to create a Java based LBP face recognizer using JavaCV. JavaCV is a wrapper to the Open CV libraries for image processing. The workflow that I am trying to implement is as below

  • The calling program will supply a bunch of images and a person name to this class ( learnNewFace(String personName, IplImage[] images)
  • The class will store the images in a folder and map the person name to an integer id
  • The class will then read all the images and person names and train the model
  • Once training is complete client can invoke identifyFace method giving an image to find out the matching personName (identifyFace(IplImage image))

Sunday, July 1, 2012

Creating xxx.activity.out.xml and failing with Error in an XML file: aborting build.

It was very annoying when I created a basic Android activity (say activity_test.xml) and tried to run in emulator it fails with an error message stating "Error in an XML file: aborting build."

When you look in editor, you can see that it created a new blank file named activity_test.out.xml and it has an error "No XML content. Please add a root view or layout to your document."

I started playing around a little and found  that the root cause of this issue is more of an Eclipse pattern, not any error. When you click the "Run" button in Eclipse, it uses the default launch configuration registered for the selected file. What is happening is, the selected file happens to be the layout file activity_text.xml and Eclipse launches an XSL launch configuration and it fails.

Two ways to fix this issue is listed below