[説明] OpenCVのOpenCVの描画機能とシフトパラメータ

通訳OpenCVの描画機能とシフトパラメータ

多くのOpenCVの描画パラメータは、次のようにその機能が定義されている、があります。

1.基本的な描画機能

1.1直線を描きます

void line
(
	InputOutputArray img, 
	Point pt1, Point pt2,
 	const Scalar& color,
 	int thickness = 1,
	 int lineType = LINE_8,
	 int shift = 0
	 );

最初のパラメータ:上の直線の描画
直線の開始点:第二引数
第三のパラメータ:ラインの終点
第四パラメータ:カラー
5番目のパラメータ:線幅をにより-1ときフィルパターン表される幅、
第六のパラメータ:リニア
第パラメータ:スケーリングパラメータ(後述)

1.2楕円

void ellipse(
	InputOutputArray img,
 	Point center, 
	Size axes,
 	double angle, 
	double startAngle,
 	double endAngle,
 	const Scalar& color, 
	int thickness = 1,
	int lineType = LINE_8,
 	int shift = 0
);

第二のパラメータ:描画楕円の中心
第三のパラメータ:楕円長径の矩形領域と境界の短軸長さ、矩形領域に楕円を描く
第四パラメータ:楕円の回転角度
5番目のパラメータ:デッサン楕円角度出発
第パラメータ:楕円終了角度描画
楕円が完全な回転で、又は楕円ラインの一部である場合、第5及び第六のパラメータが0と360に設定されています。

1.3ラウンド

void circle(
	InputOutputArray img,
 	Point center,
 	int radius,
 	const Scalar& color, 
	int thickness = 1,
	int lineType = LINE_8,
 	int shift = 0);

比較的単純な、説明されていません。

1.4長方形

void rectangle(
	CV_IN_OUT Mat& img,
 	Rect rec,
 	const Scalar& color, 
	int thickness = 1,
	int lineType = LINE_8, 
	int shift = 0
);

比較的単純な、説明されていません。

1.5ポリゴン

void fillPoly(
	Mat& img,
	 const Point** pts,
 	 const int* npts,
 	int ncontours,
 	const Scalar& color, 
	int lineType = LINE_8, 
	int shift = 0,
	Point offset = Point() );

第二引数:注は、二次元のポインタです。ポリゴンの境界点を描画表現。
第三のパラメータ:ディメンションへのポインタは、多角形の境界点の数を表す
第四のパラメータ:ポリゴンの数を描画する
第八のパラメータを:すべてのオプションのオフセット輪郭

具体的な使用例


 	Point p[1][5];  
	p[0][0] = Point(100, 100);
	p[0][1] = Point(100, 200);
	p[0][2] = Point(200, 300);
	p[0][3] = Point(300, 200);
	p[0][4] = Point(300, 100);
	const Point* ppt[1] = { p[0] };//多边形点集
	
	int npt[] = { 5 };//多边形点集的数量
	fillPoly(m, ppt, npt,1,Scalar(255, 0, 0), 8);

2.シフトパラメータ

ほぼすべてのプロットの後ろにそれをやっている最終的にint型のシフトパラメータの機能を、持っていますか?私のテストの後、私はシフトが縮小画像のために使用されて発見され、ライン長の中心点座標が縮小され、元のデジタルD、デジタル変換さをdとし、特定の式であります:

D = D / 2 シフト

次のようにテストは以下のとおりです。

#include<opencv2/opencv.hpp>
#include<iostream>
using namespace cv;
using namespace std;

int main()
{

	Mat m = imread("1.png");
	circle(m, Point(300, 300), 100, Scalar(0, 0, 255), 0, 8, 0);
	circle(m, Point(300, 300), 100, Scalar(0, 0, 255), 1, 8, 1);
	circle(m, Point(300, 300), 100, Scalar(0, 0, 255), 1, 8, 3);
	
	imshow("a", m);
	waitKey(0);
	return 0;
}

上記オフセット効果のコードのみであり
ここに画像を挿入説明
、それが2に従って見ることができる、次の制御コードを作ったシフト赤い円複数の狭黒丸と全く一致

#include<opencv2/opencv.hpp>
#include<iostream>
using namespace cv;
using namespace std;

int main()
{

	Mat m = imread("1.png");

	circle(m, Point(300, 300), 100, Scalar(0, 0, 255), 0, 8, 0);
	
	circle(m, Point(300, 300), 100, Scalar(0, 0, 255), 1, 8, 1);
	circle(m, Point(300/2, 300/2), 100/2, Scalar(0, 0, 0), 1, 8, 0); //与上一个红色圈重合
	
	circle(m, Point(300, 300), 100, Scalar(0, 0, 255), 1, 8, 3);
	circle(m, Point(300 / 8, 300 / 8), 100 / 8, Scalar(0, 0, 0), 1, 8, 0);//与上一个红色圈重合
	
	imshow("a", m);
	waitKey(0);
	return 0;
}


ここに画像を挿入説明

公開された14元の記事 ウォンの賞賛1 ビュー502

おすすめ

転載: blog.csdn.net/qq_41741344/article/details/104347443