openCV 视频 cvLogPolar 对数极坐标变换


#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})

转换前
在这里插入图片描述

转换后 
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SongYuLong的博客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值