/* // Getting feature pyramid // // API // int getFeaturePyramid(IplImage * image, const filterObject **all_F, const int n_f, const int lambda, const int k, const int startX, const int startY, const int W, const int H, featurePyramid **maps); // INPUT // image - image // OUTPUT // maps - feature maps for all levels // RESULT // Error status */ int getFeaturePyramid(IplImage * image, CvLSVMFeaturePyramid **maps) { IplImage *imgResize; float step; int numStep; int maxNumCells; int W, H; if(image->depth == IPL_DEPTH_32F) { imgResize = image; } else { imgResize = cvCreateImage(cvSize(image->width , image->height) , IPL_DEPTH_32F , 3); cvConvert(image, imgResize); } W = imgResize->width; H = imgResize->height; step = powf(2.0f, 1.0f / ((float)LAMBDA)); maxNumCells = W / SIDE_LENGTH; if( maxNumCells > H / SIDE_LENGTH ) { maxNumCells = H / SIDE_LENGTH; } numStep = (int)(logf((float) maxNumCells / (5.0f)) / logf( step )) + 1; allocFeaturePyramidObject(maps, numStep + LAMBDA); getPathOfFeaturePyramid(imgResize, step , LAMBDA, 0, SIDE_LENGTH / 2, maps); getPathOfFeaturePyramid(imgResize, step, numStep, LAMBDA, SIDE_LENGTH , maps); if(image->depth != IPL_DEPTH_32F) { cvReleaseImage(&imgResize); } return LATENT_SVM_OK; }
int getFeaturePyramid(IplImage * image, CvLSVMFeaturePyramid **maps, const int bx, const int by) { IplImage *imgResize; float step; unsigned int numStep; unsigned int maxNumCells; unsigned int W, H; if (image->depth == IPL_DEPTH_32F) { imgResize = image; } else { imgResize = cvCreateImage(cvSize(image->width, image->height), IPL_DEPTH_32F, 3); cvConvert(image, imgResize); } W = imgResize->width; H = imgResize->height; step = powf(2.0f, 1.0f / ((float) Lambda)); maxNumCells = W / Side_Length; if (maxNumCells > H / Side_Length) { maxNumCells = H / Side_Length; } numStep = (int) (logf((float) maxNumCells / (5.0f)) / logf(step)) + 1; allocFeaturePyramidObject(maps, numStep + Lambda); #ifdef PROFILE TickMeter tm; tm.start(); cout << "(featurepyramid.cpp)getPathOfFeaturePyramid START " << endl; #endif uploadImageToGPU1D(imgResize); getPathOfFeaturePyramidGPUStream(imgResize, step , Lambda, 0, Side_Length / 2, bx, by, maps); getPathOfFeaturePyramidGPUStream(imgResize, step, numStep, Lambda, Side_Length , bx, by, maps); cleanImageFromGPU1D(); #ifdef PROFILE tm.stop(); cout << "(featurepyramid.cpp)getPathOfFeaturePyramid END time = " << tm.getTimeSec() << " sec" << endl; #endif if (image->depth != IPL_DEPTH_32F) { cvReleaseImage(&imgResize); } return LATENT_SVM_OK; }
/* // Getting feature pyramid // // API // int getFeaturePyramid(IplImage * image, const filterObject **all_F, const int n_f, const int lambda, const int k, const int startX, const int startY, const int W, const int H, featurePyramid **maps); // INPUT // image - image // lambda - resize scale // k - size of cells // startX - X coordinate of the image rectangle to search // startY - Y coordinate of the image rectangle to search // W - width of the image rectangle to search // H - height of the image rectangle to search // OUTPUT // maps - feature maps for all levels // RESULT // Error status */ int getFeaturePyramid(IplImage * image, const int lambda, const int k, const int startX, const int startY, const int W, const int H, CvLSVMFeaturePyramid **maps) { IplImage *img2, *imgTmp, *imgResize; float step, tmp; int cntStep; int maxcall; int i; int err; CvLSVMFeatureMap *map; //geting subimage cvSetImageROI(image, cvRect(startX, startY, W, H)); img2 = cvCreateImage(cvGetSize(image), image->depth, image->nChannels); cvCopy(image, img2, NULL); cvResetImageROI(image); if(img2->depth != IPL_DEPTH_32F) { imgResize = cvCreateImage(cvSize(img2->width , img2->height) , IPL_DEPTH_32F , 3); cvConvert(img2, imgResize); } else { imgResize = img2; } step = powf(2.0f, 1.0f/ ((float)lambda)); maxcall = W/k; if( maxcall > H/k ) { maxcall = H/k; } cntStep = (int)(logf((float)maxcall/(5.0f))/logf(step)) + 1; //printf("Count step: %f %d\n", step, cntStep); allocFeaturePyramidObject(maps, lambda, cntStep + lambda); for(i = 0; i < lambda; i++) { tmp = 1.0f / powf(step, (float)i); imgTmp = resize_opencv (imgResize, tmp); //imgTmp = resize_article_dp(img2, tmp, 4); err = getFeatureMaps_dp(imgTmp, 4, &map); err = normalizationAndTruncationFeatureMaps(map, 0.2f); err = PCAFeatureMaps(map); (*maps)->pyramid[i] = map; //printf("%d, %d\n", map->sizeY, map->sizeX); cvReleaseImage(&imgTmp); } /**********************************one**************/ for(i = 0; i < cntStep; i++) { tmp = 1.0f / powf(step, (float)i); imgTmp = resize_opencv (imgResize, tmp); //imgTmp = resize_article_dp(imgResize, tmp, 8); err = getFeatureMaps_dp(imgTmp, 8, &map); err = normalizationAndTruncationFeatureMaps(map, 0.2f); err = PCAFeatureMaps(map); (*maps)->pyramid[i + lambda] = map; //printf("%d, %d\n", map->sizeY, map->sizeX); cvReleaseImage(&imgTmp); }/*for(i = 0; i < cntStep; i++)*/ if(img2->depth != IPL_DEPTH_32F) { cvReleaseImage(&imgResize); } cvReleaseImage(&img2); return LATENT_SVM_OK; }