hi, can be help me, with this "assertion failed ((img.depth()==cv_8U|| img.depth()==cv_32F)&&img.type()==templ.type())"
I'm working on a project in java, I'm using the match template. And gives me that error. anexo el codigo que tengo del metodo
public void MatchingMethod1() { Connection conect;
Mat template = frame;
try {
conect = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/imagen", "root", "12345");
PreparedStatement pps = (PreparedStatement) conect.prepareStatement("SELECT imagen FROM imagenes");
rst = pps.executeQuery();
while (rst.next()) {
Blob imagen = (Blob) rst.getBlob("imagen");
Mat imagenO = Highgui.imread(imagen.toString());
int result_cols = -imagenO.cols() + template.cols() + 1;
int result_rows = -imagenO.rows() + template.rows() + 1;
Mat result = new Mat(result_rows, result_cols, CvType.CV_32FC1);
Imgproc.matchTemplate(imagenO, template, result, Imgproc.TM_SQDIFF_NORMED);
Core.normalize(result, result, 0, 1, Core.NORM_MINMAX, -1, new Mat());
MinMaxLocResult mmr = Core.minMaxLoc(result);
double threashhold = 0.10;
if (mmr.maxVal > threashhold) {
JOptionPane.showMessageDialog(null, "Encontrado");
break;
} else {
JOptionPane.showMessageDialog(null, "No coincidencias suficientes");
}
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Any help is welcome
i can only guess, but
rst.getBlob("imagen");
will probably return an image "in memory" , not "on disk"is it a case of using imdecode() instead of imread() here ? (again, there will be nothing written to your hard your disk, given the current code)
again, - my guess is:
Mat imagenO
is just empty/invalid. (please check !)Could you explain how it would be to use imcode, please.