cv.jit.learn && cv.jit.blobs.recon

Berani's icon

I'm trying to create a training model with cv.jit.learn. Next I want to be able to recognize this model with cv.jit.blobs.recon.

I used part of the patch that recognizes the letters A and M with cv.jit.blobs.recon, only I load my own mxb file which I trained with cv.jit.learn (what exactly do i need to know to train a good model?) I took just part of an image..say a letter or a clear pattern, train it with cv.jit.learn. Next I try to recognize this part of the total image us the total image as movie input and loading the trained mxb in cv.jit.blobs.recon.

It doesn't seem to work though, I get no output similar to when using carpe.gif in the cv.jit.blobs.recon demo patch which shows letter A and M when using the right .mxb files.

Jean-Marc Pelletier's icon

Quote: Berani wrote on Sat, 21 October 2006 10:47
----------------------------------------------------
>(what exactly do i need to know to train a good model?)

How you train depends on the situation in which you will use the model. If the training data has very little variation, you will get a very strict model that is likely to give a lot of false negatives. On the other hand, if there is too much variation in the data, then the model will be too loose and you will get false positives.

For the A and M models, I used jit.lcd to draw those letters using every font on my system (excluding non-letter and unusual fonts).

If you're working from a still image, try this: isolate the part you want to recognize, and move it around, make it smaller or bigger, even rotate it slightly if you're using moments, or completely if you're using invariants.

Test the model with cv.jit.learn itself, cv.jit.blobs.recon uses exactly the same algorithm.

Lastly, the distance returned by either cv.jit.learn or cv.jit.blobs.recon is not in itself meaningful. That is, depending on the model you may need to adjust the detection threshold to 2, 5 or even 20. You need to compare the output of positives versus negatives to find the correct value.

In my experience, if you want to improve detection even more, it's useful to add manual checks: look at the training data and add conditionals: m20 has to be greater than m02, m11 has to be positive, m30 has to be negative, for instance. When working with multiple shapes that are somewhat similar, you may need to add checks like this: letter is 'M' if distance from 'M' model is smaller than both threshold and distance from 'O' model, else letter is 'O'.

> It doesn't seem to work though, I get no output similar to when using carpe.gif in the cv.jit.blobs.recon demo patch which shows letter A and M when using the right .mxb files.

What is the output of cv.jit.blobs.recon using your model and a positive match? What about a negative match?

Jean-Marc

Berani's icon

Well, I thought the output had to be an image like in the demo with the letters A and M.

Therefore I thought training part of an image would result in just that part being visible when I would put the entire object in front of my cam with the part on it that had to be recognized. Just like the letters A and M becoming visible in the demo.

Your reply has been very useful, I'm gonna check out the things you've mentioned and see if I can come up with something.

Jean-Marc Pelletier's icon

Quote: Berani wrote on Tue, 24 October 2006 02:54
----------------------------------------------------
> Well, I thought the output had to be an image like in the demo with the letters A and M.

No no no. Notice, in the helpfile, the _labeled_ image is sent to jit.charmap, which isolates the letters. The output of cv.jit.blobs.recon only measures the statistical distance from the model for each blob; the smaller the distance, the more similar the blob is to the training data.