Image appearing 90 degree tilt when downloaded from server in Android? - android

Working on an application in which we capture images and upload over server. Application is in Android And I Phone. When we post image from Android, they are of quantity in Kilo Bytes but when we Post image from I Phone they are of MB size.
When we the images posted from IPHONE 5 with URL on browser, they appear good as they supposed to appear but when we download that image in Android device and show in an IMAGE VIEW, they appears 90 deg tilt to the left hand side.
I am not using, any rotation code after downloading the images in Android or in I Phone.
In I Phone the images are appearing fine.
IMages captured from Android are also visible straight. Images of low resolution capture from I Phone are also visible straight in Android.
Image uploaded from Android:
https://s3.amazonaws.com/WeddingApp/Weddingimage/933_6_stan.jpg
Image uploaded from I Phone:
https://s3.amazonaws.com/WeddingApp/Weddingimage/937_6_stan.jpg
public static boolean downloadFile(final String fileURL,File directory,Context CONTEXT){
try{
URL url = new URL(fileURL);
URLConnection ucon = url.openConnection();
ucon.setReadTimeout(35000);
ucon.setConnectTimeout(10000);
InputStream is = ucon.getInputStream();
BufferedInputStream inStream = new BufferedInputStream(is, 1024 * 5);
File file = directory;
if (file.exists())
{
file.delete();
}
file.createNewFile();
FileOutputStream outStream = new FileOutputStream(file);
byte[] buff = new byte[5 * 1024];
int len;
while ((len = inStream.read(buff)) != -1)
{
outStream.write(buff, 0, len);
}
outStream.flush();
outStream.close();
inStream.close();
}
catch (IOException e){ //IF SDCARD NOT EXIST THEN PASS RESPONSE TRUE`
e.printStackTrace();
return false;
}catch(Exception e){
e.printStackTrace();
return false;
}
return true;
}
Please suggest me.

This is because of iPhone's silly new camera implementation. I found below on research (sources given below):
1. The iPhone camera's interpretation of "up" direction is rotated 90 degrees from the actual "up" direction we know. What you and I call "up", is iphone's "left" or "right". The camera's orientation has been changed. This was done so that they could support taking pictures with the volume button.
2. But, being aware that other devices and cameras have normal orientation, and so that those devices and browsers display the images properly, iOS adds EXIF data to the uploaded images. This is added on image upload. EXIF, as mentioned in the link, is a metadata that contains all the information of how the image is actually supposed to look.
3. The target platform on which the image is downloaded is supposed to read the EXIF data, and then show the correct representation of the image. So, if the target platform reads the EXIF, it will realize that the image received is 90 degrees rotated, and that it should rely on EXIF data, and not on what's received. This is why iPhone camera apps can show the image properly.
4 However, not everybody reads EXIF. Apps and browsers that are aware of EXIF, read the EXIF data of the image, and show it properly. But those that are not aware of EXIF, don't read that data, and show the image exactly as received --> 90 degrees rotated
5 People have worked around this problem, by rotating their iPhone 90 degrees, before taking a picture (so that the camera is oriented right, before the picture is taken)
Resources:
1. Source 1
2. Source 2
Others with same problem:
1. SO Post 1
2. SO Post 2

