I'm developing a web application that connects to a security camera via JavaCV. The applet I developed normally runs on the desktop, but when I try to run it in the browser, although it does not give any errors, it renders all swing components (panels, buttons, etc), but does not display video. The OpenCVFrameGrabber instance does not execute the start method.
Below is the code I use to call the applet from within my JSF page (Note: all dependencies are already in .jar):
<applet code="com.br.spacnet.camera.CameraApplet" archive="CameraApplet.jar" width="1000" height="1000">
Below is the code that connects to the camera and displays the video (I'm using local connection for testing purposes):
try {
OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(0);
jLabel1.setText(jLabel1.getText() + "; instanciou o grabber");
//grabber.setFormat("mjpeg");
grabber.start();
jLabel1.setText(jLabel1.getText() + "; iniciou o Grab");
opencv_core.IplImage frame = grabber.grab();
while (jPanel1.isVisible()) {
jLabel1.setText(jLabel1.getText() + "; entrou no laço");
jPanel1.getGraphics().drawImage(frame.getBufferedImage(), 0, 0, 320, 240, null);
jLabel1.setText(jLabel1.getText() + "; redesenhou painel");
}
grabber.stop();
jLabel1.setText(jLabel1.getText() + "; parou o grabber");
System.exit(0);
} catch (Exception ex) {
jLabel1.setText("Erro " + ex.getMessage());
}