Ask Your Question

Revision history [back]

Checking the Sample Size Input for `cv::ml::StatModel::predict()` Loaded from File?

I'm loading an ML trained model from a file.
I noticed that when calling predict() with an input sample of the wrong size, the function does not (necessarily) fail! Apparently there is no internal checking that the input is of the right size!

I want to verify that when I'm calling predict(), my input sample is of the correct size. How can I do that? I cannot seem to find such a method to provide this info.

Checking the Sample Size Input for `cv::ml::StatModel::predict()` Loaded from File?

I'm loading an ML trained model from a file.
I noticed that when calling predict() with an input sample of the wrong size, the function does not (necessarily) fail! Apparently there is no internal checking that the input is of the right size!

I want to verify that when I'm calling predict(), my input sample is of the correct size. How can I do that? I cannot seem to find such a method to provide this info.

OpenCV 3.4. Some "sample" code:

``` cv::Ptr<cv::ml::statmodel> classifier = cv::Algorithm::load(...); // ...

cv::Mat sample32f; // fill sample32f

//...

classifier->predict(sample32f.reshape(1, 1)); // How to verify the correct expected size??? ```

Checking the Sample Size Input for `cv::ml::StatModel::predict()` Loaded from File?

I'm loading an ML trained model from a file.
I noticed that when calling predict() with an input sample of the wrong size, the function does not (necessarily) fail! Apparently there is no internal checking that the input is of the right size!

I want to verify that when I'm calling predict(), my input sample is of the correct size. How can I do that? I cannot seem to find such a method to provide this info.

OpenCV 3.4. Some "sample" code:

``` cv::Ptr<cv::ml::statmodel> classifier classifier = cv::Algorithm::load(...); // ...

cv::Mat sample32f; // fill sample32f

//...

classifier->predict(sample32f.reshape(1, classifier->predict(sample32f.reshape(1, 1)); // How to verify the correct correct expected size??? ```size???

Checking the Sample Size Input for `cv::ml::StatModel::predict()` Loaded from File?

I'm loading an ML trained model from a file.
I noticed that when calling predict() with an input sample of the wrong size, the function does not (necessarily) fail! Apparently there is no internal checking that the input is of the right size!

I want to verify that when I'm calling predict(), my input sample is of the correct size. How can I do that? I cannot seem to find such a method to provide this info.

OpenCV 3.4. Some "sample" code:

cv::Ptr<cv::ml::statmodel> classifier

cv::Ptr<cv::ml::StatModel> classifier = cv::Algorithm::load(...);  // ...

... cv::Mat sample32f; // fill sample32f

//...

classifier->predict(sample32f.reshape(1, 1)); sample32f //... classifier->predict(sample32f.reshape(1,1)); // How to verify the correct correct expected size???

size???