Javacv applet does not display video in the browser, only on the desktop

Asked

Viewed 72 times

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());
    }

1 answer

2


Following the advice of user Andrew Thompson, I enabled the display of the Java console and could see several JRE security blocks. So I added the following lines in 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 end-user of the system from having to change the java file settings, the ultimate solution requires the signature of . applet jar. This tutorial shows how to authenticate an auto-signed applet: http://www.devmedia.com.br/trabalhando-com-applet-auto-assinado-em-java/28660.

Browser other questions tagged

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