B4J Question OpenCV custom training


Licensed User
Longtime User
HI, All

Who is good specialist in the neural networks ?
I'm only trying to start, using jOpenCV. And i need some help (paid one is possible, sure).

I have to identify the units marked by digits and sometimes letters. Very special and custom digits\letters, manually placed, not any standard font, no similar glyphs, one digit is not same as another similar - each is made manually.

My first test to identify them using the OpenCV template matching the small image-example (that is cut from the camera frame) - was OK. But there are 400...500 real examples to be checked\identified. And sometimes these numbers are not well readable, but the template matching is OK with it - question is to get the available keypoints on the pictures.
So, questions are
1) How\by what software to train OpenCV NN for the custom templates. What is the result files of such training to be used in B4J project ?
2) Optimal algorithm to pre-process the examples.

TempDownload.png TempDownload.png

Any help for the training jOpenCV NN?
Last edited:


Well-Known Member
Licensed User
Longtime User
I've never trained any DNN model (I think some forum members have). But there's plenty of high-level online tools which I guess can produce the needed files to be used with jOpenCV's DNN module.

Alternatively, if you have a way to isolate the individual characters by whichever means, then you could use a Machine Learning (ML) approach. ML is, somehow, the predecessor of NN, but still very useful and faster for certain tasks.

In the past I used KNN (included in jOpenCV), training it with several symbols to do a SUDOKU solver and it worked really well, but the symbols were much clearer than in the pictures that you provided.
As a hint, normalize all the samples to a given size, binarize the them and work with HOG (histogram of Oriented Gradients) instead of the pixels to train the KNN.
There's plenty of documentation and example code about it. Since you have already used jOpenCV, translation should not be a problem

Whichever method you use, DNN or Machine Learning, you'll need several, if not many, picture samples of each different symbol in order to correctly train the model.
Upvote 0


Active Member
Licensed User
Longtime User
Upvote 0