Error accessing Webcam.js-Error: Webcam is not loaded yet
I am getting this error when accessing Webcam.js
Error: Webcam is not loaded yet
I'm already using secure connection plus the error persists.
I'm using Primefaces
, the photocam
component.
The application server used is Payara
- derived from 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();
}
}
1
Author: Edward Ramos, 2019-08-26