Error accessing Webcam.js - Error: Webcam is not Loaded yet

Asked

Viewed 714 times

1

I’m getting this error while accessing Webcam.js

Error: Webcam is not Loaded yet

I’m already using secure connection plus error persists. I’m using Primefaces, the component photocam. Application server used is the Payara - derived from the GlassFish.

My View

<p:growl id="growl" showDetail="true" autoUpdate="true"/>
<p:photoCam style="margin: 0 auto;" widgetVar="pc" update="cod" listener="#{vendaControle.oncapture}" /> 
<p:poll interval="1" oncomplete="PF('pc').capture()"/>

My Controller

public void oncapture(CaptureEvent captureEvent) {
        try {
            if (captureEvent != null) {
                Result result = null;
                BufferedImage image = null;

                InputStream in = new ByteArrayInputStream(captureEvent.getData());

                image = ImageIO.read(in);

                LuminanceSource source = new BufferedImageLuminanceSource(image);
                BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));

                result = new MultiFormatReader().decode(bitmap);
                if (result != null) {
                    setCodBarras(result.getText());
                    System.out.println("Código de Barras: " + codBarras);
                }
            }
        } catch (NotFoundException ex) {
            // fall thru, it means there is no QR code in image
        } catch (ReaderException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

Erro

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.