Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to scan till a valid qrcode is obtained continuously, decode it, put it to a JLabel, via a webcam
    primarykey
    data
    text
    <p>I wish to scan a QRCode via a webcam, decode it &amp; place it on a JLabel. The scanner should continuously scan till a valid QRCode is obtained. Im using eclipse, will someone point me to the correct direction?</p> <p>Websites tried:</p> <pre><code>- http://shashindrasri.blogspot.sg/2013_01_01_archive.html - http://webcam-capture.sarxos.pl/ - &amp; many more </code></pre> <p>I follow what was advised and the closest I can get is the following, which gives me errors like:</p> <pre><code>- java.lang.UnsupportedClassVersionError: com/google/zxing/NotFoundException : Unsupported major.minor version 51.0 - Could not find the main class: boundary.Scanner. Program will exit. - Exception in thread "Thread-3" java.lang.UnsatisfiedLinkError: C:\Users\Safety.Puss-HP\AppData\Local\Temp\javacpp403997126115\jniopencv_core.dll: Can't find dependent libraries </code></pre> <p>Imports I did:</p> <pre><code>- webcam-capture-0.3.10-RC4 - slf4j-api-1.7.2 - bridj-0.7-20130703.103049-42 </code></pre> <p>The code:</p> <pre><code>import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.image.BufferedImage; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; import javax.swing.JFrame; import javax.swing.JTextArea; import com.github.sarxos.webcam.Webcam; import com.github.sarxos.webcam.WebcamPanel; import com.github.sarxos.webcam.WebcamResolution; import com.google.zxing.BinaryBitmap; import com.google.zxing.LuminanceSource; import com.google.zxing.MultiFormatReader; import com.google.zxing.NotFoundException; import com.google.zxing.Result; import com.google.zxing.client.j2se.BufferedImageLuminanceSource; import com.google.zxing.common.HybridBinarizer; public class Scanner extends JFrame implements Runnable, ThreadFactory { private static final long serialVersionUID = 6441489157408381878L; private Executor executor = Executors.newSingleThreadExecutor(this); private Webcam webcam = null; private WebcamPanel panel = null; private JTextArea textarea = null; public Scanner() { super(); setLayout(new FlowLayout()); setTitle("Read QR / Bar Code With Webcam"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Dimension size = WebcamResolution.QVGA.getSize(); webcam = Webcam.getWebcams().get(0); webcam.setViewSize(size); panel = new WebcamPanel(webcam); panel.setPreferredSize(size); textarea = new JTextArea(); textarea.setEditable(false); textarea.setPreferredSize(size); add(panel); add(textarea); pack(); setVisible(true); executor.execute(this); } @Override public void run() { do { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } 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) { textarea.setText(result.getText()); } } while (true); } @Override public Thread newThread(Runnable r) { Thread t = new Thread(r, "example-runner"); t.setDaemon(true); return t; } public static void main(String[] args) { new Scanner(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload