ehbsw_if_py.cpp
Go to the documentation of this file.
00001 #include "ehbsw.hpp"
00002 //#include <fstream>
00003 //#include <time.h>
00004 #include <iostream>
00005 #include <cstring>
00006 #include <cmath>
00007 
00008 
00009 
00010 // void ehbsw_l1(float* scores, int* vw_ima, int width, int height, int half_win_size, int d, float* classifier)
00011 // {
00012 //   EHBSW_LinHist_L1 a(scores, vw_ima, width, height, half_win_size, d, classifier);
00013 //   a.run_image();
00014 // }
00015 
00016 void ehbsw_pownorm(float* scores, int dim_out, int* vw_ima, int height, int width, int half_win_size, int d, float* classifier)
00017 {
00018   std::cout<<width<<"x"<<height<<" "<<scores<<" "<<d<<std::endl;
00019   std::cout<<classifier[0]<<" "<<classifier[1]<<" "<<classifier[2]<<"("<<d<<")"<<std::endl;
00020   std::cout<<half_win_size<<std::endl;
00021   EHBSW_PowNorm a(scores, vw_ima, width, height, half_win_size, d, classifier);
00022   a.run_image();
00023 }
00024 
00025 //void gen_windows()
00026 //{
00027 //}
00028 
00029 
00030 void create_histograms(float* h, int nmh, int nh, int mh, int* vws, int nvw, int mvw, float* bboxes, int nbboxes, int mbboxes)
00031 {
00032   //std::cout<<nmh<<" "<<nh<<" "<<mh<<" "<<nvw<<" "<<mvw<<" "<<nbboxes<<" "<<mbboxes<<std::endl;
00033 
00034   memset(h, 0, nmh*sizeof(float)); //cleaning before first use
00035   for(int i=0; i<nbboxes; i++)
00036   {
00037     //std::cout<<"bbox num "<<i<<std::endl;
00038     float bb_x1 = bboxes[i*mbboxes];
00039     float bb_y1 = bboxes[i*mbboxes+1];
00040     float bb_x2 = bboxes[i*mbboxes+2];
00041     float bb_y2 = bboxes[i*mbboxes+3];
00042      
00043     for(int j=0; j<nvw; j++)
00044     {
00045 
00046       int x = vws[j*mvw];
00047       int y = vws[j*mvw+1];
00048       int vw = vws[j*mvw+2];
00049       //std::cout<<x<<">="<<bb_x1<<" "<<y<<">="<<bb_y1<<" "<<x<<"<="<<bb_x2<<" "<<y<<"<="<<bb_y2<<std::endl;
00050       if(x>=bb_x1 && x<=bb_x2 && y>=bb_y1 && y<=bb_y2)
00051         h[vw+i*mh] += 1;
00052     }
00053   }
00054 }
00055 
00056 
00057 void gen_windows(float *bboxes_gw, int nmbboxes_gw, int *used, int xstep, int ystep, int widthmin, int widthmax, int widthstep, float *whratios, int nwhratios, int xmax, int ymax)
00058 {
00059   int ibbx=0;
00060   int nbboxes=nmbboxes_gw/4;
00061   //std::cout<<"nbboxes = "<<nbboxes<<std::endl;
00062   memset(bboxes_gw, 0, nmbboxes_gw*sizeof(float)); //cleaning before first use
00063   for(int i=0; i<nwhratios; i++)
00064   {
00065     float whr = whratios[i];
00066     for(float w=widthmin; w<widthmax; w+=widthstep)
00067     {
00068       float h=w*whr;
00069       //std::cout<<h<<" "<<widthmin<<" "<<widthmax<<" "<<widthstep<<" "<<w<<std::endl;
00070       for(int x=0+w/2; x<xmax-w/2; x+=xstep)
00071       {
00072         for(int y=0+h/2; y<ymax-h/2; y+=ystep)
00073         {
00074           bboxes_gw[ibbx*4]=fmax(0.,float(round(x-w/2)));
00075           bboxes_gw[ibbx*4+1]=fmax(0.,float(round(y-h/2)));
00076           bboxes_gw[ibbx*4+2]=fmin(float(round(x+w/2)),xmax-1.);
00077           bboxes_gw[ibbx*4+3]=fmin(float(round(y+h/2)),ymax-1.);
00078           //std::cout<<".";
00079           //std::cout<<x<<" "<<y<<" "<<bboxes_gw[ibbx*4]<<" "<<bboxes_gw[ibbx*4+1]<<" "<<bboxes_gw[ibbx*4+2]<<" "<<bboxes_gw[ibbx*4+3]<<std::endl;
00080           ibbx+=1;
00081           //std::cout<<ibbx<<std::endl;
00082         }
00083       }
00084     }
00085   }
00086   *used = ibbx;
00087 }
00088 
00089 
00090 int main(void)
00091 {
00092 
00093   return -100;
00094 }
00095 


iri_bow_object_detector
Author(s): dmartinez
autogenerated on Fri Dec 6 2013 22:45:45