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/helperfunctions.h

Go to the documentation of this file.
00001 #include <windows.h>
00002 //#include "mpisearchBinary.h"
00003 #include "mpisearchFaceDetector.h"
00004 
00005 // ================================================================
00006 
00007 inline void GreyScaleFlipVideo(int width, int height, int np, RGBTRIPLE *rgbpix, RImage<float> & pixels)
00008 {
00009         RGBTRIPLE *source;
00010         unsigned char *sp;
00011         float *dest;
00012 
00013         // convert image to grayscale and out of directshow coordinates 
00014         for (int y=0; y < height; y++) {
00015                 source = rgbpix + (np - (y+1) * width);
00016                 sp = (unsigned char *) source;
00017                 dest = pixels.array + width*y;
00018                 for (int x = 0; x < width; x++) {
00019                         *dest++ = (float)(sp[2] + sp[1]*6 + sp[0]*3);
00020                         sp += 3;
00021                 }
00022         }
00023 
00024 } 
00025 
00026 // ================================================================
00027 
00028 inline void SetRGBRed(int x, int y, int cxImage, int cyImage, int failedCycles, RGBTRIPLE *prgb){
00029         float Decay = (10 - failedCycles)*.1;
00030 #define MPIRedDecay(x)                                          \
00031   (x)->rgbtRed = (unsigned char) floor((255 - (x)->rgbtRed)*Decay + (x)->rgbtRed);              \
00032   (x)->rgbtBlue = (unsigned char) ceil((x)->rgbtBlue - ((x)->rgbtBlue - 0)*Decay);          \
00033   (x)->rgbtGreen = (unsigned char) ceil((x)->rgbtGreen - ((x)->rgbtGreen - 0)*Decay);
00034 
00035         MPIRedDecay( prgb + (x + cxImage*((cyImage-1) - y)));
00036 }
00037 
00039 
00040 inline void SetRGBBlue(int x, int y, int cxImage, int cyImage, int failedCycles, RGBTRIPLE *prgb){
00041         float Decay = (10 - failedCycles)*.1;
00042 #define MPIBlueDecay(x)                                         \
00043   (x)->rgbtRed = (unsigned char) ceil((x)->rgbtRed - ((x)->rgbtRed - 0)*Decay);         \
00044   (x)->rgbtBlue = (unsigned char) floor((255 - (x)->rgbtBlue)*Decay + (x)->rgbtBlue);       \
00045   (x)->rgbtGreen = (unsigned char) ceil((x)->rgbtGreen - ((x)->rgbtGreen - 0)*Decay);
00046 
00047         MPIBlueDecay( prgb + (x + cxImage*((cyImage-1) - y)));
00048 }
00049 
00051 
00052 inline void SetRGBWhite(int x, int y, int cxImage, int cyImage, int failedCycles, RGBTRIPLE *prgb){
00053         float Decay = (10 - failedCycles)*.1;
00054 #define MPIWhiteDecay(x)                                                \
00055   (x)->rgbtRed = (unsigned char) floor((255 - (x)->rgbtRed)*Decay + (x)->rgbtRed);              \
00056   (x)->rgbtBlue = (unsigned char) floor((255 - (x)->rgbtBlue)*Decay + (x)->rgbtBlue);       \
00057   (x)->rgbtGreen = (unsigned char) floor((255 - (x)->rgbtGreen)*Decay + (x)->rgbtGreen);
00058 
00059         MPIWhiteDecay( prgb + (x + cxImage*((cyImage-1) - y)));
00060 }
00061 
00062 // ================================================================
00063 
00064 inline void DrawBoxes(RGBTRIPLE *prgb, FaceBoxList &faces, int failedCycles, int cxImage, int cyImage)
00065 {  
00066         int leftX, rightX, topY, bottomY, x, y;
00067         bool firstface = true;
00068         for (list<Square>::iterator it = faces.begin(); it != faces.end(); it++) {
00069                 Square &curface = *it;
00070                 if (curface.size > 0) {
00071                         leftX = curface.x;
00072                         rightX = leftX + curface.size;
00073                         topY = curface.y;
00074                         bottomY = topY + curface.size - 1;
00075 
00076                         for(x = leftX; x <= rightX; ++x){
00077                                 if (firstface) {
00078                                         SetRGBRed(x, topY, cxImage, cyImage, failedCycles, prgb);
00079                                         SetRGBRed(x, bottomY, cxImage, cyImage, failedCycles, prgb);
00080                                 } else {
00081                                         SetRGBBlue(x, topY, cxImage, cyImage, failedCycles, prgb);
00082                                         SetRGBBlue(x, bottomY, cxImage, cyImage, failedCycles, prgb);
00083                                 }
00084                         }
00085                         for(y = topY; y < bottomY; ++y){
00086                                 if (firstface) {
00087                                         SetRGBRed(leftX, y, cxImage, cyImage, failedCycles, prgb);
00088                                         SetRGBRed(rightX, y, cxImage, cyImage, failedCycles, prgb);
00089                                 } else {
00090                                         SetRGBBlue(leftX, y, cxImage, cyImage, failedCycles, prgb);
00091                                         SetRGBBlue(rightX, y, cxImage, cyImage, failedCycles, prgb);
00092                                 }
00093                         }
00094                         firstface = false;
00095                 }
00096         }
00097 }
00098 

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