开发者

Converting color image from the Xoom camera to monochrome image for qr code recognizing

I have done an app on the Motorola Xoom that recognize QrCode using the xzing library. I already have done the same application on my computer and it was working perfectly on my computer, but on the Xoom, it has an hard time to recognize QrCode. It needs a very good lighting with no direct spot light in it. The problem come from the camera. The front camera work not to bad, but never as good as the webcam on my labtop. The back camera is worst even if it has a better resolution. It's kind of weird that the back camera give worst result, but given that the focus doesn't work well, I think it's normal. You need a very sharp picture to have good result.

Right now I use the algo from zxing called PlanarYUVLuminanceSource.

So I wonder if you guys have found some Good alg开发者_StackOverflow中文版orithm for converting color image from the xoom camera to a monochrome image. The xzing library for recognizing monochrome image is good enought, so it's just the monochrome picture that is bad quality. No need to recommend me an another monochrome image qrcode reader.


Bitmap yourPhoto = //The bitmap of the photo from your camera
Bitmap tempBitmap = Bitmap.createBitmap(yourPhoto.getWidth(), yourPhoto.getHeight(), Bitmap.Config.ARGB_4444);
Canvas c = new Canvas(tempBitmap);
Paint paint = null;
ColorMatrix cm = new ColorMatrix();
paint = new Paint();
cm.setSaturation(0);
ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
paint.setColorFilter(f);        
c.drawBitmap(yourPhoto, 0, 0, paint);

Now your 'tempBitmap' contains the black and white image you are looking for :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