The problem seems to be related to EXIF data found on the images. We must process it before displaying the image. It appears to be that not every camera outputs EXIF data 'cause this issues only happens to me in some android handsets.
Take a look at: http://commons.wikimedia.org/wiki/Commons:Exif#Orientation_.28rotation_and_mirroring.29
EDIT:
We could implement something like:
public Bitmap getBitmap(String path){
Bitmap tmpBitmap = BitmapFactory.decodeFile(path);
Bitmap bitmap = null;
if(path != null){
try {
ExifInterface ei = new ExifInterface(path);
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
Matrix mtx = new Matrix();
int w = tmpBitmap.getWidth();
int h = tmpBitmap.getHeight();
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
//rotate CCW
mtx.preRotate(-90);
bitmap = Bitmap.createBitmap(tmpBitmap, 0, 0, w, h, mtx, true);
break;
case ExifInterface.ORIENTATION_ROTATE_270:
//rotate CW
mtx.preRotate(90);
bitmap = Bitmap.createBitmap(tmpBitmap, 0, 0, w, h, mtx, true);
break;
//CONSIDER OTHER CASES HERE....
default:
bitmap = tmpBitmap;
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
return bitmap;
}
Regards.

Related

Android SavePhoto Rotate Bitmap Prior to Save

I have an Android app which is capturing an image as a CameraPreview image.
Prior to capturing the image is appears on the Phone screen in Portrait mode (as needed).
But when I do a Save, the image goes to the JPG file rotated to Landscape mode.
I have confirmed this by going to MyFiles, finding the image and viewing it with Gallery - it pops up on-screen in Landscape mode.
Additionally when I upload the image files onto my computer they show up in Landscape mode there as well.
The image is correct, but the orientation is wrong.
The method that I am using to Save is as follows:
private boolean savePhoto(Bitmap bm) {
FileOutputStream image = null;
try {
image = new FileOutputStream(mLocation);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
bm.compress(CompressFormat.JPEG, 100, image);
if (bm != null) {
int h = bm.getHeight();
int w = bm.getWidth();
} else {
return false;
}
return true;
}
Can I insert code here or call a routine (if so what code is needed) that can rotate the image into the appropriate orientation prior to the actual Save?
Or is there some other manner to change the resultant JPG image orientation?
POST EDIT - I just now added the following code to examine the Saved JPG file.
ExifInterface exif = new ExifInterface(f.getPath());
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
However it returned an Orientation = 0 which is not telling me that it 'thinks' that the JPG was Saved in Landscape orientation so that I might be able to use other posting's code.
Thanks

Camera folder images appear rotated

I'm trying to process images in my app. The problem I'm currently facing is related to orientation of images. The thumbnail of the images selected from camera folder of Android appears 90 degrees rotated. I'm getting the thumbnail as following;
Uri thumbUri = Uri.withAppendedPath(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, uri.getLastPathSegment());
if (thumbUri != null){
try {
List<String> parts = uri.getPathSegments();
String lastPart = parts.get(parts.size() - 1);
int index = lastPart.indexOf(":");
if (index != -1)
{
lastPart = lastPart.substring(index+1);
}
long id = Long.parseLong(lastPart);
// get a thumbnail for the image
Bitmap bitmap = MediaStore.Images.Thumbnails.getThumbnail(
context.getContentResolver(),
id,
MediaStore.Images.Thumbnails.MINI_KIND,
null
);
if (bitmap != null)
{
return bitmap;
}
}
catch (Exception e)
{
Log.e(LOG_TAG, "Unable to generate thumbnail from thumbnail uri " + e.getMessage(), e);
}
}
Also tried to fix it by reading orientation from ExifInterface as;
ExifInterface ei = new ExifInterface(uri.getPath());
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
But orientation returned is always 0 ORIENTATION_UNDEFINED. Unable to get what I'm doing wrong here.
Got the solution. I used getThumbnail(ContentResolver contentResolver, long id) method from BitmapUtil which reads the metadata of image from cursor and then process accordingly.
Thanks to Jason Fry for this useful utility.
You can do a simple workaround by performing additional rotation to your bitmap, using Matrix. It's perfectly simple.
//we don't need a NullPointerException now, do we?
if (bitmap != null)
{
//ever so simply initialize a Matrix
Matrix matrix = new Matrix();
//tell the Matrix it should rotate everything it's applied to by -90 degreeds
matrix.postRotate(-90);
//create a clone of the bitmap while applying the mentioned Matrix
//for width and height attributes, you must always use old bitmap's width and height
bitmap = Bitmap.createBitmap(bitmap, 0, 0,
bitmap.getWidth(), bitmap.getHeight(),
matrix, true);
return bitmap;
}
EDIT:
And if you need to determine which orientation (landscape/portrait) were the photos taken in, and then decide which ones to rotate, you can use a code from this question/answer, with ExifInterface.
I see you've already applied something similar, so maybe you should try this modification with only 1 parameter, as in the linked answer:
exif.getAttribute(ExifInterface.TAG_ORIENTATION);
UPDATE:
OK, so it doesn't work either. But it should, right? That's what the mentioned method does. So I suggest you check out what uri.getPath() actually returns (using a debugger or System.out.println()), and see if it's right. Invalid path bugs happened to me plenty of times, and every time it took a while to find out what's wrong.
String path = uri.getPath();
//breakpoint somewhere below
UPDATE 2:
I've done some research and, apparently, you can't get absolute file path from URI. So I found this solution on StackOverflow.com that gives a super-simple workaround.
Link

Restoring the image from Native Memory using NDK returns Black Image with No display

I am trying to restore the image from Native memory (using NDK,C/C++) but that returns me an Black Image.
What i am doing ::
1)get the image from Drawable
2)apply the rotation to the image
3)After rotation apply the grayscale effect to the image
4)At the end i am trying to save the grayscale image in SD Card
For all the above steps, i am referring this awesome lib,which have the native method to store and restore the images.
Please note image is being stored in the SD card but when i am trying to see the image,its totally black with no display at all.
My Java Implementation ::
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case R.id.item_rotate_90:
options.inPreferredConfig = Config.ARGB_8888;
bitmapOrig = BitmapFactory.decodeResource(this.getResources(), R.drawable.sample_cam,options);
storeBitmap(bitmapOrig);
bitmapOrig.recycle();
rotateBitmap(90,_handler);
tempBmp=getBitmapAndFree();
bitmapWip = Bitmap.createBitmap(bitmapOrig.getWidth(),bitmapOrig.getHeight(),Config.ALPHA_8);
jniConvertToGray(tempBmp,bitmapWip);
if(bitmapWip!=null)
{
try
{
Bitmap b = Bitmap.createBitmap(bitmapWip.getWidth(),bitmapWip.getHeight(),Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
Paint paint = new Paint();
ColorMatrix cm = new ColorMatrix();
ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
paint.setColorFilter(f);
c.drawBitmap(bitmapWip, 0, 0, paint);
storeBitmap(b);
SaveGrayScaledImage(b);
b.recycle();
tempBmp.recycle();
} catch (IOException e) {
e.printStackTrace();
}
ivDisplay.setImageBitmap(bitmapWip);
}
break;
}
}
I have not make any changes in native method(means using the same method as this lib have for storing and restoring the image).
Saving image to SD Card ::
private void SaveGrayScaledImage(Bitmap finalBitmap)throws IOException
{
String imageFileName = "Temp" + "_gray";
File albumF = new File("/mnt/sdcard/","gray_img");
if(!albumF.exists())
{
albumF.mkdirs();
}
// File imageF = File.createTempFile(imageFileName, JPEG_FILE_SUFFIX,
// albumF);
File imageF = new File(albumF,imageFileName + ".jpeg");
if (imageF.exists()) {
imageF.delete();
imageF.createNewFile();
}
try {
FileOutputStream out = new FileOutputStream(imageF);
finalBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
imageF = null;
}
}
While googling, i found that(may be i am wrong) image which returns for Native Memory have the ALPHA_8 bitmap config,so i convert the config ALPHA_8 t0 ARGB_8888,but the result is same.
Conversion of bitmap from ALPHA_8 to ARGB_8888 ::
Bitmap b = Bitmap.createBitmap(bitmapWip.getWidth(),bitmapWip.getHeight(),Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
Paint paint = new Paint();
ColorMatrix cm = new ColorMatrix();
ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
paint.setColorFilter(f);
c.drawBitmap(bitmapWip, 0, 0, paint);
StoreBimap funcation ::
public void storeBitmap(final Bitmap bitmap)
{
if(_handler!=null)
freeBitmap();
_handler=jniStoreBitmapData(bitmap);
}
I have no clue about where i was wrong. i have checked the lib methods and implmentation again and again to find the issue.
I have spent my many hours on this small issue and it really frustrating me.
Let me know please if you need anything else from my side.
Please help me to resolve this issue.
Many Thanks in Advance....
EDIT ::
bitmapHolder=new JniBitmapHolder();
final Options options=new Options();
BitmapFactory.decodeFile(picPath, options);
options.inJustDecodeBounds=true;
options.inPreferredConfig=Config.ARGB_8888;
prepareForDownsampling(options,192,256);
System.gc();
bmpGrayscale=BitmapFactory.decodeFile(picPath,options);
int width = bmpGrayscale.getWidth();
int height = bmpGrayscale.getHeight();
bitmapHolder.storeBitmap(bmpGrayscale);
bmpGrayscale.recycle();
Bitmap thumbnail = null;
int rotationInDegrees = 0;
if (picPath != null) {
Uri uri = Uri.parse(picPath);
ExifInterface exif = null;
try {
exif = new ExifInterface(uri.getPath());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int rotation = exif.getAttributeInt(
ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
rotationInDegrees = exifToDegrees(rotation);
}
rotationInDegrees = 90;
ByteBuffer _handler =null;
switch(rotationInDegrees)
{
case 90:
bitmapHolder.rotateBitmapCw90();
break;
case 180:
bitmapHolder.rotateBitmap180();
break;
}
Bitmap bitmapWip = Bitmap.createBitmap(width,height,Config.ALPHA_8);
bitmapHolder.bitmapGrayScale(bitmapWip);
if(bitmapWip!=null){
File CurrentFile = saveGrayScaledIamge(bitmapWip,
takePhotoFile);
}
I have followed your suggestion/steps but the result is same,getting black image with no display.
ok I've found multiple problems and tips for improvements:
the first createBitmap is run with width*height on a bitmap that got rotated instead of height*width. this should be as:
rotateBitmap(90,_handler);
tempBmp=getBitmapAndFree();
bitmapWip=Bitmap.createBitmap(bitmapOrig.getHeight(),bitmapOrig.getWidth(),Config.ALPHA_8);
when saving file you don't get the correct path (you use a hardcoded path, and Lint warns about it).
jniConvertToGray doesn't really need to go over arrays and can just use a pointer, as it just runs on a single pixel. you store the bitmap into JNI twice instead of once (just do: store, rotate, grayscale, restore&free).
you don't use the new bitmap after you have finished working on it, so if I call rotation multiple times, it doesn't seem to do anything.
you already have bitmapWip rotated and grayscaled. why do you need to make a new bitmap that has its content in it, do a grayscale on it, and then save it ?
functions should be named with lowercase letter in the beginning of their names.
and finally , the most important thing: you use ALPHA_8 for the image that you show and need to save to file. this configuration has no color. it's a mask. In order to see the problem, you should set a background color to the imageView :
ivDisplay.setBackgroundColor(0xFFff0000);
before choosing the rotation, you see nothing red. after choosing it, everything you think is white, has actually become red. that's because it's transparent...
If in any phase of your development you've succeeded saving the image to a file and thought it's a black image (yet the size is not 0) , try to edit it and put a background behind it. Maybe you got lucky and just got transparent pixels...
Adding the fact that you save the file to a jpg format, which doesn't support transparency, might also contribute to unexpected behaviors.
in order to solve this, you should use the same technique i've used - use a single bitmap all the time. no need to create so many. only one should exist on the java world, and it should support having colors.

Android Camera Parameter setPictureSize causes streaked picture

I am trying to take a picture using the Android camera. I have a requirement to capture a 1600 (w) x 1200 (h) image (3rd party vendor requirement). My code seems to work fine for many phone cameras but the setPictureSize causes a crash on some phones (Samsung Galaxy S4, Samsung Galaxy Note) and causes a streaked picture on others (Nexus 7 Tablet). On at least the Nexus the size I desire is showing up in the getSupportPictureSizes list.
I have tried specifying the orientation but it didn't help. Taking the picture with the default picture size works fine.
Here is an example of the streaking:
For my image capture I have a requirement of 1600x1200, jpg, 30% compression, so I am capturing a JPG file.
I think I have three choices:
1) Figure out how to capture the 1600x1200 size without a crash or streaking, or
2) Figure out how to change the size of the default picture size to a JPG that is 1600x1200.
3) Something else that is currently unknown to me.
I have found some other postings that have similar issues but not quite the same. I am in my 2nd day of trying things but am not finding a solution. Here is one posting that got close:
Camera picture to Bitmap results in messed up image (none of the suggestions helped me)
Here is the section of my code that worked fine for until I ran into the S4/Note/Nexus 7. I have added a bit of debugging code for now:
Camera.Parameters parameters = mCamera.getParameters();
Camera.Size size = getBestPreviewSize(width, height, parameters);
if (size != null) {
int pictureWidth = 1600;
int pictureHeight = 1200;
// testing
Camera.Size test = parameters.getPictureSize();
List<Camera.Size> testSizes = parameters.getSupportedPictureSizes();
for ( int i = 0; i < testSizes.size(); i++ ) {
test = testSizes.get(i);
}
test = testSizes.get(3);
// get(3) is 1600 x 1200
pictureWidth = test.width;
pictureHeight = test.height;
parameters.setPictureFormat(ImageFormat.JPEG);
parameters.setPictureSize(pictureWidth, pictureHeight);
parameters.setJpegQuality(30);
parameters.setPreviewSize(size.width, size.height);
// catch any exception
try {
// make sure the preview is stopped
mCamera.stopPreview();
mCamera.setParameters(parameters);
didConfig = true;
catch(Exception e) {
// some error presentation was removed for brevity
// since didConfig not set to TRUE it will fail gracefully
}
}
Here is the section of my code that saves the JPG file:
PictureCallback jpegCallback = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
if ( data.length > 0 ) {
String fileName = "image.jpg";
File file = new File(getFilesDir(), fileName);
String filePath = file.getAbsolutePath();
boolean goodWrite = false;
try {
OutputStream os = new FileOutputStream(file);
os.write(data);
os.close();
goodWrite = true;
} catch (IOException e) {
goodWrite = false;
}
if ( goodWrite ) {
// go on to the Preview
} else {
// TODO return an error to the calling activity
}
}
Log.d(TAG, "onPictureTaken - jpeg");
}
};
Any suggestions on how to correctly set up the camera parameters for taking photos or how to crop or resize the resulting photo would be great. Especially if it will work with older cameras (API level 8 or later)! Based on needing the full width of the picture I can only crop off the top.
Thanks!
EDIT: Here is what I ended up doing:
I started by processing the Camera.Parameters getSupportedPictureSizes to use the first one that had the height and width both greater than my desired size, AND the same width:height ratio. I set the Camera parameters to that picture size.
Then once the picture was taken:
BitmapFactory.Options options = new BitmapFactory.Options();;
options.inPurgeable = true;
// convert the byte array to a bitmap, taking care to allow for garbage collection
Bitmap original = BitmapFactory.decodeByteArray(input , 0, input.length, options);
// resize the bitmap to my desired scale
Bitmap resized = Bitmap.createScaledBitmap(original, 1600, 1200, true);
// create a new byte array and output the bitmap to a compressed JPG
ByteArrayOutputStream blob = new ByteArrayOutputStream();
resized.compress(Bitmap.CompressFormat.JPEG, 30, blob);
// recycle the memory since bitmaps seem to have slightly different garbage collection
original.recycle();
resized.recycle();
byte[] desired = blob.toByteArray();
Then I write out the desired jpg to a file for upload.
test = testSizes.get(3);
// get(3) is 1600 x 1200
There is no requirement that the array have 4+ elements, let alone that the fourth element be 1600x1200.
1) Figure out how to capture the 1600x1200 size without a crash or streaking
There is no guarantee that every device is capable of taking a picture with that exact resolution. You cannot specify arbitrary values for the resolution -- it must be one of the supported picture sizes. Some devices support arbitrary values, while other devices will give you corrupted output (as is the case here) or will flat-out crash.
2) Figure out how to change the size of the default picture size to a JPG that is 1600x1200
I am not aware that there is a "default picture size", and, beyond that, such a size will be immutable, since it is the default. Changing the picture size is your option #1 above.
3) Something else that is currently unknown to me.
For devices that support a resolution that is bigger on both axes, take a picture in that resolution, then crop to 1600x1200.
For all other devices, where one or both axes are smaller than desired, take a picture in whatever resolution suits you (largest, closest match to 4:3 aspect ratio, etc.), and then stretch/crop to get to 1600x1200.

