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

mpisearch/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 "mpisearchFaceDetector.h"
00006 #include "Images/color.h"
00007 
00008 class FilterInterface
00009 {
00010 public:
00011 
00012         FilterInterface();    // Constructor
00013         ~FilterInterface();     // Destructor
00014 
00015         int runInterface(BYTE *pData, int imgWidth, int imgHeight);
00016         void printFrame(RGBTRIPLE *prgb, int cxImage, int cyImage);
00017 
00018 private:
00019 
00020 //      MPISearchBinary m_Detector;
00021         MPISearchFaceDetector m_Detector;
00022 
00023         FaceBoxList m_faces;
00024         FaceBoxList m_lastFace;
00025         RImage<float> m_pixels;
00026         MPColorTools colorT;
00027         int m_failedCycles;
00028         bool m_failedSearch;
00029 
00030 // ================================================================
00031 
00032         inline void GreyScaleFlipVideo(int width, int height, RGBTRIPLE *rgbpix, RImage<float> & pixels)
00033         {
00034                 RGBTRIPLE *source;
00035                 unsigned char *sp;
00036                 float *dest;
00037 
00038                 // convert image to grayscale and out of directshow coordinates 
00039                 for (int y=0; y < height; y++) {
00040                         source = rgbpix + width * ((height-1) - y);
00041                         sp = (unsigned char *) source;
00042                         dest = pixels.array + width*y;
00043                         for (int x = 0; x < width; x++) {
00044                                 *dest++ = (float)(sp[2] + sp[1]*6 + sp[0]*3);
00045                                 sp += 3;
00046                         }
00047                 }
00048 
00049         } 
00050 
00051 // ================================================================
00052 
00053         inline void DrawBoxes(RGBTRIPLE *prgb, int cxImage, int cyImage)
00054         {  
00055                 bool firstface = true;
00056                 RGBCOLOR color;
00057                 double alpha;
00058                 FFImage<RGBTRIPLE> rgbimage(prgb, cxImage, cyImage);
00059 
00060                 if(m_failedSearch) alpha = exp(-m_failedCycles*0.25);
00061                 else alpha = 1;
00062                 list<Square>::iterator face = m_lastFace.begin();
00063                 list<Square>::iterator last_face = m_lastFace.end();
00064                 for ( ; face != last_face; ++face) {
00065                         //print face box
00066                         if(firstface) color = RGBRED;
00067                         else color = RGBBLUE;
00068                         Square fa = (*face);
00069                         colorT.DrawRGBBox(rgbimage, fa.x, fa.y, fa.size, fa.size, color, alpha);
00070 
00071                         firstface = false;
00072                 }
00073         }
00074 
00075 
00076 }; // FilterInterface
00077 
00078 #endif __FILTERINTERFACE_H__

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