/// <summary> /// detect facial features using the given image and face coordinates /// </summary> /// <param name="img">image object containing the face</param> /// <param name="face_tx">The top left x coordinate of the detected face within the image object</param> /// <param name="face_ty">The top left y coordinate of the detected face within the image object</param> /// <param name="face_bx">The bottom right x coordinate of the detected face within the image object</param> /// <param name="face_by">The bottom right y coordinate of the detected face within the image object</param> void classHumunculus::analyseFace(classimage *img, int face_tx, int face_ty, int face_bx, int face_by) { int x,y,c,xx,yy,w,h; int lateral_symetry,lefteye_x,righteye_x,lefteye_y,righteye_y,mouth_y,mouth_width; //dimensions of the face within the original image w = face_bx - face_tx; h = face_by - face_ty; //dump the face region into a separate image of fixed dimensions for (x=0;x<FACE_IMAGE_SIZE;x++) { xx = face_tx + ((x * w)/ FACE_IMAGE_SIZE); for (y=0;y<FACE_IMAGE_SIZE;y++) { yy = face_ty + ((y * h) / FACE_IMAGE_SIZE); for (c=0;c<3;c++) face->image[x][y][c] = img->image[xx][yy][c]; } } //face->updateIntegralImage(); //detect the positions of features within the face image detectFeatures(lateral_symetry, lefteye_x, righteye_x, lefteye_y, righteye_y, mouth_y, mouth_width); detectKeypoints(lateral_symetry, lefteye_x, righteye_x, lefteye_y, righteye_y, mouth_y, mouth_width); }
InitResult KltHomographyInit::addFirstFrame(FramePtr frame_ref) { reset(); detectFeatures(frame_ref, px_ref_, f_ref_); if(px_ref_.size() < 100) { SVO_WARN_STREAM_THROTTLE(2.0, "First image has less than 100 features. Retry in more textured environment."); return FAILURE; } frame_ref_ = frame_ref; px_cur_.insert(px_cur_.begin(), px_ref_.begin(), px_ref_.end()); return SUCCESS; }
InitResult KltHomographyInit::addFirstFrame(FramePtr frame_ref, Matrix3d orient, Vector3d pos) { reset(); detectFeatures(frame_ref, px_ref_, f_ref_); if(px_ref_.size() < 100) { SVO_WARN_STREAM_THROTTLE(2.0, "First image has less than 100 features. Retry in more textured environment."); return FAILURE; } frame_ref_ = frame_ref; px_cur_.insert(px_cur_.begin(), px_ref_.begin(), px_ref_.end()); T_first_frame_real_scale = SE3(orient, pos); frame_ref_->T_f_w_ = T_first_frame_real_scale; return SUCCESS; }
// 确保添加的第一帧检测到的特征点数大于100 InitResult Initialization::addFirstFrame(FramePtr frame_ref) { reset(); detectFeatures(frame_ref, px_ref_, f_ref_); if (px_ref_.size() < 100) { std::cerr << "First image has less than 100 features. Retry in more textured environment." << std::endl; return FAILURE; } int detect_features_num = px_ref_.size(); // 将这一帧图像做为参考帧 frame_ref_ = frame_ref; // 先设置当前帧的特征与参考帧的特征一致 px_cur_.insert(px_cur_.begin(), px_ref_.begin(), px_ref_.end()); return SUCCESS; }
void DetailedFaceDetector::processFrame() { cv::Mat frame = getMostRecentFrame(); if(frame.empty()) return; detectFaces(frame); //only detect features if the FaceDetector has updates! if(hasUpdates) { //only detect other features if the face detector had updates if(detectWhat > 0) detectFeatures(frame); //since this object disables autoNotify, do it manually now! //this is to avoid double updates to the controllers and //only update when necessary notifyControllers(); } }