Como Resolve esse Erro at org.opencv.imgproc.Imgproc.blur_2(Native Method)

Mais uma vez aqui pedindo ajuda pra comunidade, to me aprofundando nos estudos de OpenCV, só que surgem muitas duvidas, é que muitos componentes não funciona de uma versão pra outra, dai queria ver o pq desse erro.

    Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: OpenCV(4.3.0) C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\imgproc\src\box_filter.dispatch.cpp:446: error: (-215:Assertion failed) !_src.empty() in function 'cv::boxFilter'
]
	at org.opencv.imgproc.Imgproc.blur_2(Native Method)
	at org.opencv.imgproc.Imgproc.blur(Imgproc.java:4288)
	at br.com.sitemaPraia.Classes.reconhecimento.reconhecedorPlaca(reconhecimento.java:44)
	at br.com.sitemaPraia.Classes.entrada.main(entrada.java:42)

CLASSE RECONHECIMENTO

public class reconhecimento {
    public static int ver =0;
public static BufferedImage reconhecedorPlaca(Mat matrix,int m,int n,int a,int b,int c,int d,

int e ) {

int cols = matrix.cols();
 int rows = matrix.rows();

 int elemSize = (int)matrix.elemSize();

 byte[] data = new byte[cols * rows * elemSize];

 int type;

 Mat imagemResultanteCanny = new
Mat(matrix.rows(),matrix.cols(),CvType.CV_8UC1);

 Imgproc.blur(matrix, imagemResultanteCanny,new Size(3,3));
 Imgproc.Canny(imagemResultanteCanny, imagemResultanteCanny, m, n, 3, true);
 Imgcodecs.imwrite("canny"+m+"x"+n+"x3ver"+ver+".jpg", imagemResultanteCanny);
 ver++;

 Mat lines = new Mat();
 Imgproc.HoughLinesP(imagemResultanteCanny, lines, 2, Math.PI/180, b, c, d);
 System.out.println(lines.size());

 for (int x = 0; x < lines.cols(); x++)
 {
 double[] vec = lines.get(0, x);

 org.opencv.core.Point start = new org.opencv.core.Point();
 start.x = (int) vec[0];
 start.y = (int) vec[1];

 org.opencv.core.Point end = new org.opencv.core.Point();
 end.x = (int) vec[2];
 end.y = (int) vec[3];

  Imgproc.line(matrix, start, end, new Scalar(255,255,255), 2); 
 }

 Mat imagemResultanteCorner = new Mat();

 Imgproc.cornerHarris(imagemResultanteCanny, imagemResultanteCorner, 2, 3, 0.04, 1);

 Mat n_norm = new Mat();
 /*Imgproc.normalize(imagemResultanteCorner, n_norm,0,255,Core.compareTo(Core),CvType.CV_32FC1);*/
Mat s_norm = new Mat();
//Imgproc.conveScaleAbs(n_norm, s_norm);
Imgcodecs.imwrite("corner"+m+"x"+n+"x"+a+"x"+b+"x"+c+"x"+d+"x"+e+"ver"+ver+".jpg",
s_norm);
 for(int y = 0; y < imagemResultanteCorner.height(); y++){
 for(int x = 0; x < imagemResultanteCorner.width(); x++){
 if(s_norm.get(y,x)[0] > e ){
 Imgproc.circle(matrix, new org.opencv.core.Point(x,y),10, new Scalar(255), 2,8,0);
 }
 }
 }

 switch (matrix.channels()) {
 case 1:
 type = BufferedImage.TYPE_BYTE_GRAY;
 break;
 case 3:
 type = BufferedImage.TYPE_3BYTE_BGR;
 byte bI;
 for(int i=0; i<data.length; i=i+3) {

 bI = data[i];
 data[i] = data[i+2];
 data[i+2] = bI;
 }
 break;
 default:
 return null;
 }
matrix.get(0, 0, data);
 BufferedImage image2 = new BufferedImage(cols, rows, type);
 image2.getRaster().setDataElements(0, 0, cols, rows, data);
 return image2;

 }
}

CLASSE ENTADA

    identar texto pré-formatado por 4 espaços

 */
public class entrada {
public static void main(String[] args) {
try {
// carregando a biblioteca
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
System.out.println("começando");
int[] mm = { 10,100 };
int[] nn = { 10,100,300 };
int[] aa = { 1 };
int[] bb = { 5};
int[] cc = { 5,10,15 };
int[] dd = { 3 };
int[] ee = {200};
for (int m = 0; m < mm.length; m++) {
for (int n = 0; n < nn.length; n++) {
for (int a = 0; a < aa.length; a++) {
for (int b = 0; b < bb.length; b++) {
for (int c = 0; c < cc.length; c++) {
for (int d = 0; d < dd.length; d++) {
for(int e = 0; e < ee.length;e++){
// carregando a imagem original, ja em escala de cinza
    Mat imageGray = Imgcodecs.imread("C:\\Users\\PC\\Desktop\\placa.jpg\"");
BufferedImage temp = reconhecimento.reconhecedorPlaca(imageGray, mm[m], nn[n],
aa[a], bb[b], cc[c], dd[d],ee[e]);
File outputfile = new File("final" + aa[a]
+ "x" + bb[b] + "x" + cc[c] + "x" + dd[d] + "x" +ee[e]
+"x"
+ ".jpg");
ImageIO.write(temp, "jpg", outputfile);
}}}}}}}
} catch (IOException e) {
System.out.println("Error: " + e.getMessage());
}
}
}

quando postar código, seleciona ele todo e clica em </>

image


Esse é o erro completo?

1 curtida

Pior que tento, mas sempre erro.kkk
Já posto o erro, não tô em casa

é que vc aperta antes de selecionar, tem que deixar o texto selecionado e apertar

Blz, vou fazer um curso de guj kkk