Changeset 91 for foam/trunk/vision
 Timestamp:
 07/23/2009 09:42:50 AM (11 years ago)
 Location:
 foam/trunk/vision
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

foam/trunk/vision/Makefile
r90 r91 1 TARGET := test1 TARGET := libvision.a 2 2 3 SRCS := src/main.cpp\ 4 src/Image.cpp\ 3 SRCS := src/Image.cpp\ 5 4 src/Rendering.cpp\ 6 5 src/Classifier.cpp\ … … 14 13 15 14 CCFLAGS = `pkgconfig cflags opencv` ggdb Wall O3 ffastmath Wnounused DTIXML_USE_STL 16 LDFLAGS =17 LIBS = `pkgconfig libs opencv` lYARP_dev lYARP_sig lYARP_OS lACE18 15 19 16 CC = g++ … … 30 27 31 28 ${TARGET}: ${OBJS} 32 ${CC} ${LDFLAGS} o $@ $^ ${LIBS}29 ar rc ${TARGET} ${OBJS} 33 30 34 31 ${OBJS}: %.o: %.cpp %.dep 
foam/trunk/vision/src/Vector.h
r90 r91 58 58 bool IsInf(); 59 59 T Mean(); 60 T DistanceFrom(const Vector &other) const; 61 T Magnitude() const; 60 62 61 63 Vector &operator=(const Vector &other); … … 158 160 159 161 template<class T> 162 T Vector<T>::DistanceFrom(const Vector &other) const 163 { 164 assert(m_Size==other.m_Size); 165 166 float acc=0; 167 for (unsigned int i=0; i<m_Size; i++) 168 { 169 acc+=(other[i](*this)[i]) * (other[i](*this)[i]); 170 } 171 172 return sqrt(acc); 173 } 174 175 template<class T> 176 T Vector<T>::Magnitude() const 177 { 178 float acc=0; 179 for (unsigned int i=0; i<m_Size; i++) 180 { 181 acc+=(*this)[i] * (*this)[i]; 182 } 183 184 return sqrt(acc); 185 } 186 187 template<class T> 160 188 Vector<T> Vector<T>::operator+(const Vector &other) const 161 189 { … … 329 357 Vector<T> om(m); 330 358 assert(om[5]==0.5); 359 360 assert(feq(m.Magnitude(),0.5f)); 361 Vector<T> a(10); 362 a.Zero(); 363 a[5]=10; 364 assert(feq(a.DistanceFrom(m),10.5f)); 331 365 } 332 366 
foam/trunk/vision/src/main.cpp
r90 r91 33 33 double scale = 1; 34 34 35 //int w=50;36 //int h=80;37 int w=20;38 int h=30;35 int w=50; 36 int h=80; 37 //int w=20; 38 //int h=30; 39 39 40 40 PCA pca(w*h); 41 Vector<float> params( 50);41 Vector<float> params(100); 42 42 Image src("data/dave.png"); 43 43 … … 65 65 { 66 66 //Recalc(); 67 //FILE *f=fopen("spacek 20x30.pca", "wb");67 //FILE *f=fopen("spacek50x80.pca", "wb"); 68 68 //pca.Save(f); 69 69 70 FILE *f=fopen("spacek 20x30.pca", "rb");70 FILE *f=fopen("spacek50x80.pca", "rb"); 71 71 pca.Load(f); 72 73 72 fclose(f); 74 73 75 pca.Compress(0, 50);74 pca.Compress(0,100); 76 75 src = src.Scale(w,h).RGB2GRAY(); 77 76 Vector<float> d(src.ToFloatVector()); … … 298 297 //} 299 298 300 for (unsigned int i=0; i<pca.GetEigenTransform().GetRows(); i++) 301 { 302 camera.Blit(Image(w,h,1,pca.GetEigenTransform().GetRowVector(i)*2+pca.GetMean()),(i%20)*(w+2),0+(i/20)*(h+2)); 303 } 304 305 camera.Blit(Image(w,h,1,pca.Synth(params)),200,200); 306 camera.Blit(src,100,200); 299 static float t=0; 300 301 for (unsigned int i=0; i<30; i++) 302 { 303 camera.Blit(Image(w,h,1,(pca.GetEigenTransform().GetRowVector(i)*50)/((i+1) * 1)+pca.GetMean() 304 ),(i%10)*(w+2),0+(i/10)*(h+2)); 305 } 306 307 t+=0.1; 308 309 camera.Blit(Image(w,h,1,pca.GetMean()),0,300); 310 camera.Blit(src,60,300); 311 camera.Blit(Image(w,h,1,pca.Synth(params)),120,300); 307 312 308 313 cvShowImage("result", camera.m_Image);
Note: See TracChangeset
for help on using the changeset viewer.