Hi Krzyslek,
Indeed, you have to select a number of states and number of discrete symbols in your alphabet beforehand. The number of states can often be inferred from some known characteristics of your sequences. For example, in
fingerspelling recognition [1] you can use the number of letters in a given word as the number of hidden states for the classifier corresponding to this word.
However, as I mentioned before, the problem of determining A, B and v is not plain "counting". You will have to use the Forward and Backward algorithms inside a modified E-M algorithm to estimate them (e.g. Baum-Welch) or use some other learning technique which can handle the sequences of hidden states. I think the best description and explanation I have ever seen on Baum-Welch for HMMs was given by Christopher Bishop on his book "
Pattern Recognition and Machine Learning". I think if you wish to implement your model from scratch this would be a must read, as it gives a lot of information on the involved probabilities.
You can only "count" things when your model is not hidden (i.e. you know beforehand the sequence of states which lead to a sequence of observations). But I think this may not be the case in your situation. You can find more information on creating those matrices by "counting" if you look for "Maximum Likelihood Estimation" of HMMs (it is different from what you have described, by the way).
So, answering your question: if you need your model to be hidden, you can't create the parameter matrices by counting. By the way; I am not sure if this is clear to you, but a gesture classifier is actually created using a collection of hidden Markov models, one for each gesture. So, if you would like to build a sequence classifier for D gestures you will build D models, each of them with their own A_D, B_D, v_D parameters.
Hope it helps!
Best regards,
Cesar
[1] Fingerspelling Recognition with Support Vector Machines and Hidden Conditional Random Fields - A Comparison with Neural Networks and Hidden Markov Models. César Roberto de Souza, Ednaldo Brigante Pizzolato, and Mauro dos Santos Anjo. IBERAMIA, volume 7637 of Lecture Notes in Computer Science, page 561-570. Springer, (2012)
[2] Christopher M. Bishop. Pattern Recognition and Machine Learning (Information Science and Statistics). Springer-Verlag New York, Inc., Secaucus, NJ, USA (2006).