Problems with Dnn TextDetectors (TextDetectionModel_DB & TextDetectionModel_EAST) on Android

I’m having several problems with text detection in android/java. I have everything written initially in C++ for testing and debugging, so far so good. but when running on android, it fails me in various ways. I will make a post for each one separately.
I’m using Opencv 4.5.1 for Android, and ARM v8, full built by my self from source, including extras and non-free. The app is the same. Running on Android 6.0.1.


using the DB_TD500_resnet18.onnx model


initialization

  int height = 320; 
  int width = 320;
  detector = new TextDetectionModel_DB(modelFilename); 
  detector.setBinaryThreshold(0.3);
  detector.setPolygonThreshold(0.5);
  detector.setUnclipRatio(3.0);
  detector.setMaxCandidates(200);
  detector.setInputParams(1.0 / 255.0, new Size(width, height), new Scalar(122.67891434, 116.66876762, 104.00698793));

then when detecting

 Mat imageDetect = new Mat( height, width, CvType.CV_8UC3 );
 Mat imageT = new Mat();
 Imgproc.resize(imageIn, imageT, new Size(width, height)); //just in case
 Imgproc.cvtColor(imageT, imageDetect, Imgproc.COLOR_BGRA2BGR); //4 to 3 channels as the model needs;
 List<MatOfPoint> detResults = new ArrayList<>();
 MatOfFloat detConfid = new MatOfFloat();
 detector.detect(imageDetect, detResults, detConfid); //<<<<<ERROR!

the error says:

 E/cv::error(): OpenCV(4.5.1) Error: Incorrect size of input array (Input size not specified) in processFrame, file C:/LIBs/opencv4.5.1/sources/modules/dnn/src/model.cpp, line 96
  E/org.opencv.dnn: dnn::detect_10() caught cv::Exception: OpenCV(4.5.1) C:/LIBs/opencv4.5.1/sources/modules/dnn/src/model.cpp:96: error: (-201:Incorrect size of input array) Input size not specified in function 'processFrame'
CvException [org.opencv.core.CvException: cv::Exception: OpenCV(4.5.1) C:/LIBs/opencv4.5.1/sources/modules/dnn/src/model.cpp:96: error: (-201:Incorrect size of input array) Input size not specified in function 'processFrame'
              ]
                  at org.opencv.dnn.TextDetectionModel.detect_0(Native Method)
                  at org.opencv.dnn.TextDetectionModel.detect(TextDetectionModel.java:52)
                  at abc.OCR_AI.OCR_AI.Recognice_TextInTheWild(OCR_AI.java:145)
                  at abc.MainActivity$4.run(MainActivity.java:1081)
                  at java.lang.Thread.run(Thread.java:833)         

the line on OpenCV source code reads:
if (size.empty()) CV_Error(Error::StsBadSize, “Input size not specified”);

but, I did set the size before !

with TextDetectionModel_EAST is the same (also manage to find another one when I set the initial settings)

MRE please. you gave no information on that variable.

I just corrected the post.
is just an image

All depends on ImageIn. Perhaps reading it fails.You don’t show how you do it and check that it goes ok.

Meta advice: You should check every line for success and every Mat for validity.

I did it.
But I’ll check again.


the image is right
a shame the detector don’t have something like a “getSize”, so you can check it is well initialized

TextDetectionModel_DB, TextDetectionModel_EAST and TextRecognitionModel all three give me the same error.
Can you give me a real working example to test?
I am now using the models directly, and partially replicating the post-processing helper functions in Java to continue the work. but doing this is somewhat cumbersome when everything is already done in the library.