1

I'm trying to achieve the optimal settings for decoding barcodes using Android's tricky Camera2 API, using TEMPLATE_STILL_CAPTURE and CONTROL_SCENE_MODE_BARCODE WHILE playing with all the other settings like FPS, AF and AE.

So far however, I have been unable to remove the banding seen when reading barcodes from screens.

Banding visible

What would be the way to remove, or reduce, banding when using the Camera2 API taking pictures of screens?

Casper Bang
  • 509
  • 1
  • 5
  • 15
  • That looks like an optical artefact as a result of interference with non-constant light sources. There are techniques for reducing these artefacts, though later APIs have methods that know how to apply these techniques for the common cases.. Probably related: https://stackoverflow.com/q/7254267/1531971 –  Sep 14 '18 at 18:36
  • camera2 has [some](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#CONTROL_AE_AVAILABLE_ANTIBANDING_MODES) antibanding modes. – Alex Cohn Sep 18 '18 at 15:09

3 Answers3

1

You should set the anti-banding mode, see CONTROL_AE_ANTIBANDING_MODE

PerracoLabs
  • 16,449
  • 15
  • 74
  • 127
0
...
.setCaptureRequestOption(
    CaptureRequest.CONTROL_AE_ANTIBANDING_MODE,
    CameraMetadata.CONTROL_AE_ANTIBANDING_MODE_AUTO
)
.setCaptureRequestOption(
    CaptureRequest.CONTROL_MODE,
    CameraMetadata.CONTROL_MODE_AUTO
)
.setCaptureRequestOption(
    CaptureRequest.CONTROL_SCENE_MODE,
    CameraMetadata.CONTROL_SCENE_MODE_BARCODE
)
...

https://developer.android.com/reference/android/hardware/camera2/CaptureRequest#CONTROL_AE_ANTIBANDING_MODE

haoxiqiang
  • 359
  • 2
  • 4
0

Depending on the technology used by the screen, the screen itself may be flickering at some rate. Unfortunately, the screen is also likely to be bright, meaning the camera has to reduce its exposure time so it doesn't overexpose.

A shorter exposure time makes it harder to apply anti-banding, since anti-banding normally involves having an exposure time that's a multiple of the flicker period. That is, if the flicker is at 100 hz (10 ms period), you need an exposure time that's a multiple of 10 ms. But if the screen is so bright that the camera needs a 5 ms exposure, then there's no way to cancel out the flicker.

In addition, most camera flicker detectors only handle 50 and 60-hz main power flicker rates. Increasingly they do more, since LED lighting has flicker rates that often unrelated to the power line frequencies, but if the device only handles 50 and 60hz, it probably can't compensate for most displays that flicker.

Besides turning on antibanding mode (which should be on by default anyway), you could try increasing exposure compensation to make the image brighter, which may give the device enough room to set an exposure time for flicker reduction. But beyond that there's not much you can do, unfortunately.

Eddy Talvala
  • 17,243
  • 2
  • 42
  • 47