OpenCV 5.0.0
Open Source Computer Vision
読み込み中...
検索中...
見つかりません
🤖 AIによる機械翻訳(非公式) — これは OpenCV 5.0.0 公式リファレンス(英語)を AI (Claude) で自動翻訳したものです。訳に誤りを含む場合があります。正確な情報は 公式英語版(原文) を参照してください。
いくつかのデータ構造

目的

  • いくつかのデータ構造を学ぶ:PointScalarSizeCircleRectRotatedRect など。

Scalar は JavaScript における配列型である。Point、Size、Circle、Rect、RotatedRect は JavaScript におけるオブジェクト型である。

Point

Point を構築するには2通りの方法があり、いずれも同じである:

// The first way
let point = new cv.Point(x, y);
// The second way
let point = {x: x, y: y};
引数
x点の x 座標。(原点は画像の左上隅)
y点の y 座標。

Scalar

Scalar を構築するには2通りの方法があり、いずれも同じである:

// The first way
let scalar = new cv.Scalar(R, G, B, Alpha);
// The second way
let scalar = [R, G, B, Alpha];
引数
R赤チャンネルのピクセル値。
G緑チャンネルのピクセル値。
B青チャンネルのピクセル値。
Alphaアルファチャンネルのピクセル値。

Size

Size を構築するには2通りの方法があり、いずれも同じである:

// The first way
let size = new cv.Size(width, height);
// The second way
let size = {width : width, height : height};
引数
widthサイズの幅。
heightサイズの高さ。

Circle

Circle を構築するには2通りの方法があり、いずれも同じである:

// The first way
let circle = new cv.Circle(center, radius);
// The second way
let circle = {center : center, radius : radius};
引数
center円の中心。
radius円の半径。

Rect

Rect を構築するには2通りの方法があり、いずれも同じである:

// The first way
let rect = new cv.Rect(x, y, width, height);
// The second way
let rect = {x : x, y : y, width : width, height : height};
引数
x矩形の左上隅となる頂点の x 座標。
y矩形の左上隅となる頂点の y 座標。
width矩形の幅。
height矩形の高さ。

RotatedRect

RotatedRect を構築するには2通りの方法があり、いずれも同じである:

// The first way
let rotatedRect = new cv.RotatedRect(center, size, angle);
// The second way
let rotatedRect = {center : center, size : size, angle : angle};
引数
center矩形の重心。
size矩形の幅と高さ。
angle時計回りの回転角度。角度が 0、90、180、270 などのとき、矩形は正立した矩形となる。

rotatedRect から頂点を取得する方法を学ぶ:

関数 cv.RotatedRect.points(rotatedRect) を使用する

引数
rotatedRect回転矩形
let vertices = cv.RotatedRect.points(rotatedRect);
let point1 = vertices[0];
let point2 = vertices[1];
let point3 = vertices[2];
let point4 = vertices[3];

rotatedRect からバウンディング矩形を取得する方法を学ぶ:

関数 cv.RotatedRect.boundingRect(rotatedRect) を使用する

引数
rotatedRect回転矩形
let boundingRect = cv.RotatedRect.boundingRect(rotatedRect);