Display webCam in Java

0

I am creating a java application that allows me to visualize my webCam in a panel defined for that purpose, but I can not. I'm using bookstores

  

bridj-0.7.0.jar, slf4j-api-1.7.2.jar, webcam-capture-0.3.12.jar, slf4j-simple-1.7.25.jar

I have created a method to start the webCam:

public void arrancarWebCam(){
    webcam = Webcam.getDefault();
    webcam.setViewSize(webcam.getViewSizes()[0]);
    panelWebCam = new WebcamPanel(webcam, true);
    panelWebCam.setPreferredSize(webcam.getViewSize());
    panelWebCam.setOpaque(true);
    panelWebCam.setBackground(Color.BLACK);
    panelWebCam.setBounds(0, 0, 400, 300);
    jpPanelFoto.add(panelWebCam);

    if (initialized.compareAndSet(false, true)) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                panelWebCam.start();
                webcam.open();
            }
        });
    }
}

which I have been mounting getting information from different sources of github and other sites. It's the first time I try to access a webcam and I'm pretty lost with this.

I've been reading and some people have created projects with Maven, I've tried it too, but I do not know how to do a Maven project, I've tried it, but when I have everything correct and without errors in the dependencies, the application it does not do anything, it does not start windows environment or anything.

The method that I mentioned above, I call it from my constructor in the class, it does not give me errors of any kind, previously using the Xarxos libraries, but I have not known how to use it, I would appreciate any help please.

Greetings

    
asked by daviserraalonso 30.05.2018 в 23:53
source

1 answer

0

Solution:

I already managed to do it, thanks anyway, the solution has been this:

  public void ArrancarWebCam() {
     webcam = Webcam.getDefault();
     webcam.setViewSize(WebcamResolution.VGA.getSize());

     WebcamPanel panel = new WebcamPanel(webcam);
     panel = new WebcamPanel(webcam);
     panel.setFPSDisplayed(false);
     panel.setDisplayDebugInfo(false);
     panel.setImageSizeDisplayed(false);
     panel.setMirrored(true);
     panel.setSize(webcam.getViewSize());

    jpDatosPaciente.add(panel);
     pack();
     panel.setBounds(850, 40, 150, 150);
     panel.setVisible(true);
}

and then make a call to this method from the constructor

    
answered by 31.05.2018 в 00:30