2
I am developing a web application that connects to a security camera via Javacv. The applet I developed runs normally on the desktop, but when I try to run in the browser, although it does not give any error, it renders all swing components (panels, buttons, etc), but does not display video. Opencvframegrabber instance does not execute start method.
Below is the code I use to call the applet from inside 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 follows the code that connects to the camera and displays the video (I’m using local connection for test 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());
}