Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat () J
I'm using the VideoCapture function from the opencv library, below the code snippet:
private void BotaoStartActionPerformed(java.awt.event.ActionEvent evt){
Mat imageMat = new Mat(); // matriz de imagem //
VideoCapture capture = new VideoCapture();
capture.open(0); // abre dispositivo de video de índice 0 //
// especifica altura e largura do video //
capture.set(org.opencv.highgui.Highgui.CV_CAP_PROP_FRAME_HEIGHT, 320);
capture.set(org.opencv.highgui.Highgui.CV_CAP_PROP_FRAME_WIDTH, 640);
BufferedImage image;
capture.read(imageMat); //Captura o quadro
image = this.matToBufferedImage(imageMat); //Converte para imageBuffer
while(capture.isOpened()){
Icon icon = new ImageIcon(image);
this.TelaImagem.setIcon(icon);
this.TelaImagem.repaint();
try {
Thread.sleep(150);
} catch (InterruptedException ex) {
}
}
}
This is the function that converts the type Mat to BufferedImage:
public BufferedImage matToBufferedImage(Mat matrix) {
int cols = matrix.cols();
int rows = matrix.rows();
int elemSize = (int)matrix.elemSize();
byte[] data = new byte[cols * rows * elemSize];
int type;
matrix.get(0, 0, data);
switch (matrix.channels()) {
case 1:
type = BufferedImage.TYPE_BYTE_GRAY;
break;
case 3:
type = BufferedImage.TYPE_3BYTE_BGR;
// bgr to rgb
byte b;
for(int i=0; i<data.length; i=i+3) {
b = data[i];
data[i] = data[i+2];
data[i+2] = b;
}
break;
default:
return null;
}
BufferedImage image = new BufferedImage(cols, rows, type);
image.getRaster().setDataElements(0, 0, cols, rows, data);
return image;
}
the error points to the declaration line of Mat imageMat = new Mat (); , would anyone know what is causing this error? Thank you in advance.