Exemplo n.º 1
0
void StereoCalibrationDialog::updateFrame()
{
    captureLeft.grab();
    captureRight.grab();

    captureLeft.retrieve(currentFrameLeft);
    captureRight.retrieve(currentFrameRight);

    if(!currentFrameLeft.empty() && !currentFrameRight.empty())
    {
        cv::Mat frameLeftCopy = currentFrameLeft.clone();
        cv::Mat frameRightCopy = currentFrameRight.clone();

        if(ui->checkBox->isChecked())
        {
            detectChessboard(frameLeftCopy, patternSize);
            detectChessboard(frameRightCopy, patternSize);
        }

        QImage qframeL, qframeR;
        qframeL = MatToQImage(frameLeftCopy);
        qframeR = MatToQImage(frameRightCopy);

        frameLeft = MatToQImage(currentFrameLeft);
        frameRight = MatToQImage(currentFrameRight);

        pixmapLeft = QPixmap::fromImage(qframeL).scaled(currentFrameLeft.cols,
                                                  currentFrameRight.rows, Qt::KeepAspectRatio);

        pixmapRight = QPixmap::fromImage(qframeR).scaled(currentFrameRight.cols,
                                                  currentFrameRight.rows, Qt::KeepAspectRatio);
        ui->leftCameraLabel->setPixmap(pixmapLeft);
        ui->rightCameraLabel->setPixmap(pixmapRight);

    }

}
Exemplo n.º 2
0
    void processImage(cv::Mat& inputImg)
    {
        //init images
        chessbrd_img = inputImg.clone();
        birds_img = inputImg.clone();

        // DETECT Chessboard
        bool patternfound;
        detectChessboard(inputImg, corners, patternfound, PATTERNSIZE);
        if(patternfound)
        {
            cv::drawChessboardCorners(chessbrd_img, PATTERNSIZE, cv::Mat(corners), patternfound);
            calcBirdsEyeTransform(H, corners, PATTERNSIZE, delta_chess0, trgtChessbrdCuboidWidth);
            birdsEyeTransform(chessbrd_img, birds_img, H, TOPVIEW_SIZE);
            postprocessTopview(birds_img, resizeTopviewOutput, carPos, visCarPos);
        }
        else
        {
            // clear projMat
            //H = cv::Mat::zeros(H.rows,H.cols, H.type());
        }



        // ------
        // OUTPUT
        // ------
        cv::imshow(OPENCV_WINDOW_rgb, inputImg);
        cv::imshow(OPENCV_WINDOW_chess, chessbrd_img);
        cv::imshow(OPENCV_WINDOW_bird, birds_img);

        char k;
        k = cv::waitKey(3000);  // wait 3 sec before next image
        //printf("%d\n", k);
        if(k == 10) // save if "Enter" is clicked
        {
            // save images + H + CalibConfig
            cv::imwrite("visLoc_TopviewCalib_BirdsEye.jpg", birds_img);
            cv::imwrite("visLoc_TopviewCalib_ChessboardCalib.jpg", chessbrd_img);            
            writeDoubleMatToFile(H, projMatFilename);
            writeCalibConfigToFile(TOPVIEW_SIZE, carPos, PATTERNSIZE, delta_chess0, delta_chess0ToCam, configFilename);
        }
    }