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

FindFacesInGWorld Class Reference

#import <FindFacesInGWorld.h>

Collaboration diagram for FindFacesInGWorld:

Collaboration graph
[legend]
List of all members.

Public Member Functions

(void) FindFaces:
(FindFacesInGWorld *) init
(void) InitializeStreamWithWidth:Height:

Protected Attributes

bool initialized
MPISearchFaceDetectormpi
int subsampling

Member Function Documentation

- (void) FindFaces: (GWorldPtr)  gWorldPtr  
 

Definition at line 75 of file FindFacesInGWorld.mm.

References RImage::array, ObjectList::begin(), ObjectList::empty(), f(), FaceBoxList, faces, ObjectList::front(), grayImg, InitializeStreamWithWidth:Height:, mpi, ObjectList::pop_front(), MPISearchObjectDetector::search(), ObjectList::simplify(), TSquare::size, ObjectList::size(), square, Square, TSquare::x, and TSquare::y.

00075                  :(GWorldPtr)gWorldPtr
00076 {
00077     PixMapHandle        pixMapHandle = NULL;
00078     Ptr                 pixBaseAddr = nil;
00079 
00080     //struct timeval tv_now, last, tv_a, tv_b;
00081     //double totalTime, msgTime;
00082     //gettimeofday(&last,0);
00083 
00084     NSAssert(gWorldPtr != nil, @"nil gWorldPtr");
00085 
00086     // Lock the pixels
00087     pixMapHandle = GetGWorldPixMap(gWorldPtr);
00088     if (pixMapHandle)
00089     {
00090         Rect    portRect;
00091         int     portWidth, portHeight;
00092 
00093         NSAssert(LockPixels(pixMapHandle) != false, @"LockPixels returns false");
00094     
00095         GetPortBounds(gWorldPtr, &portRect);
00096         portWidth = (portRect.right - portRect.left);
00097         portHeight = (portRect.bottom - portRect.top);
00098 
00099         if(!initialized)
00100             [self InitializeStreamWithWidth:portWidth Height:portHeight];
00101         float   *theData = grayImg.array;
00102         int     pixmapRowBytes;
00103         int     srcRowByte,srcRowIndex;    
00104         pixBaseAddr = (unsigned char *)GetPixBaseAddr(pixMapHandle);
00105         int sm1 = (subsampling - 1)*4, sm2 = subsampling * 4;
00106         if (pixBaseAddr)
00107         {
00108             pixmapRowBytes = GetPixRowBytes(pixMapHandle);
00109             //float one_over_765 = 1.0f/(3.0f * 255.0f);
00110             for (srcRowIndex=0; srcRowIndex< portHeight; srcRowIndex+=subsampling)
00111             {
00112                 float *dst = theData + (srcRowIndex/subsampling) * (portWidth/subsampling);
00113                 unsigned char *src = pixBaseAddr + srcRowIndex * pixmapRowBytes;
00114                 //unsigned char a,r,g,b,r2,g2,b2,r3,g3,b3;
00115                 for (srcRowByte = 0; srcRowByte < portWidth; srcRowByte+=(subsampling*3))
00116                 {
00117                     *dst++ = (float)(src[1] + src[2] + src[3]);
00118                     src+=sm2;
00119                     *dst++ = (float)(src[1] + src[2] + src[3]);
00120                     src+=sm2;
00121                     *dst++ = (float)(src[1] + src[2] + src[3]);
00122                     src+=sm2;
00123                 }
00124             }
00125         }
00126         FaceBoxList faces;
00127         mpi->search(grayImg, faces);
00128         list<Square>::iterator it = faces.begin();
00129         faces.simplify(0.1f);
00130         if(faces.size() != 0) {
00131             while(!faces.empty( )){
00132                 Square face = faces.front(); 
00133                 faces.pop_front(); 
00134                 face.x*=subsampling; 
00135                 face.y*=subsampling; 
00136                 face.size*=subsampling; 
00137                 //NSLog(@"really at (%d, %d, %d)", face.x, face.y, face.size);
00138                 square(pixBaseAddr, face, pixmapRowBytes/4);
00139             }
00140         }
00141     }
00142 
00143     NSAssert(pixMapHandle != NULL, @"null pixMapHandle");
00144     NSAssert(pixBaseAddr != nil, @"nil pixBaseAddr");
00145 
00146     if (pixMapHandle)
00147     {
00148         UnlockPixels(pixMapHandle);
00149     }
00150     //gettimeofday(&tv_now,0);
00151     //totalTime = difftv(tv_now, last);
00152     //NSLog(@"\tThe search took %g seconds.", totalTime);
00153 
00154 }

Here is the call graph for this function:

- (FindFacesInGWorld *) init  
 

Definition at line 59 of file FindFacesInGWorld.mm.

References initialized, mpi, and subsampling.

00060 {
00061     mpi = new MPISearchFaceDetector;
00062     initialized = false;
00063     subsampling = 2;
00064     return [super init];
00065 }

- (void) InitializeStreamWithWidth: (int)  w
Height: (int)  h
 
 

Definition at line 67 of file FindFacesInGWorld.mm.

References grayImg, initialized, MPISearchObjectDetector::initStream(), mpi, RImage::setSize(), and subsampling.

Referenced by FindFaces:.

00067                                  :(int)w Height:(int)h
00068 {
00069     //NSLog(@"w = %d, h = %d", w, h);
00070     mpi->initStream(w/subsampling, h/subsampling);
00071     grayImg.setSize(w/subsampling, h/subsampling);
00072     initialized = true;
00073 }

Here is the call graph for this function:


Member Data Documentation

- (bool) initialized [protected]
 

Definition at line 28 of file FindFacesInGWorld.h.

Referenced by init, and InitializeStreamWithWidth:Height:.

- (MPISearchFaceDetector*) mpi [protected]
 

Definition at line 27 of file FindFacesInGWorld.h.

Referenced by FindFaces:, init, and InitializeStreamWithWidth:Height:.

- (int) subsampling [protected]
 

Definition at line 29 of file FindFacesInGWorld.h.

Referenced by init, and InitializeStreamWithWidth:Height:.


The documentation for this class was generated from the following files:
Generated on Mon Nov 8 17:08:32 2004 for MPT by  doxygen 1.3.9.1