Ir para conteúdo
Fórum Script Brasil

poliekos

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Sobre poliekos

poliekos's Achievements

0

Reputação

  1. Olá! Estou fazendo um projeto em que a webcam padrão tira fotos a cada 1 segundo utilizando o opencv. Por enquanto ,nesse code, ao clique do botão capturar você seleciona a pasta onde quer e ele captura uma foto.Preciso, alem do loop para ele tirar fotos a cada segundo, salva-las em um determinada pasta. public class jfmPrincipal extends javax.swing.JFrame { VideoCaptura webCam; ExibeQuadro exibeQuadro; Thread executor; private DaemonThread myThread = null; int count = 0; VideoCapture webSource = null; Mat frame = new Mat(); MatOfByte mem = new MatOfByte(); class DaemonThread implements Runnable { protected volatile boolean runnable = false; @Override public void run() { synchronized(this) { while(runnable) { if(webSource.grab()) { try { webSource.retrieve(frame); Highgui.imencode(".bmp", frame, mem); Image im = ImageIO.read(new ByteArrayInputStream(mem.toArray())); BufferedImage buff = (BufferedImage) im; Graphics g=jlbCaptura.getGraphics(); if (g.drawImage(buff, 0, 0, getWidth(), getHeight() -150 , 0, 0, buff.getWidth(), buff.getHeight(), null)) if(runnable == false) { System.out.println("Going to wait()"); this.wait(); } } catch(Exception ex) { System.out.println("Error"); } } } } } } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { int returnVal = jFileChooser1.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = jFileChooser1.getSelectedFile(); Highgui.imwrite(file.getPath(), frame); } else { System.out.println("Acesso negado."); } }
×
×
  • Criar Novo...