zoukankan      html  css  js  c++  java
  • opencvcartToPolar笛卡尔坐标转极坐标

    cartToPolar 

    #include<opencv2/opencv.hpp>
    #include<iostream>
    #include  <vector>
    
    
    int main(int argc, char** argv) {
    
        std::vector<cv::Point2f> sides;//建立容器存坐标
        sides.push_back(cv::Point2f(3, 4));
        sides.push_back(cv::Point2f(6, 8));
        sides.push_back(cv::Point2f(1, 1));
    
        cv::Mat xpts(sides.size(), 1, CV_32FC1);
        xpts.at<float>(0, 0) = sides[0].x;
        xpts.at<float>(1, 0) = sides[1].x;
        xpts.at<float>(2, 0) = sides[2].x;
    
        cv::Mat ypts(sides.size(), 1, CV_32F);
        ypts.at<float>(0, 0) = sides[0].y;
        ypts.at<float>(1, 0) = sides[1].y;
        ypts.at<float>(2, 0) = sides[2].y;
    
        std::cerr << xpts << std::endl;
        std::cerr << ypts << std::endl;
    
        cv::Mat magnitude, angle;
        cartToPolar(xpts, ypts, magnitude, angle);//笛卡尔坐标转极坐标
        /*
        参数1:x坐标矩阵    n行1列
        参数2:y坐标矩阵    n行1列
        参数3:极径矩阵   
        参数4:极角矩阵   根据atan2(y, x) 算出来的  单位:弧度
        */
    
        std::cerr << magnitude << std::endl;
        std::cerr << angle << std::endl;
    
        std::cerr << atan2(1, 1)<<std::endl;;
    
        cv::waitKey(0);
        return 0;
    }

  • 相关阅读:
    洛谷#P5652#基础博弈练习题
    hgoi#20191112
    hgoi#20191111
    hgoi#20191109
    洛谷#P3674#小清新人渣的本愿
    hgoi#20191108
    hgoi#20191107
    树上差分
    树链剖分(树剖)
    LCA(最近公共祖先)问题
  • 原文地址:https://www.cnblogs.com/liming19680104/p/15636521.html
Copyright © 2011-2022 走看看