- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在C#中使用opencv来检测网络摄像头图像中的轮廓。如果轮廓有4个点,我想使用它来使用opencv的getPerspective
和warpPerspective
校正包含在此轮廓中的像素的透 View 。职能。
这是获得这4分的代码:
Imgproc.approxPolyDP(perimMat,polyMat,0.005 * perim, true); //get contour of the current detected perimeter as polyMat
List<Point> polyMatList = polyMat.toList(); //convert it to a list of points
if (polyMatList.Count == 4){ //this contour has 4 points, we can use it for getting perspective
Debug.Log("p1x: " + polyMatList[0].x + "p1y: " + polyMatList[0].y); //example log: p1x: 203,p1y: 111
}
getPerspective
中使用它。我该怎么做呢?
for_point_warp
函数似乎提供了不错的指南。我只是不知道C#等效项。
最佳答案
//Begin by sorting your list by y values using List.sort()
polyMatList.sort( (pnt_a, pnt_b) => pnt_b.y - pnt_a.y ); // points 0 & 1 will by definition be your top points and points 2, 3 will be definition be your bottom points.
// now your top 2 points may be out of order since we only sorted by y in the previous step
Point tempPoint;
if(polyMatList[0].x > polyMatList[1].x)
{
tempPoint = polyMatList[0];
polyMatList[0] = polyMatList[1];
polyMatList[1] = tempPoint ;
}
// same goes for your bottom two points
if(polyMatList[2].x > polyMatList[3].x)
{
tempPoint = polyMatList[2];
polyMatList[2] = polyMatList[3];
polyMatList[3] = tempPoint ;
}
//now your list will be ordered tl, tr, bl, br
关于c# - C#-如何按顺时针顺序(tl,tr,br,bl)对4点列表进行排序,以用于opencv getPerspective?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54815961/
我已经很长时间没有使用数学了,这应该是一个简单的问题。 假设我有两个点 A:(1, 0) 和 B:(1, -1)。 我想使用一个程序(Python 或任何编程语言)来计算 A、原点 (0, 0) 和
我有一个用点表示的凸多边形。点由x 坐标数组 和y 坐标数组 表示。 例如: X = {6, 1, 5, 0, 3} Y = {4, 0, 0, 4, 6} 如何按顺时针排序这些点?点数并不总是相同,
我正在开发一个项目,使用这段代码将一个元素拖到另一个圆形元素周围:http://jsfiddle.net/sandeeprajoria/x5APH/11/ function rotateAnn
我有一个二维矩阵 M[N][N],我需要将其逆时针旋转 90 度。我已经看到很多顺时针旋转的答案,但我找不到逆时针旋转的答案。这两个操作有多相似? 最佳答案 如果您反转每一行的顺序,然后顺时针旋转以相
对于我不会涉及的上下文,我需要两个本质上互为倒数的函数。 angle_to() 应该返回钟针从 0° 到连接 p1 和 p2 的线所必须转动的度数>(即 p1 是旋转中心),其中 p1 和 p2 都是
我是一名优秀的程序员,十分优秀!