Exemplo n.º 1
0
/*****************************************************************************
 * Retreive next frame, find the target and display
 *****************************************************************************/
void MainWindow::getNextFrame()
{
    mCurrentFrames = vids.nextframe();

    for (int i = 0; i < 4; i++)
    {
        cv::Mat img;
        mCurrentFrames[i].copyTo(img);
        bool out = mpMST[i]->findTarget(img, mCandidateRect[i]);
        qDebug() << "next frame of " << i << " is " << out;
        picture[i]->setPixmap(fromMat(mCurrentFrames[i]));
    }
    ui->gphPic1->setTrackingRect(mCandidateRect[0]);
    ui->gphPic2->setTrackingRect(mCandidateRect[1]);
    ui->gphPic3->setTrackingRect(mCandidateRect[2]);
    ui->gphPic4->setTrackingRect(mCandidateRect[3]);

    for(int i=0;i<4;i++)
    {
        int x_pos = 0;
        int y_pos = 0;
        x_pos = mCandidateRect[i].x + mCandidateRect[i].width/2;
        y_pos = mCandidateRect[i].y + mCandidateRect[i].height/2;

        qDebug() << " Writing " << x_pos << " " << y_pos << " To " << i;

        (*mpTextStream[i]) << x_pos << " " << y_pos << "\n";
        mpTextStream[i]->flush();
    }
}
Exemplo n.º 2
0
	ofMatrix4x4 estimateAffine3D(vector<ofVec3f>& from, vector<ofVec3f>& to, vector<unsigned char>& outliers, float accuracy) {
		Mat fromMat(1, from.size(), CV_32FC3, &from[0]);
		Mat toMat(1, to.size(), CV_32FC3, &to[0]);
		Mat affine;
		estimateAffine3D(fromMat, toMat, affine, outliers, 3, accuracy);
		ofMatrix4x4 affine4x4;
		affine4x4.set(affine.ptr<double>());
		affine4x4(3, 0) = 0;
		affine4x4(3, 1) = 0;
		affine4x4(3, 2) = 0;
		affine4x4(3, 3) = 1;
		Mat affine4x4Mat(4, 4, CV_32F, affine4x4.getPtr());
		affine4x4Mat = affine4x4Mat.t();
		affine4x4.set(affine4x4Mat.ptr<float>());
		return affine4x4;
	} 
Exemplo n.º 3
0
/*****************************************************************************
 * Load a file (JSON format that describes each video as well as the starting
 * frame to sync the videos up).
 *****************************************************************************/
void MainWindow::on_cmdLoad_clicked()
{
    QFileDialog diagfile;
    QString file = diagfile.getOpenFileName();
    if (file == "")
        return;

    vids.readFile(file);

    qDebug() << "Reading first frame";
    mReferenceFrames = vids.firstframe();

    qDebug() << "Frames size: " << mReferenceFrames.size();
    qDebug() << "Frames type: " << mReferenceFrames[0].type();

    for (int i = 0; i < 4; i++)
    {
        picture[i]->setPixmap(fromMat(mReferenceFrames[i]));
    }
    mMainWindowStatus = NORMAL;
    resize();

}