まあ、これは数学の質問です。
2点:p1(x1,y1)
とp2(x2,y2)
があるとします。 p1
を "開始"、p2
を "終了"としましょう。これはあなたが持っているポイントを呼び出したものです。
slope = (y2 - y1)/(x2 - x1)
length = norm(p2 - p1)
サンプルコード:
cv::Point p1 = cv::Point(5,0); // "start"
cv::Point p2 = cv::Point(10,0); // "end"
// we know this is a horizontal line, then it should have
// slope = 0 and length = 5. Let's see...
// take care with division by zero caused by vertical lines
double slope = (p2.y - p1.y)/(double)(p2.x - p1.x);
// (0 - 0)/(10 - 5) -> 0/5 -> slope = 0 (that's correct, right?)
double length = cv::norm(p2 - p1);
// p_2 - p_1 = (5, 0)
// norm((0,5)) = sqrt(5^2 + 0^2) = sqrt(25) -> length = 5 (that's correct, right?)
おかげで、私はそれが数学の問題だけで私は多分思っていた私は、このコードを使用するいくつかの準備ができてfunctions.soがあることを知っています。 – Aydin
@Aydin問題はありません:)私はこの状況で何度も同じように見えます – Berriel
openCvには大きさやabsdiffのようないくつかの機能がありますが、どうすればそれを使用するのか分かりません。 @Aydin確かに – Aydin