检测活动android相机预览的颜色代码 [英] Detect Color Code of live android camera preview

查看:489
本文介绍了检测活动android相机预览的颜色代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在相机预览进行时检测图片(实时流图片)的颜色代码。我想开发示例Android应用程序,其工作原理类似于



查看这个应用程序的URL,它应该给你一些想法。它使用这个代码:

  int frameHeight1 = camera.getParameters()。getPreviewSize 
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);


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.

解决方案

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

这篇关于检测活动android相机预览的颜色代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