Перейти к содержимому
Compvision.ru

RamaChandra

Пользователи
  • Количество публикаций

    3
  • Зарегистрирован

  • Посещение

Репутация

0 Новичек

О RamaChandra

  • Звание
    Новичок
  1. я знаю про Template Matching, но мне надо задать какие-то границы, чтобы определенные части изображения сравнивать(при этом чтобы все изображение было передо мной, т.е. без обрезания) ... Есть там такое? нашел что-то похожее... cvSetImageROI может кто еще знает что?
  2. Дорогие форумчане. Заинтересовался таким вопросом - как в (видео)изображении выделить нужные области(не обрезая) и их сравнивать с шаблонами? PS средствами OPENCV и C/C++.
  3. Дорогие друзья! Увидел здесь много умных людей, прошу вашей помощи. Очень важно. Программа распознавание лиц HMM. Так и не понял как решить эту проблему с функцией cvEstimateObsProb Пробовал OpenCV 2.3.1, 2.4.3, 2.4.6 - 2.4.8 Visual studio 2010 и 2012. Подскажите, люди добрые, что делать? void EHMMObjRecognition::Train( ImgObj &imgObj, EHMMObj &ehmmObj ) { const int MAX_ITER = 80; const double STOP_STEP_ITER = 0.01; CvImgObsInfo **obsInfoVec; IplImage *iplImg; int obsVecLen = _noDCTCoeff.width * _noDCTCoeff.height; CvSize _noObs; CvEHMM *tmplEhmm = ehmmObj.GetEHMM( ).GetCvEHMM( ); int numImages = (int)imgObj.GetNoImages( ); bool trained = false; float oldLikelihood = 0; int counter = 0; int i; assert( _imgWidth != -1 ); assert( _imgHeight != -1 ); if( _suppressIntensity ) { //Suppress first DCT coefficient obsVecLen--; } //Create the obsinfo array obsInfoVec = new CvImgObsInfo*[ numImages ]; assert( obsInfoVec != 0 ); for( i = 0; i < numImages; i++ ) { iplImg = imgObj.GetGrayScaleImage( i, _imgWidth, _imgHeight ); //Get how many DCT transforms we compute CountObs( *iplImg->roi, _dctSize, _stepSize, _noObs ); //Create the observation for each of the transforms obsInfoVec[ i ] = cvCreateObsInfo( _noObs, obsVecLen ); if( _suppressIntensity ) { float *observations = new float[ _noObs.height * _noObs.width * ( obsVecLen + 1 ) ]; cvImgToObs_DCT( iplImg, observations, _dctSize, _noDCTCoeff, _stepSize ); ExtractDCT( observations, obsInfoVec[ i ]->obs, _noObs.height * _noObs.width, obsVecLen ); if ( observations ) { delete( observations); } } else { cvImgToObs_DCT( iplImg, obsInfoVec[ i ]->obs, _dctSize, _noDCTCoeff, _stepSize ); } cvUniformImgSegm( obsInfoVec[ i ], tmplEhmm ); cvReleaseImage( &iplImg ); } cvInitMixSegm( obsInfoVec, numImages, tmplEhmm ); //Start the iterative training procedure while( ( !trained ) && ( counter < MAX_ITER ) ) { int j; float likelihood = 0; counter++; cvEstimateHMMStateParams( obsInfoVec, numImages, tmplEhmm ); cvEstimateTransProb( obsInfoVec, numImages, tmplEhmm); for( j = 0; j < numImages; j++ ) { cvEstimateObsProb( obsInfoVec[ j ], tmplEhmm ); /// в этой функции //причем первую итерацию завершает без ошибок // со второй выдает assertion failed и программа выходит likelihood += cvEViterbi( obsInfoVec[ j ], tmplEhmm ); } likelihood /= numImages * obsInfoVec[ 0 ]->obs_size; cvMixSegmL2( &obsInfoVec[ 0 ], numImages, tmplEhmm ); trained = ( fabs( likelihood - oldLikelihood ) < STOP_STEP_ITER ); oldLikelihood = likelihood; } //Clear the observations for( i = 0; i < numImages; i++ ) { cvReleaseObsInfo( &(obsInfoVec[ i ]) ); } delete []obsInfoVec; ehmmObj.GetEHMM( ).SetTrained( trained ); } что пишет: Assertion failed file: ...opencv\modules\legacy\src\hmm.cpp line: 636 Expression: sizeof(float*)==sizeof(int) Сам кусочек из hmm.cpp static CvStatus CV_STDCALL icvEstimateObsProb( CvImgObsInfo* obs_info, CvEHMM* hmm ) { int i, j; int total_states = 0; /* check if matrix exist and check current size if not sufficient - realloc */ int status = 0; /* 1 - not allocated, 2 - allocated but small size, 3 - size is enough, but distribution is bad, 0 - all ok */ for( j = 0; j < hmm->num_states; j++ ) { total_states += hmm->u.ehmm[j].num_states; } if ( hmm->obsProb == NULL ) { /* allocare memory */ int need_size = ( obs_info->obs_x * obs_info->obs_y * total_states * sizeof(float) + obs_info->obs_y * hmm->num_states * sizeof( CvMatr32f) ); int* buffer = (int*)cvAlloc( need_size + 3 * sizeof(int) ); buffer[0] = need_size; buffer[1] = obs_info->obs_y; buffer[2] = obs_info->obs_x; hmm->obsProb = (float**) (buffer + 3); status = 3; } else { /* check current size */ int* total= (int*)(((int*)(hmm->obsProb)) - 3); int need_size = ( obs_info->obs_x * obs_info->obs_y * total_states * sizeof(float) + obs_info->obs_y * hmm->num_states * sizeof( CvMatr32f/*(float*)*/ ) ); assert( sizeof(float*) == sizeof(int) ); /////////вот здесь. соответственно возвращает 3 if ( need_size > (*total) ) { int* buffer = ((int*)(hmm->obsProb)) - 3; cvFree( &buffer); buffer = (int*)cvAlloc( need_size + 3 * sizeof(int)); buffer[0] = need_size; buffer[1] = obs_info->obs_y; buffer[2] = obs_info->obs_x; hmm->obsProb = (float**)(buffer + 3); status = 3; } } if (!status) { int* obsx = ((int*)(hmm->obsProb)) - 1; int* obsy = ((int*)(hmm->obsProb)) - 2; assert( (*obsx > 0) && (*obsy > 0) ); /* is good distribution? */ if ( (obs_info->obs_x > (*obsx) ) || (obs_info->obs_y > (*obsy) ) ) status = 3; } ......
×