Webcam - detects a QR code, takes a snapshot and decodes

I'm currently trying to write a Java program to use either a built-in laptop webcam or an external USB webcam. It will hopefully be compatible with PC and Mac.

I was wondering if anyone knows of a library that can handle all this? I really don’t want to reinvent the wheel, and I don’t know where to start: 1) detecting a webcam, 2) taking a snapshot when a QR code is detected.

I am familiar with ZXing for decoding barcode images.

I searched high and low, I strongly suspect that the library I am looking for does not exist, however it is worth asking!

My first question is here, so I hope this is clear!

edit: alternatively, if it does not exist, could you please point me in the right direction, how to take a picture from a webcam when a QR code is detected? :)

thanks

+4
source share
3 answers

zxing has a port for ActionScript that makes it usable via Flash, which can access the webcam. The port is a bit old, not 100% full, but should work.

0
source

This example shows how to read QR code data using Webcam Capture with ZXing. Webcam Capture is compatible with 32-bit and 64-bit Windows, Linux, and Mac OX. For Linux, it also supports the ARM architecture.

The code is pretty simple:

Webcam webcam = Webcam.getDefault(); // non-default (eg USB) webcam can be used too webcam.open(); Result result = null; BufferedImage image = null; if (webcam.isOpen()) { if ((image = webcam.getImage()) == null) { continue; } LuminanceSource source = new BufferedImageLuminanceSource(image); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); try { result = new MultiFormatReader().decode(bitmap); } catch (NotFoundException e) { // fall thru, it means there is no QR code in image } } if (result != null) { System.out.println("QR code data is: " + result.getText()); } 
+5
source

You can use gstreamer to interact with your camera. For windows, it could be gstreamer or DirectShow again. In both cases, you will need to capture your data using special filters, in DirectShow it will be SampleGrabber. I think gstreamer should provide some similar plugins.

0
source

Source: https://habr.com/ru/post/1411003/


All Articles