Definition at line 383 of file KfrMotionExtractor.h. References BYTE, CalcEnergy(), FillBuffer(), IsInShot, m_bNormalize, m_verbose, OnShotEnd(), OnShotStart(), and TPL_NUM. Referenced by HandleNewFrame(). 00384 { 00385 IsInShot = FALSE; 00386 00387 // ZeroMemory for m_EnergyMap[] and m_EnergyBuffer[] 00388 OnShotStart(bWidth, bHeight); 00389 00390 for (int t=0; t<2*TPL_NUM; t++) 00391 { 00392 feature[t] = 0.0; 00393 } 00394 00395 //int CurBufSize = 5; 00396 if (WindowLen < CurBufSize) 00397 { 00398 printf("Error: WindowLen (%d) is smaller than CurBufSize (%d)\n", WindowLen, CurBufSize); 00399 return 1; 00400 } 00401 int num = WindowLen - CurBufSize; 00402 for (int index = 0; index < 1+num; index++) 00403 { 00404 // Just the fill the buffer according to the motion vector information 00405 FillBuffer(CurBufSize, bWidth, bHeight, mvseq + sizeof(BYTE)*bWidth*bHeight*2*index); 00406 00407 int i=0; 00408 float Temp1Energy[TPL_NUM]; 00409 float Temp2Energy[TPL_NUM]; 00410 float diffEnergy[TPL_NUM]; 00411 memset(diffEnergy,0,TPL_NUM*sizeof(float)); 00412 00413 for (i=0;i<TPL_NUM;i++) 00414 { 00415 // Use the weight template to calculate the total energy value 00416 float Energy = 0.0; 00417 if (m_bNormalize) 00418 { 00419 Energy = CalcEnergy(i, bWidth, bHeight); 00420 } else { 00421 Energy = CalcEnergy(i, bWidth, bHeight, FALSE); 00422 } 00423 00424 // update Temp1Energy[] and Temp2Energy[] for late compute their diffs 00425 if (index==0) 00426 Temp1Energy[i]=Energy; 00427 else if (index==1) 00428 Temp2Energy[i]=Energy; 00429 else //index>1 00430 { 00431 Temp1Energy[i] = Temp2Energy[i]; 00432 Temp2Energy[i] = Energy; 00433 } 00434 00435 if (m_verbose) printf("%.5f\t", Energy); 00436 00437 //sum up all the values, to compute averages later. 00438 feature[i] += Energy; 00439 } 00440 //printf("\n"); 00441 00442 // Here there are TPL_NUM pairs of data, we get the diffs of them 00443 // first diff energy has been initialized as zero 00444 if (index>0) 00445 { 00446 for (i=0;i<TPL_NUM;i++) 00447 { 00448 if (m_bNormalize) 00449 { 00450 // [-1,1] --> [0,1] 00451 diffEnergy[i] = fabs(Temp2Energy[i] - Temp1Energy[i]); 00452 //diffEnergy[i] = Normalization(diffEnergy[i],-1.0,1.0); 00453 } else { 00454 diffEnergy[i] = Temp2Energy[i] - Temp1Energy[i]; 00455 } 00456 00457 if (m_verbose) printf("%.5f\t", diffEnergy[i]); 00458 00459 //sum up all the values, to compute averages later. 00460 feature[TPL_NUM+i] += diffEnergy[i]; 00461 00462 } 00463 if (m_verbose) printf("\n"); 00464 00465 } else { 00466 00467 //index==0 00468 if (m_verbose) printf("diff1\tdiff2\tdiff3\n"); 00469 00470 for (i=0;i<TPL_NUM;i++) 00471 { 00472 //if (m_verbose) printf("%.5f\t", diffEnergy[i]); 00473 feature[TPL_NUM+i] = 0.0; 00474 } 00475 } 00476 } 00477 00478 OnShotEnd(bWidth, bHeight); 00479 00480 // calculate the averages of the feature within current Window buffer 00481 for (int t=0; t<TPL_NUM; t++) 00482 { 00483 feature[t] /= num+1; 00484 feature[TPL_NUM+t] /= num; // one less than three original values 00485 } 00486 00487 if (m_verbose) 00488 { 00489 printf("\nThe Average as the final feature:\n"); 00490 for (int t=0; t<2*TPL_NUM; t++) 00491 { 00492 printf("%.5f ",feature[t]); 00493 } 00494 printf("\n\n"); 00495 } 00496 00497 return 0; 00498 00499 }
Here is the call graph for this function:
|