Issue 1:
System information (version)

OpenCV => 4.2.5

Operating System / Platform => Android 10

Compiler => Visual Studio 2019 / Android Studio

Detailed description

When running a "DetectTextRectangles" from a "TextDetectionModel_EAST"

it throws the exception:

Org.Opencv.Core.CvException: 'cv::Exception: OpenCV(4.5.2) /build/master_pack-android/opencv/modules/dnn/src/model.cpp:96: error: (-201:Incorrect size of input array) Input size not specified in function 'processFrame'

Steps to reproduce

NB: The code might look a bit weird as it is c# in a Xamarin.Android project.

TextDetectionModel_EAST detector = new TextDetectionModel_EAST(EastTextDetectionPath);
detector.SetInputSize(640, 640);
detector.DetectTextRectangles(img, textboxesMat);

or

TextDetectionModel_EAST detector = new TextDetectionModel_EAST(EastTextDetectionPath);
Size siz = new Size(640, 640);
detector.SetInputParams(1.0, siz);
detector.DetectTextRectangles(img, textboxesMat);

if you do it "the hard way" it works

float nmsThresh = 0.4f;
Size siz = new Size(640, 640);
Net net = Dnn.ReadNetFromTensorflow(EastTextDetectionPath);

Mat blob = Dnn.BlobFromImage(img, 1.0, siz);

net.SetInput(blob);

JavaList<Mat> outs = new JavaList<Mat>();
JavaList<string> outNames = new JavaList<string>();
outNames.Add("feature_fusion/Conv_7/Sigmoid");
outNames.Add("feature_fusion/concat_3");
net.Forward(outs, outNames);

Issue 2:
System information (version)

OpenCV => 4.5.2

Operating System / Platform => Windows 64 Bit:

Compiler => Visual Studio 2017

Detailed description

java app crash when calling init(Mat image, Rect boundingBox) method of video module Tracker.java.

The following code is generated by gen_java.py.

java_bindings_generator\gen\cpp\video.inl.hpp

//
// void cv::Tracker::init(Mat image, Rect boundingBox)
//

JNIEXPORT void JNICALL Java_org_opencv_video_Tracker_init_10 (JNIEnv*, jclass, jlong, jlong, jint, jint, jint, jint);

JNIEXPORT void JNICALL Java_org_opencv_video_Tracker_init_10
(JNIEnv* env, jclass , jlong self, jlong image_nativeObj, jint boundingBox_x, jint boundingBox_y, jint boundingBox_width, jint boundingBox_height)
{

static const char method_name[] = "video::init_10()";
try {
LOGD("%s", method_name);
cv::Tracker* me = (cv::Tracker*) self; //TODO: check for NULL
Mat& image = *((Mat*)image_nativeObj);
Rect boundingBox(boundingBox_x, boundingBox_y, boundingBox_width, boundingBox_height);
me->init( image, boundingBox );
} catch(const std::exception &e) {
throwJavaException(env, &e, method_name);
} catch (...) {
throwJavaException(env, 0, method_name);
}
}

When I change the code generated by gen_java.py to the following, it works fine. cv::Tracker* -> Ptr<cv::Tracker>*

//
// void cv::Tracker::init(Mat image, Rect boundingBox)
//

JNIEXPORT void JNICALL Java_org_opencv_video_Tracker_init_10 (JNIEnv*, jclass, jlong, jlong, jint, jint, jint, jint);

JNIEXPORT void JNICALL Java_org_opencv_video_Tracker_init_10
(JNIEnv* env, jclass , jlong self, jlong image_nativeObj, jint boundingBox_x, jint boundingBox_y, jint boundingBox_width, jint boundingBox_height)
{

static const char method_name[] = "video::init_10()";
try {
LOGD("%s", method_name);
Ptr<cv::Tracker>* me = (Ptr<cv::Tracker>*) self; //TODO: check for NULL
Mat& image = *((Mat*)image_nativeObj);
Rect boundingBox(boundingBox_x, boundingBox_y, boundingBox_width, boundingBox_height);
(*me)->init( image, boundingBox );
} catch(const std::exception &e) {
throwJavaException(env, &e, method_name);
} catch (...) {
throwJavaException(env, 0, method_name);
}
}

Steps to reproduce

Tracker tracker = TrackerMIL.create();
tracker.init( mat, rect);

Issue submission checklist

I report the issue, it's not a question

I checked the problem with documentation, FAQ, open issues,

forum.opencv.org, Stack Overflow, etc and have not found solution

I updated to latest OpenCV version and the issue is still there

There is reproducer code and related data files: videos, images, onnx, etc