Changeset 72
- Timestamp:
- 04/22/2009 10:58:40 AM (11 years ago)
- Location:
- foam/trunk
- Files:
-
- 6 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
foam/trunk/simple-faceident/README
r62 r72 53 53 * Expose image size and error threshold via yarp 54 54 * Use tinyxml or something better for the serialisation 55 * Lighting is a problem 56 - Ignore the problem 57 - Try the edge image trick 58 - LBP 55 59 56 60 Questions to: -
foam/trunk/simple-faceident/src/ImageUtils.cpp
r64 r72 117 117 return ret; 118 118 } 119 120 121 122 ///////////////////////////////////////////////////////////// 123 // return a local binary patterns image of the src image 124 125 unsigned char SafeGet2D(IplImage *image, int y, int x, int c) 126 { 127 CvSize size = cvGetSize(image); 128 if (x<0 || x>=size.width || y<0 || y>=size.height) 129 { 130 return 0; 131 } 132 133 return cvGet2D(image,y,x).val[c]; 134 } 135 136 void LBPImage(IplImage *srcimage, IplImage *dstimage) 137 { 138 CvSize srcsize = cvGetSize(srcimage); 139 CvSize dstsize = cvGetSize(dstimage); 140 141 assert(srcsize.width == dstsize.width); 142 assert(srcsize.height == dstsize.height); 143 assert(srcimage->nChannels == dstimage->nChannels); 144 145 for(int y=0; y<srcsize.height; y++) 146 { 147 for(int x=0; x<srcsize.width; x++) 148 { 149 CvScalar sc; 150 151 for(int c=0; c<dstimage->nChannels; c++) 152 { 153 unsigned char v=0; 154 unsigned char o=cvGet2D(srcimage,y,x).val[c]; 155 unsigned char b=0; 156 for (int kx=-1; kx<=1; kx++) 157 { 158 for (int ky=-1; ky<=1; ky++) 159 { 160 // don't compare with ourself 161 if (!(kx==0 && ky==0)) 162 { 163 if (o>SafeGet2D(srcimage,y+ky,x+kx,c)) 164 { 165 v&=1<<b; 166 } 167 b++; 168 } 169 } 170 } 171 sc.val[c]=v; 172 } 173 cvSet2D(dstimage,y,x,sc); 174 } 175 } 176 } -
foam/trunk/simple-faceident/src/ImageUtils.h
r14 r72 26 26 void SubMean(IplImage *image); 27 27 float Diff(IplImage *imagea, IplImage *imageb); 28 void LBPImage(IplImage *srcimage, IplImage *dstimage); 28 29 29 30 #endif
Note: See TracChangeset
for help on using the changeset viewer.