#include "opencv2/core.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
#include <iostream>
using namespace std;
using namespace cv;
int main(int argc, char **argv)
{
CvCapture* capture = NULL;
capture = cvCreateFileCapture(argv[1]);
if (!capture)
{
return -1;
}
IplImage* bgr_frame = cvQueryFrame(capture); //Init video read
double fps = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
CvSize size = cvSize(
(int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH),
(int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT)
);
CvVideoWriter *writer = cvCreateVideoWriter(argv[2], CV_FOURCC('M','J','P','G'), fps, size);
IplImage* logpolar_frame = cvCreateImage(size, IPL_DEPTH_8U, 3);
while( (bgr_frame = cvQueryFrame(capture)) != NULL)
{
cvLogPolar(
bgr_frame,
logpolar_frame,
cvPoint2D32f(bgr_frame->width/2, bgr_frame->height/2),
40,
CV_INTER_LINEAR + CV_WARP_FILL_OUTLIERS
);
cvWriteFrame(writer, logpolar_frame);
}
cvReleaseVideoWriter(&writer);
cvReleaseCapture(&capture);
cvReleaseImage(&bgr_frame);
cvReleaseImage(&logpolar_frame);
return 0;
}
cmake_minimum_required(VERSION 2.8)
project(grayscale)
find_package(OpenCV REQUIRED)
add_executable(grayscale main.cpp)
target_link_libraries(grayscale ${OpenCV_LIBS})
转换前
转换后