3

I have developed an application that calls the ZXing library to invoke the camera. I have now just been told that we need this working in the emulator for testing purposes.

I don't want to change the code to read from a file, I wan't to call the library, which will call the camera and I wan't the camera to think its looking at an image (if that makes sense).

I've seen a lot around of using webcams but I don't want a live feed.

Does anyone know if this is at all possible?

Kitteh
  • 211
  • 2
  • 10

1 Answers1

0

It depends on how you're integrating with Zxing. If you are scanning barcodes via intent, then the web-cam style live feed may be your only option.

AFAIK there is a reader class that expects you to supply the images. Something like this...

Reader reader = new MultiFormatReader();      //If you are calling the reader in your code
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); //The source as    
                                                                     //supplied by you
Result result = reader.decode(bitmap);
String text = result.getText();

Note that the above code is bits and pieces taken from here .
So it looks like you should be able to supply some image and have the bar code reader take a shot at it.

Archit
  • 887
  • 2
  • 10
  • 19
  • Thanks for your answer Archit. I've used that code before but like I said, I don't want to change the code to read from a file. It kind of defeats the purpose of testing if I'm changing the code that's supposed to be tested. – Kitteh Oct 05 '11 at 15:51
  • Ok. Sorry couldn't be of much more help. :( – Archit Oct 06 '11 at 20:23