void testVectors(){ vector<double> test1(10,8.0); vector<double> abc(10,7.); vector<double> res(10); cout<<"vecadd test1+abc "<<endl; vectorAdd(&test1,&abc,&res); vectorPrint(&res); cout<<"vecsub res-abc "<<endl; vectorSub(&res,&abc,&res); vectorPrint(&res); cout<<"vecscalar 3 "<<endl; vectorScalar(&res,3.); vectorPrint(&res); cout<<"vecscalar 3 "<<endl; vectorScalar(&res,3.,&test1); vectorPrint(&test1); cout<<"vecvec test1 abc "<<endl; cout<<vectorVector(&test1,&abc)<<endl; vector<map< int,double> > testmat(2);//=new vector<map< int,double> >(n); for (int i=0;i<2;++i){ testmat[i];//=new map< int,double> (); } testmat[0][0]= 1; testmat[0][1]= 1; testmat[1][0]= 1; //testmat[1][1]= 1; vector<double> vec(2,8.0); vector<double> ret(2); matrixVector(&testmat,&vec,&ret); vectorPrint(&ret); }
static int Quat(lua_State *L) /* creates a quaternion from another quaternion, a scalar and a vec3, a matrix, * or a list of scalars. * the size is adapted by discarding exceeding values or adding zeros in lieu * of missing values. * quat(q) * quat([w [, x [, y [, z]]]) * quat(s, v) * quat(mat) */ { quat_t q; vec_t v; size_t vsize, i, arg; if(testquat(L, 1, q)) return pushquat(L, q); if(testvec(L, 2, v, &vsize, NULL)) { #if 0 if(vsize != 3) return luaL_argerror(L, 2, "size 3 vector expected"); #endif q[0] = luaL_checknumber(L, 1); q[1] = v[0]; q[2] = v[1]; q[3] = v[2]; return pushquat(L, q); } if(testmat(L, 1, NULL, NULL, NULL)) return quat_FromMat(L); arg = 1; for(i = 0; i < 4; i++) q[i] = luaL_optnumber(L, arg++, 0); return pushquat(L, q); }
//main function int main() { //declare variables for image IplImage * input1; IplImage * output1; char nameim[100]="../project/dbase/males/1/mvc-001f.jpg"; CvSize s1= {48,48}; output1=cvCreateImage(s1,IPL_DEPTH_8U,3); CvSVM SVM; float a; SVM.load("../project/temp/SVM_hap_neu_sad.txt"); FILE *fp; float feat[18432]; char str[50]="./gabor ../project/temp/temp1.jpg "; IplImage * happy; IplImage * sad; IplImage * neutral; IplImage * temp; CvSize s2= {400,400}; happy=cvCreateImage(s2,IPL_DEPTH_8U,3); sad=cvCreateImage(s2,IPL_DEPTH_8U,3); neutral=cvCreateImage(s2,IPL_DEPTH_8U,3); temp = cvLoadImage("../project/data/Images/happy.jpeg", CV_LOAD_IMAGE_UNCHANGED); cvResize(temp,happy); temp = cvLoadImage("../project/data/Images/sad.jpeg", CV_LOAD_IMAGE_UNCHANGED); cvResize(temp,sad); temp = cvLoadImage("../project/data/Images/neutral.jpeg", CV_LOAD_IMAGE_UNCHANGED); cvResize(temp,neutral); CvCapture *capture=cvCreateCameraCapture(0); if(capture!=NULL) //camera has begun starting itself for(;;) { input1=cvQueryFrame(capture);//take current image in camera and give it to input pointer //get input from camera (input) //input1 = cvLoadImage(nameim, CV_LOAD_IMAGE_UNCHANGED); face_detect_crop(input1,output1); cvSaveImage("../project/temp/temp1.jpg",output1); //_______________________________________________________________// fp=popen(str,"r"); for(int i=0; i<18432; i++) { fscanf(fp,"%f",&feat[i]); //std::cout<<feat[i]<<" "; } pclose(fp); //_______________________________________________________________// cvNamedWindow("Emotion", 1); cv::Mat testmat(1, 18432, CV_32FC1, feat); a=SVM.predict(testmat); if( a<1.1 && a>0.9) { std::cout<<"happy\n"; cvShowImage("Emotion",happy); if( cv::waitKey( 10 ) >= 0 )break; } else if(a>-1.1 && a<-0.9) { std::cout<<"sad\n"; cvShowImage("Emotion",sad); if( cv::waitKey( 10 ) >= 0 )break; } else { std::cout<<"neutral\n"; cvShowImage("Emotion",neutral); if( cv::waitKey( 10 ) >= 0 )break; } cvNamedWindow("O-O", 1); cvShowImage("O-O",input1); if( cv::waitKey( 10 ) >= 0 )break; } cvReleaseCapture( &capture ); return 0; }