Lines Matching refs:hmm
111 // Parameters: hmm - addres of pointer to CvEHMM structure
112 // state_number - array of hmm sizes (size of array == state_number[0]+1 )
133 CvEHMM* hmm;
144 hmm = (CvEHMM*)cvAlloc( (state_number[0] + 1) * sizeof(CvEHMM) );
147 hmm[0].num_states = state_number[0];
148 hmm[0].level = 1;
178 /* set pointer to embedded hmm array */
179 hmm->u.ehmm = hmm + 1;
181 for( i = 0; i < hmm[0].num_states; i++ )
183 hmm[i+1].u.state = all_states;
185 hmm[i+1].num_states = state_number[i+1];
190 hmm[i].transP = icvCreateMatrix_32f( hmm[i].num_states, hmm[i].num_states );
191 hmm[i].obsProb = NULL;
192 hmm[i].level = i ? 0 : 1;
196 *this_hmm = hmm;
202 CvEHMM* hmm = phmm[0];
204 for( i = 0; i < hmm[0].num_states + 1; i++ )
206 icvDeleteMatrix( hmm[i].transP );
209 if (hmm->obsProb != NULL)
211 int* tmp = ((int*)(hmm->obsProb)) - 3;
215 cvFree( &(hmm->u.ehmm->u.state->mu) );
216 cvFree( &(hmm->u.ehmm->u.state) );
219 /* free hmm structures */
258 icvUniformImgSegm( CvImgObsInfo* obs_info, CvEHMM* hmm )
268 if ( !obs_info || !hmm ) return CV_NULLPTR_ERR;
270 first_state = hmm->u.ehmm->u.state;
275 int superstate = (int)((i * hmm->num_states)*inv_y);/* /obs_info->obs_y; */
277 int index = (int)(hmm->u.ehmm[superstate].u.state - first_state);
281 int state = (int)((j * hmm->u.ehmm[superstate].num_states)* inv_x); /* / obs_info->obs_x; */
291 CvEHMMState* first_state = hmm->u.ehmm->u.state;
294 if ( hmm->num_states > obs_info->obs_y ) return CV_BADSIZE_ERR;
297 float row_per_state = (float)obs_info->obs_y / hmm->num_states;
301 for( i = 0; i < hmm->num_states; i++ )
303 CvEHMM* ehmm = &(hmm->u.ehmm[i]);
309 for( i = 0; i < hmm->num_states - 1; i++ )
313 ss_bound[hmm->num_states - 1] = obs_info->obs_y;
319 for( i = 0; i < hmm->num_states; i++ )
321 CvEHMM* ehmm = &(hmm->u.ehmm[i]);
369 // hmm - pointer to HMM structure
376 icvInitMixSegm( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm )
393 CvEHMMState* first_state = hmm->u.ehmm->u.state;
395 for( i = 0 ; i < hmm->num_states; i++ )
397 total += hmm->u.ehmm[i].num_states;
595 // hmm - hmm
600 static CvStatus CV_STDCALL icvEstimateObsProb( CvImgObsInfo* obs_info, CvEHMM* hmm )
610 for( j = 0; j < hmm->num_states; j++ )
612 total_states += hmm->u.ehmm[j].num_states;
615 if ( hmm->obsProb == NULL )
619 obs_info->obs_y * hmm->num_states * sizeof( CvMatr32f) );
625 hmm->obsProb = (float**) (buffer + 3);
632 int* total= (int*)(((int*)(hmm->obsProb)) - 3);
634 obs_info->obs_y * hmm->num_states * sizeof( CvMatr32f/*(float*)*/ ) );
640 int* buffer = ((int*)(hmm->obsProb)) - 3;
647 hmm->obsProb = (float**)(buffer + 3);
654 int* obsx = ((int*)(hmm->obsProb)) - 1;
655 int* obsy = ((int*)(hmm->obsProb)) - 2;
669 float** tmp = hmm->obsProb;
673 for( i = 0; i < hmm->num_states; i++ )
675 hmm->u.ehmm[i].obsProb = tmp;
682 for( i = 0; i < hmm->num_states; i++ )
684 CvEHMM* ehmm = &( hmm->u.ehmm[i] );
709 for( i = 0; i < hmm->num_states; i++ )
711 CvEHMM* ehmm = &(hmm->u.ehmm[i]);
739 for( i = 0; i < hmm->num_states; i++ )
741 CvEHMM* ehmm = &(hmm->u.ehmm[i]);
840 for( i = 0; i < hmm->num_states; i++ )
842 CvEHMM* ehmm = &(hmm->u.ehmm[i]);
881 // hmm - pointer to HMM structure
887 icvEstimateTransProb( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm )
891 CvEHMMState* first_state = hmm->u.ehmm->u.state;
897 icvSetZero_32f( hmm->transP, hmm->num_states, hmm->num_states );
898 for (i = 0; i < hmm->num_states; i++ )
900 icvSetZero_32f( hmm->u.ehmm[i].transP , hmm->u.ehmm[i].num_states, hmm->u.ehmm[i].num_states );
920 begin_ind = (int)(hmm->u.ehmm[superstate].u.state - first_state);
925 int transP_size = hmm->num_states;
929 hmm->transP[superstate * transP_size + nextsuperstate] += 1;
934 int transP_size = hmm->u.ehmm[superstate].num_states;
937 hmm->u.ehmm[superstate].transP[ state * transP_size + nextstate] += 1;
943 for( i = 0; i < hmm->num_states; i++)
947 for( j = 0; j < hmm->num_states; j++)
949 total += hmm->transP[i * hmm->num_states + j];
955 for( j = 0; j < hmm->num_states; j++)
957 hmm->transP[i * hmm->num_states + j] =
958 hmm->transP[i * hmm->num_states + j] ?
959 (float)log( hmm->transP[i * hmm->num_states + j] * inv_total ) : -BIG_FLT;
964 for( k = 0; k < hmm->num_states; k++ )
966 CvEHMM* ehmm = &(hmm->u.ehmm[k]);
1000 // hmm
1006 icvMixSegmL2( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm )
1010 CvEHMMState* state = hmm->u.ehmm[0].u.state;
1048 CvStatus icvMixSegmProb(CvImgObsInfo* obs_info, int num_img, CvEHMM* hmm )
1052 CvEHMMState* state = hmm->ehmm[0].state_info;
1270 // hmm - HMM
1277 static float CV_STDCALL icvEViterbi( CvImgObsInfo* obs_info, CvEHMM* hmm )
1284 CvEHMMState* first_state = hmm->u.ehmm->u.state;
1287 CvMatr32f superB = icvCreateMatrix_32f(hmm->num_states, obs_info->obs_y );
1290 int*** q = (int***)cvAlloc( hmm->num_states * sizeof(int**) );
1293 for (i = 0; i < hmm->num_states; i++)
1304 for (i = 0; i < hmm->num_states; i++)
1306 CvEHMM* ehmm = &(hmm->u.ehmm[i]);
1318 superB[j * hmm->num_states + i] = max_gamma * inv_obs_x;
1324 icvViterbiSegmentation( hmm->num_states, obs_info->obs_y,
1325 hmm->transP, superB, 0,
1339 int state = (int)(hmm->u.ehmm[superstate].u.state - first_state);
1350 for (i = 0; i < hmm->num_states; i++)
1366 icvEstimateHMMStateParams( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm )
1377 CvEHMMState* first_state = hmm->u.ehmm[0].u.state;
1381 for(i = 0; i < hmm->num_states; i++ )
1383 total+= hmm->u.ehmm[i].num_states;
1624 CvEHMM* hmm = 0;
1630 IPPI_CALL( icvCreate2DHMM( &hmm, state_number, num_mix, obs_size ));
1634 return hmm;
1638 cvRelease2DHMM( CvEHMM ** hmm )
1644 IPPI_CALL( icvRelease2DHMM( hmm ));
1678 cvUniformImgSegm( CvImgObsInfo * obs_info, CvEHMM * hmm )
1684 IPPI_CALL( icvUniformImgSegm( obs_info, hmm ));
1690 cvInitMixSegm( CvImgObsInfo ** obs_info_array, int num_img, CvEHMM * hmm )
1696 IPPI_CALL( icvInitMixSegm( obs_info_array, num_img, hmm ));
1702 cvEstimateHMMStateParams( CvImgObsInfo ** obs_info_array, int num_img, CvEHMM * hmm )
1708 IPPI_CALL( icvEstimateHMMStateParams( obs_info_array, num_img, hmm ));
1714 cvEstimateTransProb( CvImgObsInfo ** obs_info_array, int num_img, CvEHMM * hmm )
1720 IPPI_CALL( icvEstimateTransProb( obs_info_array, num_img, hmm ));
1727 cvEstimateObsProb( CvImgObsInfo * obs_info, CvEHMM * hmm )
1733 IPPI_CALL( icvEstimateObsProb( obs_info, hmm ));
1739 cvEViterbi( CvImgObsInfo * obs_info, CvEHMM * hmm )
1747 if( (obs_info == NULL) || (hmm == NULL) )
1750 result = icvEViterbi( obs_info, hmm );
1758 cvMixSegmL2( CvImgObsInfo ** obs_info_array, int num_img, CvEHMM * hmm )
1764 IPPI_CALL( icvMixSegmL2( obs_info_array, num_img, hmm ));