int main() #endif { KLT_FeatureList fl; KLT_FeatureHistory fh; KLT_FeatureTable ft; int i; ft = KLTReadFeatureTable(NULL, "features.txt"); fl = KLTCreateFeatureList(ft->nFeatures); KLTExtractFeatureList(fl, ft, 1); KLTWriteFeatureList(fl, "feat1.txt", "%3d"); KLTReadFeatureList(fl, "feat1.txt"); KLTStoreFeatureList(fl, ft, 2); KLTWriteFeatureTable(ft, "ft2.txt", "%3d"); fh = KLTCreateFeatureHistory(ft->nFrames); KLTExtractFeatureHistory(fh, ft, 5); printf("The feature history of feature number 5:\n\n"); for (i = 0 ; i < fh->nFrames ; i++) printf("%d: (%5.1f,%5.1f) = %d\n", i, fh->feature[i]->x, fh->feature[i]->y, fh->feature[i]->val); KLTStoreFeatureHistory(fh, ft, 8); KLTWriteFeatureTable(ft, "ft3.txt", "%6.1f"); return 0; }
int main() #endif { unsigned char *img1, *img2; char fnamein[100], fnameout[100]; KLT_TrackingContext tc; KLT_FeatureList fl; KLT_FeatureTable ft; int nFeatures = 150, nFrames = 10; int ncols, nrows; int i; tc = KLTCreateTrackingContext(); fl = KLTCreateFeatureList(nFeatures); ft = KLTCreateFeatureTable(nFrames, nFeatures); tc->sequentialMode = TRUE; tc->writeInternalImages = FALSE; tc->affineConsistencyCheck = -1; /* set this to 2 to turn on affine consistency check */ img1 = pgmReadFile("img0.pgm", NULL, &ncols, &nrows); img2 = (unsigned char *) malloc(ncols*nrows*sizeof(unsigned char)); KLTSelectGoodFeatures(tc, img1, ncols, nrows, fl); KLTStoreFeatureList(fl, ft, 0); KLTWriteFeatureListToPPM(fl, img1, ncols, nrows, "feat0.ppm"); for (i = 1 ; i < nFrames ; i++) { sprintf(fnamein, "img%d.pgm", i); pgmReadFile(fnamein, img2, &ncols, &nrows); KLTTrackFeatures(tc, img1, img2, ncols, nrows, fl); #ifdef REPLACE KLTReplaceLostFeatures(tc, img2, ncols, nrows, fl); #endif KLTStoreFeatureList(fl, ft, i); sprintf(fnameout, "feat%d.ppm", i); KLTWriteFeatureListToPPM(fl, img2, ncols, nrows, fnameout); } KLTWriteFeatureTable(ft, "features.txt", "%5.1f"); KLTWriteFeatureTable(ft, "features.ft", NULL); KLTFreeFeatureTable(ft); KLTFreeFeatureList(fl); KLTFreeTrackingContext(tc); free(img1); free(img2); return 0; }
int main(int argc, char ** argv) { //Timer appTimer; //initTimer(&appTimer, "APP Time"); unsigned char *img1, *img2; char fnamein[100], fnameout[100]; KLT_TrackingContext tc; KLT_FeatureList fl; KLT_FeatureTable ft; int nFeatures; int nFrames; int ncols, nrows; int i; if(argc == 3) { nFeatures = atoi(argv[1]); nFrames = atoi(argv[2]); } else { nFeatures = 512; nFrames = 10; } tc = KLTCreateTrackingContext(); fl = KLTCreateFeatureList(nFeatures); ft = KLTCreateFeatureTable(nFrames, nFeatures); tc->sequentialMode = TRUE; tc->writeInternalImages = FALSE; tc->affineConsistencyCheck = -1; /* set this to 2 to turn on affine consistency check */ //startTimer(&appTimer); img1 = pgmReadFile("img0.pgm", NULL, &ncols, &nrows); img2 = (unsigned char *) malloc(ncols*nrows*sizeof(unsigned char)); KLTSelectGoodFeatures(tc, img1, ncols, nrows, fl); KLTStoreFeatureList(fl, ft, 0); KLTWriteFeatureListToPPM(fl, img1, ncols, nrows, "feat0.ppm"); for (i = 1 ; i < nFrames ; i++) { sprintf(fnamein, "img%d.pgm", i); pgmReadFile(fnamein, img2, &ncols, &nrows); KLTTrackFeatures(tc, img1, img2, ncols, nrows, fl); #ifdef REPLACE KLTReplaceLostFeatures(tc, img2, ncols, nrows, fl); #endif KLTStoreFeatureList(fl, ft, i); sprintf(fnameout, "feat%d.ppm", i); KLTWriteFeatureListToPPM(fl, img2, ncols, nrows, fnameout); } //stopTimer(&appTimer); //printTime(appTimer); //printf("Frames per second = %4.2f\n", nFrames / getTime(appTimer) *1000 ); KLTWriteFeatureTable(ft, "features.txt", "%5.1f"); KLTWriteFeatureTable(ft, "features.ft", NULL); KLTFreeFeatureTable(ft); KLTFreeFeatureList(fl); KLTFreeTrackingContext(tc); free(img1); free(img2); return 0; }
/** ============================================================================ * @func pool_notify_Execute * * @desc This function implements the execute phase for this application. * * @modif None * ============================================================================ */ NORMAL_API DSP_STATUS pool_notify_Execute (IN Uint32 numIterations, Uint8 processorId, IN Char8 * strFeatures, IN Char8 * strFrames) { DSP_STATUS status = DSP_SOK ; long long start; // Variables for klt unsigned char *img1, *img2; char fnamein[100], fnameout[100]; KLT_TrackingContext tc; KLT_FeatureList fl; KLT_FeatureTable ft; int ncols, nrows; int i; int nFeatures; int nFrames; #if defined(DSP) unsigned char *buf_dsp; #endif #ifdef DEBUG printf ("Entered pool_notify_Execute ()\n") ; #endif nFeatures = atoi(strFeatures); nFrames = atoi(strFrames); unit_init(); start = get_usec(); tc = KLTCreateTrackingContext(); fl = KLTCreateFeatureList(nFeatures); ft = KLTCreateFeatureTable(nFrames, nFeatures); tc->sequentialMode = TRUE; tc->writeInternalImages = FALSE; tc->affineConsistencyCheck = -1; /* set this to 2 to turn on affine consistency check */ //startTimer(&appTimer); img1 = pgmReadFile("img0.pgm", NULL, &ncols, &nrows); img2 = (unsigned char *) malloc(ncols*nrows*sizeof(unsigned char)); KLTSelectGoodFeatures(tc, img1, ncols, nrows, fl); KLTStoreFeatureList(fl, ft, 0); KLTWriteFeatureListToPPM(fl, img1, ncols, nrows, "feat0.ppm"); for (i = 1 ; i < nFrames ; i++) { sprintf(fnamein, "img%d.pgm", i); pgmReadFile(fnamein, img2, &ncols, &nrows); KLTTrackFeatures(tc, img1, img2, ncols, nrows, fl); #ifdef REPLACE KLTReplaceLostFeatures(tc, img2, ncols, nrows, fl); #endif KLTStoreFeatureList(fl, ft, i); sprintf(fnameout, "feat%d.ppm", i); KLTWriteFeatureListToPPM(fl, img2, ncols, nrows, fnameout); } //stopTimer(&appTimer); //printTime(appTimer); //printf("Frames per second = %4.2f\n", nFrames / getTime(appTimer) *1000 ); KLTWriteFeatureTable(ft, "features.txt", "%5.1f"); KLTWriteFeatureTable(ft, "features.ft", NULL); KLTFreeFeatureTable(ft); KLTFreeFeatureList(fl); KLTFreeTrackingContext(tc); free(img1); free(img2); #if !defined(DSP) printf(" Result is %d \n", sum_dsp(pool_notify_DataBuf,pool_notify_BufferSize)); #endif #if defined(DSP) POOL_writeback (POOL_makePoolId(processorId, SAMPLE_POOL_ID), pool_notify_DataBuf, pool_notify_BufferSize); POOL_translateAddr ( POOL_makePoolId(processorId, SAMPLE_POOL_ID), (void*)&buf_dsp, AddrType_Dsp, (Void *) pool_notify_DataBuf, AddrType_Usr) ; NOTIFY_notify (processorId,pool_notify_IPS_ID,pool_notify_IPS_EVENTNO,1); sem_wait(&sem); #endif printf("Sum execution time %lld us.\n", get_usec()-start); return status ; }