博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
OpenCV——花环生成函数
阅读量:4590 次
发布时间:2019-06-09

本文共 1458 字,大约阅读时间需要 4 分钟。

// define head function#ifndef PS_ALGORITHM_H_INCLUDED#define PS_ALGORITHM_H_INCLUDED#include 
#include
#include "cv.h"#include "highgui.h"#include "cxmat.hpp"#include "cxcore.hpp"#include "math.h"using namespace std;using namespace cv;void Show_Image(Mat&, const string &);#endif // PS_ALGORITHM_H_INCLUDED/*This program will generate the garland.*/#include "PS_Algorithm.h"#include
using namespace std;using namespace cv;#define pi 3.1415926int main(){ Mat Img(400,600, CV_32FC3); int width=Img.cols; int height=Img.rows; Point Center(width/2, height/2); int k=4; int N=720; float R=150.0; float dn; dn=360.0/N; float theta; float r; float x,y; float new_x, new_y; for (int i=0; i<=N; i++) { theta=(i*dn)*pi/180.0; r=R*sin(k*theta); x=(r*cos(theta)); y=(r*sin(theta)); new_y=(int)(Center.y-y); new_x=(int)(Center.x+x); Img.at
(new_y, new_x)[0]=1; Img.at
(new_y, new_x)[1]=1; Img.at
(new_y, new_x)[2]=1; } Show_Image(Img, "out"); imwrite("Out.jpg", Img*255); waitKey();}// define the show image#include "PS_Algorithm.h"#include
#include
using namespace std;using namespace cv;void Show_Image(Mat& Image, const string& str){ namedWindow(str.c_str(),CV_WINDOW_AUTOSIZE); imshow(str.c_str(), Image);}

转载于:https://www.cnblogs.com/mtcnn/p/9412576.html

你可能感兴趣的文章
jmeter生成随机的四位数
查看>>
Jmeter做接口的压力测试
查看>>
sql语句优化的30种方法
查看>>
MyISAM和InnoDB的区别
查看>>
springboot2.0 management.security.enabled无效
查看>>
spring cloud启动zipkin,报错maven依赖jar包冲突 Class path contains multiple SLF4J bindings
查看>>
源发行版8需要目标发行版1.8
查看>>
Cleartext HTTP traffic to xxx not permitted解决办法
查看>>
[Docker] Win10中安装Docker并运行Nginx镜像
查看>>
salesforce入门
查看>>
MySQL 8.017连接Navicat中出现的问题
查看>>
Css布局
查看>>
遇到的小问题
查看>>
sql server的Case When Then关键字的使用
查看>>
Css进阶
查看>>
SQL在工作中遇到的问题
查看>>
在电脑CMD中通过pip安装完部分文件后PyCharm仍无法使用的解决方法
查看>>
笨方法学Python3(21-44)
查看>>
笨方法学python3
查看>>
Linux for Matlab中文注释乱码(亲测有效)
查看>>