Can't read a QR code from camera

EDIT:
After playing around with it for a few hours, I came to believe that the problem is in the image quality. For example, to first image is how it came from the camera. Decoder can't read it. The second image is turned into B/W with adjusted contrast and the decoder reads it great.
Since the demo app that came with zxing is able to read the fist image off the monitor in a few seconds, I think the problem might be in some setting deep within the zxing library. It doesn't wait long enough to process the image, but spits out NotFound almost instantly.
I'm making a simple QR-reader app. Here's a screenshot.
The top black area is a surfaceview, that shows frames from the camera. It works fine, only you can't see it in the screenshot.
Then, when I press the button, a bitmap is taken from that surfaceview, placed on an ImageView below and is attempted to be read by the zxing library.
Yet it will give out a NotFoundException. :/
**10-17 19:53:15.382: WARN/System.err(2238): com.google.zxing.NotFoundException
10-17 19:53:15.382: WARN/dalvikvm(2238): getStackTrace() called but no trace available**
On the other hand, if I crop the qr image from this screenshot, place it into the imageview ( instead of a camera feed ) and try to decode it, it works fine. Therefor the QR image itself and its quality are OK... but then why doesn't it decode in the first scenario?
Thanks!
public void dec(View v)
{
ImageView ivCam2 = (ImageView)findViewById(R.id.imageView2);
ivCam2.setImageBitmap(bm);
BitmapDrawable drawable = (BitmapDrawable) ivCam2.getDrawable();
Bitmap bMap = drawable.getBitmap();
TextView textv = (TextView) findViewById(R.id.mytext);
LuminanceSource source = new RGBLuminanceSource(bMap);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Reader reader = new MultiFormatReader();
try {
Result result = reader.decode(bitmap);
Global.text = result.getText();
byte[] rawBytes = result.getRawBytes();
BarcodeFormat format = result.getBarcodeFormat();
ResultPoint[] points = result.getResultPoints();
textv.setText(Global.text);
} catch (NotFoundException e) {
textv.setText("NotFoundException");
} catch (ChecksumException e) {
textv.setText("ChecksumException");
} catch (FormatException e) {
textv.setText("FormatException");
}
}
how the bitmap is created:
#Override
public void surfaceCreated(SurfaceHolder holder)
{
try
{
this.camera = Camera.open();
this.camera.setPreviewDisplay(this.holder);
this.camera.setPreviewCallback(new PreviewCallback() {
public void onPreviewFrame(byte[] _data, Camera _camera) {
Camera.Parameters params = _camera.getParameters();
int w = params.getPreviewSize().width;
int h = params.getPreviewSize().height;
int format = params.getPreviewFormat();
YuvImage image = new YuvImage(_data, format, w, h, null);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Rect area = new Rect(0, 0, w, h);
image.compressToJpeg(area, 50, out);
bm = BitmapFactory.decodeByteArray(out.toByteArray(), 0, out.size());
}
});
}
catch(IOException ioe)
{
ioe.printStackTrace(System.out);
}
}
I wrote this code. Returning quickly isn't a problem. Decoding is very fast on a mobile, and very very fast on a desktop.
The general answer to this type of question is that some images just aren't going to decode. That's life -- the heuristics don't always get it right. But I don't think that is the problem here.
QR codes don't decode without a minimal white "quiet zone" around them. The image beyond its borders is considered white for this purpose. But in your raw camera image, there's little border around the code and it's not all considered white by the binarizer, I'd bet.
Still, there's more you can do. Set the TRY_HARDER hint to the decoder, for one, to have it spend a lot more CPU to try to decode. You can also try a different Binarizer implementation than the default HybridBinarizer.
(The rest looks just fine. I assume that RGBLuminanceSource is getting data in the format it expects; it ought to from Bitmap)
See this: http://zxing.org/w/docs/javadoc/com/google/zxing/NotFoundException.html The exception means that a barcode wasn't found in the image. My suggestion would be to use your work around that works instead of trying to decode the un-cropped image.

Categories

Resources