//眨眼计时器超时的slot函数 void BlinkAnalyser::timeout(){ timeoutTimer->stop(); QObject::disconnect(webcamCapture,SIGNAL(newImageCaptured(cv::Mat)),this,SLOT(receiveNewFrame(cv::Mat))); //解绑接收摄像头事件 //cv::destroyAllWindows(); emit this->done(false); std::cout << "BlinkAnalyser Time out!"<<std::endl; }
//开启检测眨眼线程 void BlinkAnalyser::start(){ QSound::play("/home/netbeen/QtWorkspace/LivenessDetection3/请眨眼.wav"); timeoutTimer = new QTimer(); QObject::connect(timeoutTimer,SIGNAL(timeout()),this,SLOT(timeout())); std::cout << "BlinkAnalyser at " << QThread::currentThreadId()<< std::endl; QObject::connect(webcamCapture,SIGNAL(newImageCaptured(cv::Mat)),this,SLOT(receiveNewFrame(cv::Mat))); timeoutTimer->start(timeoutTimeMs); }
void OpenMouthAnalyser::success(){ timeoutTimer->stop(); QObject::disconnect(webcamCapture,SIGNAL(newImageCaptured(cv::Mat)),this,SLOT(receiveNewFrame(cv::Mat))); //解绑接收摄像头事件 cv::destroyAllWindows(); std::cout << "OpenMouthAnalyser success!"<<std::endl; emit this->done(true); }
void OpenMouthAnalyser::start(){ timeoutTimer = new QTimer(); QObject::connect(timeoutTimer,SIGNAL(timeout()),this,SLOT(timeout())); //绑定计时器事件 std::cout << "OpenMouthAnalyser at " << QThread::currentThreadId()<< std::endl; QObject::connect(webcamCapture,SIGNAL(newImageCaptured(cv::Mat)),this,SLOT(receiveNewFrame(cv::Mat))); timeoutTimer->start(timeoutTimeMs); }
//启动入口函数 void YawAnalyser::start(){ std::cout << "YawAnalyser at " << QThread::currentThreadId()<< std::endl; QObject::connect(webcamCapture,SIGNAL(newImageCaptured(cv::Mat)),this,SLOT(receiveNewFrame(cv::Mat))); //绑定接收摄像头事件 isProgressTimeout=false; this->progressTimer = new QTimer(); QObject::connect(this->progressTimer,SIGNAL(timeout()),this,SLOT(progressTimeout())); //绑定计时器事件 this->updateSliderTimer = new QTimer(); QObject::connect(this->updateSliderTimer,SIGNAL(timeout()),this,SLOT(updateSliderTimeout())); this->progressTimer->start(totalProgressTimeMS); this->updateSliderTimer->start(totalProgressTimeMS/1000); }
//摇头测试结束,开始计算结果 void YawAnalyser::finish(){ this->progressTimer->stop(); this->updateSliderTimer->stop(); QObject::disconnect(webcamCapture,SIGNAL(newImageCaptured(cv::Mat)),this,SLOT(receiveNewFrame(cv::Mat))); //解绑接收摄像头事件 QObject::disconnect(this,SIGNAL(doCalcOpticalFlow(cv::Mat)),this->opticalFlowCalculater,SLOT(doCalc(cv::Mat))); //解绑光流计算事件 QObject::disconnect(opticalFlowCalculater,SIGNAL(calcCompete(bool,cv::Mat)),this,SLOT(receiveNewOpticalFlow(bool,cv::Mat))); //解绑接受光流事件 //cv::destroyAllWindows(); std::cout << "YawAnalyser Time out!"<<std::endl; ///////////////////// std::cout << "捕获到光流总帧数:" <<this->leftBackgroundNormalVector.size() <<std::endl; std::cout << "左模" << Utils::calculatePearsonCorrelation(this->faceNormalVector,this->leftBackgroundNormalVector) <<std::endl; std::cout << "右模"<< Utils::calculatePearsonCorrelation(this->faceNormalVector,this->rightBackgroundNormalVector) <<std::endl; std::cout << "左相位"<< Utils::calculatePearsonCorrelation(this->facePhaseVector,this->leftBackgroundPhaseVector) <<std::endl; std::cout << "右相位"<< Utils::calculatePearsonCorrelation(this->facePhaseVector,this->rightBackgroundPhaseVector) <<std::endl; emit this->done(true); }