Detect Color Code of live android camera preview

ojas picture ojas · May 28, 2015 · Viewed 17.7k times · Source

I would like to detect colorcode of image (live stream image) while camera preview is going on. I want to develop sample android application which works like ColorGrab android application. Please find attached screenshot for the same.

How can I make demo program application which capture and recognize colors simply by pointing the camera and show as hexcode of that color.

Any help would be appreciated. Thanks for your time.

enter image description here

Answer

raj picture raj · Jan 22, 2016

https://play.google.com/store/apps/details?id=com.raj.colorwalls

Look at this app url, it should give you some idea. It uses this code:

int frameHeight1 = camera.getParameters().getPreviewSize().height;
    int frameWidth1 = camera.getParameters().getPreviewSize().width;
    int rgb1[] = new int[frameWidth * frameHeight];
    decodeYUV420SP(rgb1, data, frameWidth, frameHeight);
    Bitmap bmp1 = Bitmap.createBitmap(rgb, frameWidth1, frameHeight1, Config.ARGB_8888);
    int pixel = bmp1.getPixel( x,y );
    int redValue1 = Color.red(pixel);
    int blueValue1 = Color.blue(pixel);
    int greenValue1 = Color.green(pixel);
    int thiscolor1 = Color.rgb(redValue1, greenValue1, blueValue1);

enter image description here