# \#ml

**URL:** https://forum.opencv.org/tag/ml/69.md

[Latest](https://forum.opencv.org/latest.md) · [Categories](https://forum.opencv.org/categories.md) · [Tags](https://forum.opencv.org/tags.md)

---

## [Seeking advice: self-training workflow for small object counting (2K camera, no pretrained models)](https://forum.opencv.org/t/seeking-advice-self-training-workflow-for-small-object-counting-2k-camera-no-pretrained-models/24142)

<div class="topic-metadata">

**Author:** [@Exto\_Logia](https://forum.opencv.org/u/Exto_Logia)\
**Replies:** 1\
**Last updated:** [October 24, 2025, 5:50pm UTC](https://forum.opencv.org/t/seeking-advice-self-training-workflow-for-small-object-counting-2k-camera-no-pretrained-models/24142 "2025-10-24T17:50:40Z")

</div>

I’m new in OpenCV and currently working on an object counting system using a 2K camera, but I’m not using any pretrained models or machine learning yet. My current pipeline is fully classical — it relies on OpenCV filter…

---

## [Issue when training the ML model](https://forum.opencv.org/t/issue-when-training-the-ml-model/19824)

<div class="topic-metadata">

**Author:** [@Tin\_Basic](https://forum.opencv.org/u/Tin_Basic)\
**Replies:** 1\
**Last updated:** [January 28, 2025, 5:57pm UTC](https://forum.opencv.org/t/issue-when-training-the-ml-model/19824 "2025-01-28T17:57:59Z")

</div>

Working on a model that recognizes handwritten digits from the MNIST dataset. Did my code in visual studio. After training the data i get Nan and inf in the output layer everytime. std::string fileNameImages = file…

---

## [How to save SVM models trained by python and use it Android for prediction?](https://forum.opencv.org/t/how-to-save-svm-models-trained-by-python-and-use-it-android-for-prediction/15862)

<div class="topic-metadata">

**Author:** [@Ranjit\_kw](https://forum.opencv.org/u/Ranjit_kw)\
**Replies:** 3\
**Last updated:** [December 15, 2023, 8:44am UTC](https://forum.opencv.org/t/how-to-save-svm-models-trained-by-python-and-use-it-android-for-prediction/15862 "2023-12-15T08:44:27Z")

</div>

\# define svm classifier model model = SVC(kernel='linear', probability=True) model.fit(face\_embd, labels) how to save it and use it on android kotlin

---

## [Using a MLP to classify lists of numbers](https://forum.opencv.org/t/using-a-mlp-to-classify-lists-of-numbers/13286)

<div class="topic-metadata">

**Author:** [@tamirmichael](https://forum.opencv.org/u/tamirmichael)\
**Replies:** 7\
**Last updated:** [May 24, 2023, 5:37pm UTC](https://forum.opencv.org/t/using-a-mlp-to-classify-lists-of-numbers/13286 "2023-05-24T17:37:17Z")

</div>

Hello and thank you for taking the time, This is my very first attempt to work with neural networks after reading some theory about them. What I am trying to do is to classify long lists of numbers (600+ of them per tr…

---

## [Prediction result shares no similarity with training data](https://forum.opencv.org/t/prediction-result-shares-no-similarity-with-training-data/13260)

<div class="topic-metadata">

**Author:** [@Shassk](https://forum.opencv.org/u/Shassk)\
**Replies:** 10\
**Last updated:** [May 22, 2023, 1:22pm UTC](https://forum.opencv.org/t/prediction-result-shares-no-similarity-with-training-data/13260 "2023-05-22T13:22:39Z")

</div>

I am trying to use an MLP for classification (yes, I’m aware of dnn, but now I’m interested in ml) so I put together a simple example to test things with a simple formula: array of classId / classesCount values =\> zero-f…

---

## [Deploy LBPHFaceRecognizer model without images](https://forum.opencv.org/t/deploy-lbphfacerecognizer-model-without-images/12635)

<div class="topic-metadata">

**Author:** [@yoko911](https://forum.opencv.org/u/yoko911)\
**Replies:** 2\
**Last updated:** [April 1, 2023, 2:20pm UTC](https://forum.opencv.org/t/deploy-lbphfacerecognizer-model-without-images/12635 "2023-04-01T14:20:18Z")

</div>

So I have trained a LBPHFaceRecognizer model using the CSV examples in the opencv documentation, is there a way to get the nodes/coefficients from the trained model and then apply them? I just don’t want to load or even…

---

## [Symbol recognition is very poor, not sure why](https://forum.opencv.org/t/symbol-recognition-is-very-poor-not-sure-why/12441)

<div class="topic-metadata">

**Author:** [@FatCat](https://forum.opencv.org/u/FatCat)\
**Replies:** 5\
**Last updated:** [March 22, 2023, 7:41am UTC](https://forum.opencv.org/t/symbol-recognition-is-very-poor-not-sure-why/12441 "2023-03-22T07:41:17Z")

</div>

Hi! I’m new to using OpenCV and I used this short tutorial for KNN character recognition. OpenCV 3 KNN Character Recognition C++ - YouTube I switched out the image used for training for one with custom drawn symbols. Ho…

---

## [2D Dataset Classifikation with HaarCascade](https://forum.opencv.org/t/2d-dataset-classifikation-with-haarcascade/11754)

<div class="topic-metadata">

**Author:** [@trausch](https://forum.opencv.org/u/trausch)\
**Replies:** 2\
**Last updated:** [January 25, 2023, 8:32pm UTC](https://forum.opencv.org/t/2d-dataset-classifikation-with-haarcascade/11754 "2023-01-25T20:32:05Z")

</div>

I want to teach a 2D data set. Is that possible? Background: I have a function curve y=f(x) and would like to have the resulting y (or its derivative) assigned to certain, fixed classes . I have only found examples for 3…

---

## [How to use cv::ml::Boost for a regression problem?](https://forum.opencv.org/t/how-to-use-cv-boost-for-a-regression-problem/11654)

<div class="topic-metadata">

**Author:** [@Olena\_Ivina](https://forum.opencv.org/u/Olena_Ivina)\
**Replies:** 0\
**Last updated:** [January 17, 2023, 2:40pm UTC](https://forum.opencv.org/t/how-to-use-cv-boost-for-a-regression-problem/11654 "2023-01-17T14:40:57Z")

</div>

The OpenCv documentation says that: class cv::ml::Boost - Boosted tree classifier derived from DTrees class cv::ml::RTrees - The class implements the random forest predictor With the RTrees I received correct predic…

---

## [OpenCV random forest parallelization](https://forum.opencv.org/t/opencv-random-forest-parallelization/10478)

<div class="topic-metadata">

**Author:** [@p-leroy](https://forum.opencv.org/u/p-leroy)\
**Replies:** 0\
**Last updated:** [October 7, 2022, 2:04pm UTC](https://forum.opencv.org/t/opencv-random-forest-parallelization/10478 "2022-10-07T14:04:55Z")

</div>

I have read the sources of OpenCV and it seems like the random forest implementation is not parallelized. Is it really the case? And if yes, is there a specific reason why the random forest has not been parallelized? Th…

---

## [What do the values returned from cv::ml::StatModel::predict() when using the RAW\_OUTPUT flag represent?](https://forum.opencv.org/t/what-do-the-values-returned-from-cv-predict-when-using-the-raw-output-flag-represent/8449)

<div class="topic-metadata">

**Author:** [@snsc](https://forum.opencv.org/u/snsc)\
**Replies:** 1\
**Last updated:** [April 20, 2022, 8:33am UTC](https://forum.opencv.org/t/what-do-the-values-returned-from-cv-predict-when-using-the-raw-output-flag-represent/8449 "2022-04-20T08:33:45Z")

</div>

I’m using an SVM to predict if images are of one label or another. I wanted to get some more information from the cv::ml::StatModel::predict method, so I used the RAW\_OUTPUT flag to get some value other than just the pre…

---

## [Calculate slope and bias of linear decision function \[SVM\]](https://forum.opencv.org/t/calculate-slope-and-bias-of-linear-decision-function-svm/4982)

<div class="topic-metadata">

**Author:** [@lando\_k](https://forum.opencv.org/u/lando_k)\
**Replies:** 0\
**Last updated:** [August 30, 2021, 2:17pm UTC](https://forum.opencv.org/t/calculate-slope-and-bias-of-linear-decision-function-svm/4982 "2021-08-30T14:17:23Z")

</div>

Hi all, for my project I need to get the exact parameters of the decision function calculated by the SVM. Right now, I’m struggling to understand the output of the methods getDecisionFunction() and getUncompressedSuppo…

---

## [Boost training issue: vector subscript out of range](https://forum.opencv.org/t/boost-training-issue-vector-subscript-out-of-range/3737)

<div class="topic-metadata">

**Author:** [@dporto](https://forum.opencv.org/u/dporto)\
**Replies:** 5\
**Last updated:** [June 18, 2021, 2:53pm UTC](https://forum.opencv.org/t/boost-training-issue-vector-subscript-out-of-range/3737 "2021-06-18T14:53:15Z")

</div>

I am having trouble with training a Boosted trees model for regression. I am using the code below to train the model, but get a runtime error for “vector subscript out of range” Ptr\<TrainData\> trainingData = TrainData::…

---

## [Random Forest setting random seed](https://forum.opencv.org/t/random-forest-setting-random-seed/3733)

<div class="topic-metadata">

**Author:** [@dporto](https://forum.opencv.org/u/dporto)\
**Replies:** 3\
**Last updated:** [June 9, 2021, 2:42pm UTC](https://forum.opencv.org/t/random-forest-setting-random-seed/3733 "2021-06-09T14:42:46Z")

</div>

Since there is randomness involved in the computation of a random forest classifier, it is necessary to define a random seed to get reproducible results. Is this possible to do in the current implementation of the algori…

---

## [Attempt at an artwork classifier using a bag of visual words model keeps predicting the same class](https://forum.opencv.org/t/attempt-at-an-artwork-classifier-using-a-bag-of-visual-words-model-keeps-predicting-the-same-class/3618)

<div class="topic-metadata">

**Author:** [@Palves](https://forum.opencv.org/u/Palves)\
**Replies:** 2\
**Last updated:** [June 1, 2021, 7:38am UTC](https://forum.opencv.org/t/attempt-at-an-artwork-classifier-using-a-bag-of-visual-words-model-keeps-predicting-the-same-class/3618 "2021-06-01T07:38:35Z")

</div>

I’m trying to do a classifier for artwork using a bag of visual words model. However, I keep getting the same prediction for every artwork I feed into it. It seems like it keeps predicting the most repeated class in the …

---

## [From ANN\_MLP to dnn](https://forum.opencv.org/t/from-ann-mlp-to-dnn/2080)

<div class="topic-metadata">

**Author:** [@ffolch](https://forum.opencv.org/u/ffolch)\
**Replies:** 6\
**Last updated:** [March 11, 2021, 2:33pm UTC](https://forum.opencv.org/t/from-ann-mlp-to-dnn/2080 "2021-03-11T14:33:40Z")

</div>

I’d like to execute an ANN\_MLP on GPU I think it’s not possible, isn’t it? So, I’d like to create automatically a neuroan network based on dnn module, from the module file that contains the trained model and its arquit…

---

## [Any recommendations for video (motion-based) machine-learning?](https://forum.opencv.org/t/any-recommendations-for-video-motion-based-machine-learning/1460)

<div class="topic-metadata">

**Author:** [@Charles\_R](https://forum.opencv.org/u/Charles_R)\
**Replies:** 2\
**Last updated:** [February 13, 2021, 2:50am UTC](https://forum.opencv.org/t/any-recommendations-for-video-motion-based-machine-learning/1460 "2021-02-13T02:50:30Z")

</div>

I have been looking into machine learning tools for a while, esp. pyTorch and scikitlearn and want to use them for object identification. All the resources I have found so far, however, deal with image recognition rather…

---

## [Segmentation fault](https://forum.opencv.org/t/segmentation-fault/1260)

<div class="topic-metadata">

**Author:** [@Jan\_Hackenberg](https://forum.opencv.org/u/Jan_Hackenberg)\
**Replies:** 1\
**Last updated:** [February 1, 2021, 9:11pm UTC](https://forum.opencv.org/t/segmentation-fault/1260 "2021-02-01T21:11:08Z")

</div>

I am trying to execute based on example code: using namespace cv; using namespace cv::ml; // mat is a Mat containing the features computed beforehand Ptr\<EM\> model = EM::create(); model-\>setClustersNumber(stat…
