JavaCV applet does not display video in browser, desktop only

2

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());
    }
    
asked by anonymous 03.01.2015 / 11:35

1 answer

2

Following advice from user Andrew Thompson, I enabled the display of the Java console and I could see several JRE security locks. So I added the following lines to the java.policy file and it worked perfectly:

permission java.util.PropertyPermission "org.bytedeco.javacpp.loadlibraries", "read";

permission java.util.PropertyPermission "org.bytedeco.javacpp.platform", "read";

permission java.security.AllPermission;

permission java.lang.RuntimePermission "shutdownHooks";

To prevent the system end user from having to change the java file settings, the final solution requires signing the applet's .jar. This tutorial shows you how to authenticate a signed auto applet: link .

    
05.01.2015 / 14:15