int main(int argc, const char * argv[])
{
    // Change this calibration to yours:
    CameraCalibration calibration(545.31565719766058f, 545.31565719766058f, 326.0f, 183.5f);
    

    std::cout << "Input image not specified" << std::endl;
    std::cout << "Usage: markerless_ar_demo  [filepath to recorded video or image]" << std::endl;



    if (argc == 1)
    {
        processVideo(calibration, cv::VideoCapture());
    }
    else if (argc == 2)
    {
        std::string input = argv[1];
        cv::Mat testImage = cv::imread(input);
        if (!testImage.empty())
        {
            processSingleImage( calibration, testImage);
        }
        else 
        {
            cv::VideoCapture cap;
            if (cap.open(input))
            {
                processVideo( calibration, cap);
            }
        }
    }
    else
    {
        std::cerr << "Invalid number of arguments passed" << std::endl;
        return 1;
    }

    return 0;
}
Exemple #2
0
int main(int argc, const char * argv[])
{
	// franquy parameters
	float fx = 695.4521167717107;
	float fy = 694.5519610122569;
	float cx = 337.2059936807979;
	float cy = 231.1645822893514;
	
	// tablet parameters
	fx=628.6341119951087;
	fy=628.7519411113429;
	cx=325.3443919995285;
	cy=236.0028199018263;
	
    // Change this calibration to yours:
    //~ CameraCalibration calibration(526.58037684199849f, 524.65577209994706f, 318.41744018680112f, 202.96659047014398f);
    CameraCalibration calibration(fx,fy,cx,cy);
    
    if (argc < 2)
    {
        std::cout << "Input image not specified" << std::endl;
        std::cout << "Usage: markerless_ar_demo <pattern image> [filepath to recorded video or image]" << std::endl;
        return 1;
    }

    // Try to read the pattern:
    cv::Mat patternImage = cv::imread(argv[1]);
    if (patternImage.empty())
    {
        std::cout << "Input image cannot be read" << std::endl;
        return 2;
    }

    if (argc == 2)
    {
		cv::VideoCapture cap(0);
        processVideo(patternImage, calibration, cap);
    }
    else if (argc == 3)
    {
        std::string input = argv[2];
        cv::Mat testImage = cv::imread(input);
        if (!testImage.empty())
        {
            processSingleImage(patternImage, calibration, testImage);
        }
        else 
        {
            cv::VideoCapture cap(0);
            if (cap.open(input))
            {
                processVideo(patternImage, calibration, cap);
            }
        }
    }
    else
    {
        std::cerr << "Invalid number of arguments passed" << std::endl;
        return 1;
    }

    return 0;
}