是否有一个java库可以处理所有标准操作的四元数和矩阵(四元数矩阵乘法)?
(我之前搜索谷歌和这里 - 但没有找到任何适当的解决方案)
我是openCV的新手,因此我遇到了一些问题.
一个问题是我如何获得轮廓的坐标以绘制例如围绕它的圆圈.
到目前为止,我的代码如下所示:
List<MatOfPoint> contours = mDetector.getContours();
Imgproc.drawContours(mRgba, contours, -1, CONTOUR_COLOR, -1);
<<code that I need>>
Core.circle(mRgba, new Point(150.0,150.0), 100, CONTOUR_COLOR, 5);
Run Code Online (Sandbox Code Playgroud)
轮廓被"提取"并绘制在测试圆圈的表面上,但是如何从轮廓中获取坐标(边界)以在每个轮廓周围绘制圆圈.
谢谢
它可能是一个简单/愚蠢的问题,但我在opencv(android)中有转换问题.
我的目标是从两个连续的图像中计算出相应匹配的基本矩阵.
我编程到目前为止(和工作):
detector.detect(actImg, actKP);
detector.detect(prevImg, prevKP);
descExtractor.compute(prevImg, prevKP, descriptorPrev);
descExtractor.compute(actImg, actKP, descriptorAct);
descMatcher.match(descriptorPrev, descriptorAct, matches);
Features2d.drawMatches(prevImg, prevKP, actImg, actKP,matches, mRgba);
Run Code Online (Sandbox Code Playgroud)
匹配的类型为MatOfDMatch.
现在我将从相互匹配的点中计算出基本矩阵.因此,我必须知道在第二张图像(actKP)中找到第一张图像(prevKP)中的哪些关键点.
Mat fundamental_matrix = Calib3d.findFundamentalMat(nextPts, prevPts, Calib3d.FM_RANSAC,3, 0.99);
Run Code Online (Sandbox Code Playgroud)
第一个问题:如何将MatOfKeyPoints提取/转换为MatOfPoint2f(它们可以传递给findFundamentalMatrix)
第二个问题:如何只将匹配的关键点传递给函数findFundamentalMatrix.这是一个很好的方法吗?
非常感谢advace!
编辑
非常感谢您的详细回复!我把你的代码写成两个函数:
private MatOfPoint2f getMatOfPoint2fFromDMatchesTrain(MatOfDMatch matches2,
MatOfKeyPoint prevKP2) {
DMatch dm[] = matches2.toArray();
List<Point> lp1 = new ArrayList<Point>(dm.length);
KeyPoint tkp[] = prevKP2.toArray();
for (int i = 0; i < dm.length; i++) {
DMatch dmm = dm[i];
if (dmm.trainIdx < tkp.length)
lp1.add(tkp[dmm.trainIdx].pt);
}
return new MatOfPoint2f(lp1.toArray(new Point[0]));
} …Run Code Online (Sandbox Code Playgroud)