最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線(xiàn)溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
OpenCV畫(huà)任意圓弧曲線(xiàn)

逆時(shí)針畫(huà)圓弧,原理:將360度分割成36份,分別標(biāo)出每10度角度時(shí)的坐標(biāo)點(diǎn),然后將每個(gè)點(diǎn)連接起來(lái)。 

創(chuàng)新互聯(lián)專(zhuān)業(yè)為企業(yè)提供嵊泗網(wǎng)站建設(shè)、嵊泗做網(wǎng)站、嵊泗網(wǎng)站設(shè)計(jì)、嵊泗網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、嵊泗企業(yè)網(wǎng)站模板建站服務(wù),10多年嵊泗做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

#include  
#include 
#include  
#include  
#include  
 
#include  
#include 
 
using namespace cv;
using namespace std;
 
// 圖像、圓心、開(kāi)始點(diǎn)、結(jié)束點(diǎn)、線(xiàn)寬
void DrawArc(Mat *src, Point ArcCenter, Point StartPoint, Point EndPoint, int Fill)
{
 if (Fill <= 0) return;
 
 vector Dots;
 double Angle1 = atan2((StartPoint.y - ArcCenter.y), (StartPoint.x - ArcCenter.x));
 double Angle2 = atan2((EndPoint.y - ArcCenter.y), (EndPoint.x - ArcCenter.x));
 double Angle = Angle1 - Angle2;
 Angle = Angle * 180.0 / CV_PI;
 
 if (Angle < 0) Angle = 360 + Angle;
 if (Angle == 0) Angle = 360;
 int brim = floor(Angle / 10); // 向下取整
 
 Dots.push_back(StartPoint);
 for (int i = 0; i < brim; i++)
 {
 double dSinRot = sin(-(10 * (i + 1)) * CV_PI / 180);
 double dCosRot = cos(-(10 * (i + 1)) * CV_PI / 180);
 int x = ArcCenter.x + dCosRot * (StartPoint.x - ArcCenter.x) - dSinRot * (StartPoint.y - ArcCenter.y);
 int y = ArcCenter.y + dSinRot * (StartPoint.x - ArcCenter.x) + dCosRot * (StartPoint.y - ArcCenter.y);
 Dots.push_back(Point(x, y));
 }
 Dots.push_back(EndPoint);
 RNG &rng = theRNG();
 Scalar color = Scalar(rng.uniform(100, 255), rng.uniform(100, 255), rng.uniform(100, 255));
 for (int i = 0; i < Dots.size() - 1; i++) {
 line(*src, Dots[i], Dots[i + 1], color, Fill);
 }
 Dots.clear();
}
 
int main()
{
 Mat Img = Mat::zeros(800, 800, CV_8UC3);
 int64 tim = getTickCount();
 
 // 坐標(biāo)零點(diǎn) 400,400
 Point ZeroPoint = Point(400, 400);
 // 起始坐標(biāo) 150,-100
 Point StartPoint = Point(ZeroPoint.x +150, ZeroPoint.y - (-100));
 // 結(jié)束坐標(biāo) -150,-100
 Point EndPoint = Point(ZeroPoint.x - 150, ZeroPoint.y - (-100));
 
 // 圓心相對(duì)起始點(diǎn)的坐標(biāo) -150,200
 int I = StartPoint.x - 150;
 int J = StartPoint.y - (+200);
 
 Point Arc = Point(I, J);
 
 // 顯示圓心坐標(biāo)
 circle(Img, Arc, 5, Scalar(0, 0, 255), -1);
 // 顯示起始點(diǎn)坐標(biāo)
 circle(Img, StartPoint, 5, Scalar(255, 0, 0), -1);
 // 顯示結(jié)束點(diǎn)坐標(biāo)
 circle(Img, EndPoint, 5, Scalar(0, 255, 0), -1);
 
 // 圖像、圓心、開(kāi)始點(diǎn)、結(jié)束點(diǎn)、線(xiàn)寬
 DrawArc(&Img, Arc, StartPoint, EndPoint, 2);
 imshow("正多邊形", Img);
 
 tim = getTickCount() - tim;
 printf("處理耗時(shí): %fms\n\n", tim * 1000 / getTickFrequency());
 waitKey(0);
 return 0;
}

效果如下:

OpenCV畫(huà)任意圓弧曲線(xiàn)

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。


本文標(biāo)題:OpenCV畫(huà)任意圓弧曲線(xiàn)
鏈接地址:http://fisionsoft.com.cn/article/gioehd.html