Пример #1
0
void mouseHandler(int event, int x, int y, int flags, void *param) {

    switch (event) {
        case CV_EVENT_LBUTTONDOWN:
            initPoint = cvRect(cvRound(multiCamera.GetFrameWidth() / 2 - 10), cvRound(multiCamera.GetFrameHeight() / 2 - 10), 20, 20);
            if (x > initPoint.x && x < initPoint.x + initPoint.width && y > initPoint.y && y < initPoint.y + initPoint.height) {
                javaStartInterface.SetStart(true);
            }
            break;
        case CV_EVENT_RBUTTONDOWN:
            trackerDetector.lostTracking();
            javaStartInterface.SetStart(false);
            break;
    }

}
Пример #2
0
 void evalTransform(mtOutput& output, const mtInput& input) const{
   input.updateMultiCameraExtrinsics(mpMultiCamera_);
   mpMultiCamera_->transformFeature(outputCamID_,input.CfP(ID_),input.dep(ID_),output.c(),output.d());
   if(input.CfP(ID_).trackWarping_ && input.CfP(ID_).com_warp_nor()){
     const int& camID = input.CfP(ID_).camID_;
     const QPD qDC = input.qCM(outputCamID_)*input.qCM(camID).inverted(); // TODO: avoid double computation
     const V3D CrCD = input.qCM(camID).rotate(V3D(input.MrMC(outputCamID_)-input.MrMC(camID)));
     const V3D CrCP = input.dep(ID_).getDistance()*input.CfP(ID_).get_nor().getVec();
     const V3D DrDP = qDC.rotate(V3D(CrCP-CrCD));
     const double d_out = DrDP.norm();
     const LWF::NormalVectorElement nor_out(DrDP);
     const Eigen::Matrix<double,2,3> J_nor_DrDP = nor_out.getM().transpose()/d_out;
     const Eigen::Matrix<double,3,3> J_DrDP_CrCP = MPD(qDC).matrix();
     const Eigen::Matrix<double,3,2> J_CrCP_nor = input.dep(ID_).getDistance()*input.CfP(ID_).get_nor().getM();
     output.c().set_warp_nor(J_nor_DrDP*J_DrDP_CrCP*J_CrCP_nor*input.CfP(ID_).get_warp_nor());
   }
 }
Пример #3
0
 void evalTransform(mtOutput& output, const mtInput& input) const{
   input.updateMultiCameraExtrinsics(mpMultiCamera_);
   mpMultiCamera_->transformFeature(outputCamID_,input.CfP(ID_),input.dep(ID_),output.c(),output.d());
 }
Пример #4
0
void mainWrapper() {
    (void) ftime(&tbi);
    (void) ftime(&tbf);

    // ESSE � O MILAGRE
    timestamp = ctime(&tbi.time);

    printf("%.19s.%hu %s", timestamp, tbi.millitm, &timestamp[20]);

    multiCamera.setup(javaStartInterface.GetIndexCAM());
    cvNamedWindow(winName, CV_WINDOW_AUTOSIZE);
    cvSetMouseCallback(winName, mouseHandler, NULL);
    ofp = fopen("log.txt", "w");
    fprintf(ofp, "timestamp\tfps\tLeftGazeX\tLeftGazeY\tRightGazeX\tRightGazeY\tLeftBlink\tRightBlink\t\n");
    int freio = 0;
    for (;;) {

        nFrames++;
        double t = (double) cvGetTickCount();

        if (multiCamera.queryFrame() == 0)
            continue;


        CvPoint startPoint = cvPoint(cvRound(multiCamera.GetFrameWidth() / 2), cvRound(multiCamera.GetFrameHeight() / 2));

        if (javaStartInterface.IsStart()) {
            //double t = (double)cvGetTickCount();
            trackerDetector.execute(multiCamera.GetFrame());
            //t = (double)cvGetTickCount() - t;
            //printf( "%g\n",  t/((double)cvGetTickFrequency()*1000.) );
            //printf( "%d\n", FaceHeuristics::GazeLeftX );
            cvCircle(multiCamera.GetFrame(), startPoint, 10, CV_RGB(255, 255, 255), 0);
            fprintf(ofp, "%g\t%g\t%d\t%d\t%d\t%d\t%d\t%d\t\n", t / ((double) cvGetTickFrequency()*1000.), getFPS(), getLeftGazeX(), getLeftGazeY(), getRightGazeX(), getRightGazeY(), getLeftBlink(), getRightBlink());
        } else {
            cvCircle(multiCamera.GetFrame(), startPoint, 10, CV_RGB(255, 255, 255), -1);

        }
        if ((cvWaitKey(10) & 255) == 27)
            freio = 1; //break;  //Test for Escape-key press 
        if (javaStartInterface.IsStop())
            freio = 1; //break; 

        if (javaStartInterface.GetScreenWidth() > 0)
            cvMoveWindow(winName, cvRound(javaStartInterface.GetScreenWidth() / 2 - multiCamera.GetFrameWidth() / 2), cvRound(javaStartInterface.GetScreenHeight() / 2 - multiCamera.GetFrameHeight() / 2));

        //cvSmooth( multiCamera.GetFrame()  , BiFrame , CV_BILATERAL, 5, 5, sigma, sigma);
        cvShowImage(winName, multiCamera.GetFrame());

        t = (double) cvGetTickCount() - t;
        loopTime = t / ((double) cvGetTickFrequency()*1000.);
        somaLoopTime += loopTime;
        if (somaLoopTime > 1000) {
            fps = nFrames;
            //printf( "%g\n", getFPS() );
            nFrames = 0;
            somaLoopTime = 0;
        }

        if (freio) {
            //break;
        }
    }

    fclose(ofp);
    cvDestroyWindow(winName);
    exit(0);
}