Ir ao conteúdo
  • Cadastre-se

Jonathan Galdino

Membro Júnior
  • Posts

    1
  • Cadastrado em

  • Última visita

Reputação

0
  1. Olá! Estou fazendo um projeto em que a webcam padrão tira fotos cada 0,5 segundos(se não for possível, a cada 1 segundo)utilizando o opencv. No meu code, ao clique do botão capturar você seleciona a pasta onde quer e ele captura uma foto. Quero fazer um loop para que ele capture fotos e salve, 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."); } }

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...