[RESOLVIDO] Trabalhando Com OpenCV

Fiz uma tela pra capturar imagens, um painel com botões, segui a documentação. Só que não abre webcam, e pior que não da erro.
identar texto pré-formatado por 4 espaços

public class Reconhecimento extends javax.swing.JInternalFrame {

public Reconhecimento() {

    initComponents();
}

private DaemonThread trend = 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);

                        Imgcodecs.imencode(".bmp", frame, mem);
                        Image im = ImageIO.read(new ByteArrayInputStream(mem.toArray()));

                        BufferedImage buff = (BufferedImage) im;
                        Graphics g = jPanel1.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");
                    }
                }
            }
        }
    }

}

ONDE CHAMO NO BOTÃO INICIAR
webSource = new VideoCapture();

    trend = new DaemonThread();

    Thread t = new Thread(trend);
    t.setDaemon(true);

    trend.runnable = true;
    t.start();
    inicio.setEnabled(false);  //start button
    pause.setEnabled(true);

vc ta seguindo o video ou o github??

to seguindo a documentação esse site https://www.codeproject.com/Tips/717283/How-to-Use-OpenCV-with-Java-under-NetBeans-IDE

Vc entendeu aquilo que eu te falei no outro tópico?

1 curtida

entendi, só que bem sincero, não encontrei o codigo fonte

Como não?

ou entrei no site errado

Fui no TeamViewer com o @Henrique_Menna e vi o que estava acontecendo, pra abrir a camera precisa usar o webSource.open(0);,

A camera não estava abrindo pq faltou essa parte do código.

E o Graphics g = jPanel1.getGraphics(); estava apontando pra o painel errado.

O nome do painel no JInternalFrame era outro.

show de bola, vc é o cara

1 curtida