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

eyefinder/windows/FilterSrc/FilterInterface.h

Go to the documentation of this file.
00001 #ifndef __FILTERINTERFACE_H__
00002 #define __FILTERINTERFACE_H__
00003 
00004 #include <windows.h>
00005 #include "eyefinderBinary.h"
00006 #include "faceobject.h"
00007 #include "Images/color.h"
00008 
00009 class FilterInterface
00010 {
00011 public:
00012 
00013         FilterInterface();    // Constructor
00014         ~FilterInterface();     // Destructor
00015 
00016         int runInterface(BYTE *pData, int imgWidth, int imgHeight);
00017         void printFrame(RGBTRIPLE *prgb, int cxImage, int cyImage);
00018 
00019 private:
00020 
00021   MPEyeFinder *m_eyefinder;
00022   VisualObject m_faces;
00023         VisualObject m_lastFace;
00024         RImage<float> m_pixels;
00025         MPColorTools colorT;
00026         int m_failedCycles;
00027         bool m_failedSearch;
00028 
00029 // ================================================================
00030 
00031         inline void GreyScaleFlipVideo(int width, int height, RGBTRIPLE *rgbpix, RImage<float> & pixels)
00032         {
00033                 RGBTRIPLE *source;
00034                 unsigned char *sp;
00035                 float *dest;
00036 
00037                 // convert image to grayscale and out of directshow coordinates 
00038                 for (int y=0; y < height; y++) {
00039                         source = rgbpix + width * ((height-1) - y);
00040                         sp = (unsigned char *) source;
00041                         dest = pixels.array + width*y;
00042                         for (int x = 0; x < width; x++) {
00043                                 *dest++ = (float)(sp[2] + sp[1]*6 + sp[0]*3);
00044                                 sp += 3;
00045                         }
00046                 }
00047 
00048         } 
00049 
00050 // ================================================================
00051 
00052         inline void DrawBoxes(RGBTRIPLE *prgb, int cxImage, int cyImage)
00053         {  
00054                 bool firstface = true;
00055                 RGBCOLOR color;
00056                 double alpha;
00057                 FFImage<RGBTRIPLE> rgbimage(prgb, cxImage, cyImage);
00058 
00059                 if(m_failedSearch) alpha = exp(-m_failedCycles*0.25);
00060                 else alpha = 1;
00061                 list<VisualObject *>::iterator face = m_lastFace.begin();
00062                 list<VisualObject *>::iterator last_face = m_lastFace.end();
00063                 for ( ; face != last_face; ++face) {
00064                         //print face box
00065                         if(firstface) color = RGBRED;
00066                         else color = RGBBLUE;
00067                         FaceObject *fo = static_cast<FaceObject*>(*face);
00068                         colorT.DrawRGBBox(rgbimage, fo->x, fo->y, fo->xSize, fo->ySize, color, alpha);
00069 
00070                         //print eye boxes
00071                         color = RGBWHITE;
00072                         float eyeSize = fo->xSize * 0.1;
00073                         //left eye
00074                         colorT.DrawRGBBox(rgbimage, static_cast<int>(fo->eyes.xLeft-eyeSize), static_cast<int>(fo->eyes.yLeft-eyeSize), 
00075                                                 static_cast<int>(eyeSize*2), static_cast<int>(eyeSize*2), color, alpha);
00076                         
00077                         //right eye
00078                         colorT.DrawRGBBox(rgbimage, static_cast<int>(fo->eyes.xRight-eyeSize), static_cast<int>(fo->eyes.yRight-eyeSize), 
00079                                                 static_cast<int>(eyeSize*2), static_cast<int>(eyeSize*2), color, alpha);
00080                         firstface = false;
00081                 }
00082         }
00083 
00084 
00085 }; // FilterInterface
00086 
00087 #endif __FILTERINTERFACE_H__

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