2

I have a FrameLayout in one of my screens. I refer to it in my code like this:

preview = (FrameLayout)findViewById(R.id.preview);

And I am embedding a CameraPreview object(extends SurfaceView, from the ZBar SDK for QR parsing) in the FrameLayout like this:

scanner.setConfig(0, Config.Y_DENSITY, 3);
mPreview = new CameraPreview(this, mCamera, getPreviewCallback(), autoFocusCB);
if(preview.getChildCount()>=1)
preview.removeAllViews();
preview.addView(mPreview);

Now when I run this on one of my test phones, Samsung Galaxy 3(GT-I5801), everything works fine and QRs are parsed ok. But if I scan it with a Samsung Galaxy S2 or Samsung Ace, the app initially starts with the camera either in low resolution or is unable to focus. Also it is unable to adjust its white balance automatically if I put it against a really bright screen. But the camera starts working fine if I navigate away from the Camera tab to another tab within the app and come back.

Any help with solving this would be greatly appreciated. Is it anything to do with the screen or camera resolution? Or anything in the ZBar SDK if anyone knows? Or what is almost always the case, I am missing something? Thanks again for reading through this far.

kumar
  • 882
  • 2
  • 11
  • 19

1 Answers1

0

I looked into sources and it seems that it tries to start continuous autofocus which does not work everywhere. And my experience with android cameras is that even if feature is advertised, it does not mean that it works and is usable (got burned on resolution setting once). While conifugring camera you have to be as defensive as possible and be prepared to problems.

I developed my own camera management for JavaOCR project and it seems to work fine ( though IU can not promiss that it wuld work everywhere, but you may trz examples ):

http://javaocr.svn.sourceforge.net/viewvc/javaocr/trunk/demos/

( in case you do not like to compie it yourself, this app is build on this library:

https://play.google.com/store/apps/details?id=de.pribluda.android.ocrcall&feature=search_result#?t=W251bGwsMSwyLDEsImRlLnByaWJsdWRhLmFuZHJvaWQub2NyY2FsbCJd )

Konstantin Pribluda
  • 12,329
  • 1
  • 30
  • 35