コード例 #1
0
int main( int argc, char** argv )
{
    cv::VideoCapture cap;
    cap.open( argv[1] );
    if( !cap.isOpened() )
    {
        std::cout << "Error: could not initialize video capturing...\n";
        return 1;
    }

    cv::Mat frame;   
    cap >> frame;

    Stabilizer stab;
    stab.init(frame);

    cap >> frame;
    while (!frame.empty())
    {

        stab.track(frame);

        cap >> frame;
    }
    return 0;
}
コード例 #2
0
int main( int argc, char** argv )
{
    cv::CommandLineParser parser(argc, argv, params);
    if (parser.get<bool>("help")) {
        parser.printParams();
        return 0;
    }
    std::string video_file = parser.get<std::string>("video");
    std::string type = parser.get<std::string>("type");

    Stabilizer stab;

    if (type == "offline")
    {
        cv::VideoCapture cap;
        cap.open( video_file );
        if( !cap.isOpened() )
        {
            std::cout << "Error: could not initialize video capturing...\n";
            return 1;
        }

        cv::Mat frame;   
        cap >> frame;
        
        stab.init(frame);

        cap >> frame;
        int k;
        int time = clock();

        while (true)
        {
            if (parser.get<bool>("medianflow")) {
                stab.forward_backward_track(frame);
            } else {
                stab.track(frame);
            }

            cap >> frame;
            if(frame.empty())
                break;

            cv::imshow("Video", frame);
            k = cv::waitKey(1);
            if (k == 27){
                break;
            }

            std::cout << clock() - time << "\n";
            time = clock();

        }

        stab.calcMaxShifts();
        std::cout << clock() - time << "\n";
    }