BufferedImage

All your problems with Audio, Video and Images.

BufferedImage

Postby andmol » Tue Sep 30, 2008 6:25 pm

Hi all,

is it possible to create a BufferedImage in Android? I try to use zxing (code.google.com/p/zxing) in my application, but I do not want to capture an image from camera, I want to capture it from a file. As I understand zxing right, I have to pass a MonochromeBitmapSoure.

Any ideas or experiences with zxing?

Thx.
andmol
Junior Developer
Junior Developer
 
Posts: 21
Joined: Tue Sep 30, 2008 5:34 pm

Top

Postby ninor » Tue Sep 30, 2008 9:37 pm

In the GettingStarted - Run in Android section, there's this comment at the end:

Note that the code expects that you placed a dummy image of a barcode for it to use in place of a camera capture at /tmp/barcode.jpg on the Android file system:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. adb push my-image.jpg /tmp/barcode.jpg
Parsed in 0.029 seconds, using GeSHi 1.0.8.4


Tried that?
User avatar
ninor
Moderator
Moderator
 
Posts: 180
Joined: Thu Aug 14, 2008 6:30 pm
Location: Barcelona, Spain

Postby andmol » Wed Oct 01, 2008 9:19 am

Yes I tried this, but in android SDK 0.9 the /tmp folder is not existing anymore. I tried to copy a file named "barcode.jpg" but I am not allowed to create the /tmp folder.
andmol
Junior Developer
Junior Developer
 
Posts: 21
Joined: Tue Sep 30, 2008 5:34 pm

Postby ninor » Wed Oct 01, 2008 10:27 am

Try to create it in your Eclipse project, inside the res folder, and copy the image in it.
User avatar
ninor
Moderator
Moderator
 
Posts: 180
Joined: Thu Aug 14, 2008 6:30 pm
Location: Barcelona, Spain

Postby andmol » Wed Oct 01, 2008 11:51 am

Thanks for the idea, but it doesn't working either.
andmol
Junior Developer
Junior Developer
 
Posts: 21
Joined: Tue Sep 30, 2008 5:34 pm

Postby plusminus » Wed Oct 01, 2008 8:26 pm

This doesn"t work at all?
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. BitmapFactory.decodeResource(getContext().getResources(), R.drawable.yourpicture)
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Postby andmol » Wed Oct 01, 2008 8:33 pm

This is working, I am able to create a Bitmap from my file. But then I have the problem that I have to convert the Bitmap to a BufferedImage and from that to a MonochromeBitmapSource (if I understand the zxing docu right).

So again I have the problem that I do not know how to convert the Bitmap and pass it to the zxing decode method.
andmol
Junior Developer
Junior Developer
 
Posts: 21
Joined: Tue Sep 30, 2008 5:34 pm

Postby varunvijayvargiya » Tue Dec 02, 2008 3:53 am

Ya, same problem here. Using eclipse it doesnt seem to resolve a BufferedImage datatype.. Importing java.awt doesnt help too as even that can be resolved.
Please help!
varunvijayvargiya
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Dec 02, 2008 3:50 am

Postby andmol » Thu Dec 04, 2008 10:52 am

I am developing on a real phone now and I was able to include zxing 1.1.

But I have still no idea if it is possible to directly pass an image (converted to BufferedImage) to zxing and receive the encoded data.

So the only way to include and test zxing using the emulator I am aware of is implementing a webcam and get the picture from the cam...this should help: http://www.tomgibara.com/android/camera-source
andmol
Junior Developer
Junior Developer
 
Posts: 21
Joined: Tue Sep 30, 2008 5:34 pm

Postby sreenubkaimal » Fri Feb 06, 2009 11:22 am

Use YUVMonochromeBitmapSource instead of MonochromeBitmapSource.
You have to import com.google.zxing.client.android.YUVMonochromeBitmapSource and then make the class and constructor (YUVMonochromeBitmapSource) public.

I was successful in creating a YUVMonochromeBitmapSource. But when i am trying to decode with reader.decode, it is throwing readerexception. Still not figured out what s the issue !!

Regds
Sreenu
sreenubkaimal
Freshman
Freshman
 
Posts: 3
Joined: Fri Feb 06, 2009 10:32 am

Postby andmol » Fri Feb 06, 2009 11:44 am

What kind of code are you passing? I successfully decode QR-Codes. Maybe it is helpful to post the image and the exception...
andmol
Junior Developer
Junior Developer
 
Posts: 21
Joined: Tue Sep 30, 2008 5:34 pm

Barcode Image

Postby sreenubkaimal » Fri Feb 06, 2009 12:12 pm

Were you able to successfully decode thru emulator ?

If so, What was the format and size of image file ? png ? jpg ?
Could you pls attach that image file so that i can give a try !!
sreenubkaimal
Freshman
Freshman
 
Posts: 3
Joined: Fri Feb 06, 2009 10:32 am

Postby andmol » Fri Feb 06, 2009 1:06 pm

Try the attached one, it is an example file out of the ZXing package.
Attachments
qr-code.jpg
qr-code.jpg (46.74 KiB) Viewed 4698 times
andmol
Junior Developer
Junior Developer
 
Posts: 21
Joined: Tue Sep 30, 2008 5:34 pm

Postby sreenubkaimal » Fri Feb 06, 2009 1:20 pm

Even this is giving me the same error..

I copied the image as jpg and copied to sdcard. Is that the right way ?

Could you pls send me vth few lines of code ?
I mean how did u convert image to byte[] and then usage of YUVMonochromeBitmapSource ?
sreenubkaimal
Freshman
Freshman
 
Posts: 3
Joined: Fri Feb 06, 2009 10:32 am

Postby srowen » Mon Feb 15, 2010 7:46 pm

Late to reply here but --

You can find an example of decoding from a BufferedImage under javase/ -- see CommandLineRunner. But this won't help you in Android because it does not have this class.

You can find an example of decoding Bitmap from Android in androidtest/

You can find an example of decoding raw byte[] in android/ -- see DecodeThread. But note your input image data must be in the right format, which in this case is some kind of planar YUV.
srowen
Freshman
Freshman
 
Posts: 3
Joined: Sun Jan 24, 2010 5:31 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 11 guests