Make haar feature scale -


this code

import java.awt.image.bufferedimage;  public class haarfeature {     public static void getfeature(bufferedimage image){         int width  = image.getwidth();         int height = image.getheight();         //int feature_width=1*scale_width;         //int feature_height=1*scale_height;         int[][] ii = integralimage.convintegralimage(image);         int white=0;         int black=0;         int feature=0;         for(int i=0;i<height;i++){             for(int j=0;j<width;j++){                 if(i<(height-1) && j<(width-3)){                     if(i==0 && j==0){                         black=ii[i][j+3];                         white=ii[i+1][j+3]-ii[i][j+3];                         feature=black-white;                         system.out.print(feature+" ");                     }                     else if(i==0){                         black=ii[i][j+3]-ii[i][j-1];                         white=ii[i+1][j+3]+ii[i][j-1]-ii[i][j+3]-ii[i+1][j-1];                         feature=black-white;                         system.out.print(feature+" ");                     }                     else if(j==0){                         black=ii[i][j+3]-ii[i-1][j+3];                         white=ii[i+1][j+3]-ii[i][j+3];                         feature=black-white;                         system.out.print(feature+" ");                     }                     else{                         black=ii[i][j+3]+ii[i-1][j-1]-ii[i][j-1]-ii[i-1][j+3];                         white=ii[i+1][j+3]+ii[i][j-1]-ii[i][j+3]-ii[i+1][j-1];                         feature=black-white;                         system.out.print(feature+" ");                     }                 }             }             system.out.println();         }      } } 

this code generate 1 rectangle features 2px x 4px. know, there many rectangle features in haar features. how code make scale in haar features? please me

i can , program in c++, check mi code generate haar feature:

int sizex = feature[i][0]; int sizey = feature[i][1]; // each position: (int x = 0; x <= framesize-sizex; x++) {     (int y = 0; y <= framesize-sizey; y++) {         // each size fitting within framesize:         (int width = sizex; width <= framesize-x; width+=sizex) {             (int height = sizey; height <= framesize-y; height+=sizey) {                 count++;                       }                  }            }      } 

this code gives correct number of features shown in article of lienhart, r. , maydt, j., "an extended set of haar-like features rapid object detection", icip02, pp. i: 900–903, 2002.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -