The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

mpisearchMexObject.cc

Go to the documentation of this file.
00001 /*
00002  *  mpisearchMex.cc
00003  * 
00004  *  Matlab interface for calling C++ mpisearch face detector from matlab  
00005  *
00006  *  Created by Ian Fasel on Thu Apr 18 2002.
00007  * 
00008  *  Copyright (c) 2003 Machine Perception Laboratory
00009  *  University of California San Diego.
00010  *
00011  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
00012  *
00013  *    1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
00014  *    2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
00015  *    3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00018  *
00019  */
00020 
00021 #include "mpisearchMex.h"
00022 // #include "ci.h"
00023 #include "gentleFace1.h"
00024 #include "loadstruct.h"
00025 #include <iostream>   //TESTING!
00026 
00027 extern "C" {
00028 #include <math.h>
00029 #include <string.h>
00030 #include <stdlib.h>
00031 #include <sys/time.h>
00032 #include <unistd.h>
00033 #include "mex.h" 
00034 #include "matrix.h"  //FOR TESTING. TAKE OUT!
00035 }
00036 
00037 
00038 MPISearchMex::MPISearchMex (const mxArray ** ci, const int &max_num_patches_, mxArray* &patch_array)
00039 {
00040   cout << "Entered MPISearchMex constructor" << endl;
00041   if(ci){
00042     mpisearchMexData::loadStruct(ci,data);
00043     isBinary = false;
00044   } else {
00045     //ci::assignData(data);
00046     gentleFace1::assignData(data);
00047     isBinary = true;
00048   }     
00049   max_num_patches = max_num_patches_;
00050 
00051   // Allocate memory for patches
00052   int dims[3] = {data.patchsize, data.patchsize, max_num_patches};
00053   if(max_num_patches)
00054     patch_array = mxCreateNumericArray(3,dims,mxDOUBLE_CLASS, mxREAL);
00055   else
00056     patch_array = mxCreateNumericMatrix(1, 1, mxDOUBLE_CLASS, mxREAL);
00057   patches = mxGetPr(patch_array);
00058 }
00059 
00060 MPISearchMex::~MPISearchMex (){
00061   //  cout << "numfeatures: " << data.numfeatures << endl;
00062   if (!isBinary) {
00063     mpisearchMexData::releaseStruct(data);
00064   }
00065   //  data.cascades = NULL;
00066   //  data.features = NULL;
00067   //  data.numfeatures = 0;
00068   //  data.numcascades = 0;
00069 }
00070 
00071 
00072 int MPISearchMex::patchSize(){return data.patchsize;}
00073 
00074 void MPISearchMex::processFace(MPIScaledImage<float>::const_iterator &window, 
00075                     const float &one_over__sf2_times_std, 
00076                     const float & mean_over_std, const int &numFaces){
00077   // write detections into array
00078   // Note that the arrays are transposed for better use in Matlab
00079 
00080   //  if(numFaces < max_num_patches){
00081   //    double * p = &(patches[data.patchsize*data.patchsize*numFaces]);
00082   //    for(int c = 0; c < data.patchsize; ++c)
00083   //      for(int r = 0; r < data.patchsize; ++r)
00084   //    *(p++) = static_cast<double>(window.getScalePixel(0,c,r));
00085   //  }
00086 }

Generated on Mon Nov 8 17:07:46 2004 for MPT by  doxygen 1.3.9.1