nuiWidget* MainWindow::Tutorial_Buttons() { NGL_OUT("MainWindow::Tutorial_Buttons"); nuiHBox* pBox = new nuiHBox(0); //pBox->EnableSurface(true); // a simple button nuiButton* pBtn = new nuiButton(_T("button")); pBtn->SetObjectName(_T("MyButton")); mEventSink.Connect(pBtn->Activated, &MainWindow::OnButtonPressed, (void*)TAG_BUTTON1); pBox->AddCell(pBtn, nuiCenter); // a simple button filling the box's cell pBtn = new nuiButton(_T("button")); pBtn->SetObjectName(_T("MyButton")); pBox->AddCell(pBtn, nuiFill); mEventSink.Connect(pBtn->Activated, &MainWindow::OnButtonPressed, (void*)TAG_BUTTON2); // a button with an image nglImage pImg(_T("rsrc:/decorations/button1.png")); pBtn = new nuiButton(pImg); pBtn->SetObjectName(_T("MyButton")); pBox->AddCell(pBtn); mEventSink.Connect(pBtn->Activated, &MainWindow::OnButtonPressed, (void*)TAG_BUTTON3); // a roll-over button using decorations nuiGradientDecoration* pDecoUp = new nuiGradientDecoration(_T("DecoUp"), nuiColor(192,192,192), nuiColor(128,128,128), 1, nuiColor(0,0,0), eStrokeAndFillShape); nuiColorDecoration* pDecoUpHover = new nuiColorDecoration(_T("DecoUpHover"), nuiColor(255,0,0,128), 1, nuiColor(0,0,0)); nuiFrame* pFrame = new nuiFrame(_T("DecoDown"), _T("rsrc:/decorations/button1.png"), nuiRect(0,0,57,54)); // create a nuiStateDecoration using the three previous decorations for the rollover's three states : up, hover and done nuiStateDecoration* pStateDeco = new nuiStateDecoration(_T("Deco"), _T("DecoUp"), _T("DecoDown"), _T("DecoUpHover")); pBtn = new nuiButton(pStateDeco); pBtn->SetObjectName(_T("MyButton")); pBtn->SetUserSize(40,40); pBox->AddCell(pBtn, nuiCenter); mEventSink.Connect(pBtn->Activated, &MainWindow::OnButtonPressed, (void*)TAG_BUTTON4); NGL_OUT("MainWindow::Tutorial_Buttons ok"); return pBox; }
//This is basically the method the class was created for. It scans the image in order to find the biggest face, processes it and fills up this object attributes with the corresponding values of rlip,llip, leb, rleb, etc. //It will return the final value of the faceFound atribute. bool Face::extractCharacteristicPoints () { Mat& pImg = this->processedImg; //Alias for easyness. vector<Rect> faces; vector<Rect>::const_iterator r; Mat mouthImg, noseImg, eyeRegionImg ; Rect mr, er, nr; Point p1, p2; Rect box; Mat imToFill; //Initializing if required. if (!this->initialized) this->init(); // Starting Face Detection cascade.detectMultiScale( pImg, faces, 1.1, 2, 0 |CV_HAAR_FIND_BIGGEST_OBJECT //DETECT THE BIGGEST FACE. Only one. //|CV_HAAR_DO_ROUGH_SEARCH |CV_HAAR_SCALE_IMAGE , Size(30, 30) ); //End of detection // If a face was detected .. r = faces.begin(); if (r != faces.end()) { //Setting Face Atributes this->location.x = r->x; this->location.y = r->y; this->size.width = r->width; this->size.height= r->height; //Starting Face Points Extraction //MOUTH //A gente so vai procurar parte baixa da face. mr.x = r->x + (r->width*0.20) ; mr.y = r->y + (r->height*0.5); mr.width = r->width * 0.6 ; mr.height = r->height * 0.5; // Now we crop the mouth and extract its feature points. mouthImg = pImg(mr); extractMouthPoints (mouthImg, llip, rlip, ulip, dlip); //NOSE nr.x = r->x + (r->width*0.3) ; nr.y = r->y + (r->height*0.50); nr.width = r->width * 0.4 ; nr.height = std::min((ulip.y + mr.y) - nr.y + 1, int(r->height * 0.20)); noseImg = pImg(nr); extractNostrils (noseImg, lnstrl, rnstrl); rnstrl += nr.tl(); lnstrl += nr.tl(); //EYES and EYEBROWS er.x = r->x + (r->width*0.1) ; er.y = r->y + (r->height*0.1); er.width = r->width * 0.8 ; er.height = std::min((nr.y - er.y + 1), int(r->height * 0.5)); eyeRegionImg = pImg(er); extractEyebrows(eyeRegionImg, !(this->bluringEnabled), leb, reb, cleye, creye, lefcps, refcps); //Relocating coordinates to the original image (rotated, rescaled) for (int i = 0; i< 4; i++){ leb[i] += er.tl(); reb[i] += er.tl(); } for (int i = 0; i< 5; i++){ lefcps[i] += er.tl(); refcps[i] += er.tl(); } llip += mr.tl(); rlip += mr.tl(); ulip += mr.tl(); dlip += mr.tl(); //Inverting Rotation if required. if (this->rotationAngle != 0 ) { transformPoint(llip , llip , irMat); transformPoint(rlip , rlip , irMat); transformPoint(ulip , ulip , irMat); transformPoint(dlip , dlip , irMat); transformPoint(lnstrl, lnstrl, irMat); transformPoint(rnstrl, rnstrl, irMat); for (int i = 0; i< 5; i++){ if (i<4){ transformPoint(leb[i], leb[i], irMat); transformPoint(reb[i], reb[i], irMat); } transformPoint(lefcps[i], lefcps[i], irMat); transformPoint(refcps[i], refcps[i], irMat); } transformPoint(this->location, this->location, irMat); //this->tilt = this->rotationAngle + rollInc; //This is wrong. Shouldn be computed here. "rollInc should be computed after theses transformation to give the real tilt. //cout << "Global Tilt Angle eyes aprox: " << (roll) << " deg. centered on left eye." << endl; } //else // this->tilt = rollInc; //Not necessary .. wrong too. //Computing global face tilt angle using eyes'axis. Left eye considered the center. double angle = double((cleye.y - creye.y)) / double(std::max((creye.x - cleye.x),1)); angle = std::atan(angle) == NAN ? 90.0 : std::atan(angle) * (180.0/ M_PI); this->tilt = angle == NAN ? 0 : angle; //cout << "Local Tilt Angle eyes aprox: " << (*froll) << " deg. centered on left eye." << endl; return (this->faceFound = true); } else return (this->faceFound=false); }