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

mp_blink.cc

Go to the documentation of this file.
00001 /*
00002  *  mp_grabSamples.cc
00003  * 
00004  *  Grab samples 
00005  *
00006  *  Created by Ian Fasel on Wed May 28 2003.
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 
00022 #include "mpisearchMex.h"
00023 #include <iostream>   //TESTING!
00024 
00025 extern "C" {
00026 #include <math.h>
00027 #include <string.h>
00028 #include <stdlib.h>
00029 #include <sys/time.h>
00030 #include <unistd.h>
00031 #include "mex.h" 
00032 #include "matrix.h"  //FOR TESTING. TAKE OUT!
00033 }
00034 
00035 FaceBoxList faces;
00036 
00037 class Blink : public MPISearchMex {
00038  public:
00039   Blink(const mxArray ** ci, mxArray* &output) :
00040     MPISearchMex(ci,0,output) {};
00041   ~Blink() {}
00042 };
00043 
00044 extern "C" {
00045 void mexFunction(int nlhs,mxArray *plhs[],int nrhs, const mxArray *prhs[]);
00046 }
00047 
00048 void mexFunction(int nlhs,mxArray*plhs[],int nrhs, const mxArray*prhs[]) 
00049 {
00050   // cout << "entered mex function" << endl;
00051   // [samples] = mp_blink(ci, img)
00052   // check arguments
00053   if (nlhs !=1 )
00054     mexErrMsgTxt("mp_blink: requires 1 output");
00055   if (nrhs != 2)
00056     mexErrMsgTxt("mp_blink: requires 2 inputs");
00057   
00058   // get pointers into Mex data
00059   const mxArray ** ci = &(prhs[0]);
00060   double * img = mxGetPr(prhs[1]);
00061   int rows = static_cast<int>(mxGetM(prhs[1]));
00062   int cols = static_cast<int>(mxGetN(prhs[1]));
00063 
00064   // create image and make upright (i.e., transpose)
00065   RImage<float> pixels(cols, rows);
00066   for (int c = 0; c < cols; c++)
00067     for(int r = 0; r < rows; r++)
00068       pixels.array[cols*r+c] = *(img++);
00069   
00070   // Initialize the MPISearchMex object
00071   Blink *blink = new Blink((mxIsStruct(prhs[0]) ? ci : NULL), plhs[0]);
00072 
00073   // check if blink
00074   double index_flags[1], output_values[1];
00075   index_flags[0] = 1;
00076   //blink->setDebug(true);
00077   blink->search(pixels, faces, 0, 1.0f, &(index_flags[0]), &(output_values[0]));
00078   *(mxGetPr(plhs[0])) = output_values[0];
00079 
00080   delete blink;
00081 }
00082 

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