本文主要是介绍Opencv入门6(读取彩色视频并转换为对数极坐标视频),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
源码如下:
#include <opencv2/opencv.hpp>
#include <iostream>
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(读取彩色视频并转换为对数极坐标视频)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!