Opencv入门6(读取彩色视频并转换为对数极坐标视频)

源码如下:

#include
#include
int main(int argc, char* argv[])
{
    cv::namedWindow("Example2_11", cv::WINDOW_AUTOSIZE);
    cv::namedWindow("Log_Polar", cv::WINDOW_AUTOSIZE);
    cv::VideoCapture capture(argv[1]);
    double fps = capture.get(cv::CAP_PROP_FPS);
    cv::Size size(
        (int)capture.get(cv::CAP_PROP_FRAME_WIDTH),
        (int)capture.get(cv::CAP_PROP_FRAME_HEIGHT)
    );
    cv::VideoWriter writer;
    writer.open(argv[2], CV_FOURCC('M', 'J', 'P', 'G'), fps, size);
    cv::Mat logpolar_frame, bgr_frame;
    for (;;) {
        capture >> bgr_frame;
        if (bgr_frame.empty())break;//end if done
        cv::imshow("Example2_11", bgr_frame);
        cv::logPolar(
            bgr_frame,
            logpolar_frame,
            cv::Point2f(
                bgr_frame.cols / 2,
                bgr_frame.rows / 2
            ),
            40,
            //Input color frame//Output log-polar frame
            //Centerpoint for log-polar transformation//
            cv::WARP_FILL_OUTLIERS
        );
        //Magnitude(scale parameter)//Fill outliers with 'zero'
        cv::imshow("Log_Polar", logpolar_frame); writer << logpolar_frame;
        char c = cv::waitKey(10);
        if (c == 27)break;
    }
        //allow the user to break out
    capture.release();

Opencv入门6(读取彩色视频并转换为对数极坐标视频)_第1张图片

你可能感兴趣的:(Opencv,opencv,人工智能,计算机视觉)