questa è la classe interessata.codice:/** * * @author Jervys */ import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import org.opencv.core.*; import org.opencv.highgui.Highgui; import org.opencv.highgui.VideoCapture; import java.awt.image.BufferedImage; import org.opencv.imgproc.Imgproc; public class fotoice extends JFrame implements ActionListener{ /** * */ JPanel pista1; JPanel pista2; JPanel GUI; JButton btpista1; JButton btpista2; JLabel label; public fotoice(){ pista1 = new JPanel(); pista2 = new JPanel(); btpista1 = new JButton("Scatta Foto Pista 1"); btpista1.addActionListener(this); btpista2 = new JButton("Scatta Foto Pista 2"); btpista2.addActionListener(this); GUI = new JPanel(); GUI.add(pista1); GUI.add(pista2); GUI.add(btpista1); GUI.add(btpista2); this.add(GUI); } public static void main (String[] args) { fotoice prova =new fotoice(); prova.setTitle("Foto Ice"); prova.setSize(600,100); prova.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); prova.setVisible(true); } @Override public void actionPerformed(ActionEvent event) { if(event.getSource()==btpista1) { System.loadLibrary(Core.NATIVE_LIBRARY_NAME); VideoCapture camera = new VideoCapture(0); if(!camera.isOpened()){ System.out.println("Error"); } else { Mat frame = new Mat(); while(true){ if (camera.read(frame)){ System.out.println("Frame Obtained"); System.out.println("Captured Frame Width " + frame.width() + " Height " + frame.height()); Highgui.imwrite("camera0.jpg", frame); System.out.println("OK"); break; } } } camera.release(); } if(event.getSource()==btpista2){ System.loadLibrary(Core.NATIVE_LIBRARY_NAME); VideoCapture camera = new VideoCapture(1); if(!camera.isOpened()){ System.out.println("Error"); } else { Mat frame = new Mat(); while(true){ if (camera.read(frame)){ System.out.println("Frame Obtained"); System.out.println("Captured Frame Width " + frame.width() + " Height " + frame.height()); Highgui.imwrite("camera1.jpg", frame); System.out.println("OK"); break; } } } camera.release(); } } }