首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EmguCV HomographyFind -统一总是接收零

EmguCV HomographyFind -统一总是接收零
EN

Stack Overflow用户
提问于 2016-11-24 14:56:21
回答 1查看 275关注 0票数 0

我是在统一工作,并试图使网格和相机同步。

为此,我使用了EmguCV/OpenCV方法HomographyFind:http://www.emgu.com/wiki/files/1.4.0.0/html/3906193c-e458-2cb5-7667-fbb94114d179.htm

我的校准功能如下所示:

代码语言:javascript
复制
 Matrix<float> homography = new Matrix<float>(3, 3);
    float[,] sourcePoints;
    float[,] destPoints;
    void Calibrate()
    {
        sourcePoints = new float[,]{{Cam.greenRect[0].X, Cam.greenRect[0].Y}, {Cam.greenRect[1].X, Cam.greenRect[1].Y}, {Cam.greenRect[2].X, Cam.greenRect[2].Y}, {Cam.greenRect[3].X, Cam.greenRect[3].Y}};
        destPoints = new float[,] { { goTile[0].transform.position.x, goTile[0].transform.position.y }, { goTile[32].transform.position.x, goTile[32].transform.position.y }, { goTile[858].transform.position.x, goTile[858].transform.position.y }, { goTile[890].transform.position.x, goTile[890].transform.position.y } };
        Emgu.CV.Matrix<float> sourceMat = new Matrix<float>(sourcePoints);
        Emgu.CV.Matrix<float> destMat = new Matrix<float>(destPoints);

        CvInvoke.FindHomography(sourceMat, destMat, homography, Emgu.CV.CvEnum.HomographyMethod.Default);
        call.GetComponent<Text>();
        call.text = destPoints[3,0].ToString();

        calibrationComplete = true;

    }

Cam.greenRect和goTile值似乎是合适的,但在我的同形中所有的位置似乎都是0。

因此,我的统一翻译还返回0 (Vector2):

代码语言:javascript
复制
Vector2 coordToUnity(Vector2 fingerPos)
    {
        float x = (fingerPos.x * homography.Data[0, 0]) + (fingerPos.y * homography[0, 1]) + (1 * homography[0, 2]);
        float y = (fingerPos.x * homography.Data[1, 0]) + (fingerPos.y * homography[1, 1]) + (1 * homography[1, 2]);
        return new Vector2(x, y);
    }   

我相信这个问题可能依赖于我的浮点数、矩阵转换或coordToUnity中的算法。

问题: coordToUnity总是返回0。我在哪里实现EmguCV.HomographyFind错误?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-24 16:42:32

答案就在于我所有的价值观都使用了浮点数。此EmguCV版本中的方法只接受双倍。

如果不使用偶数,输出同形字将返回0。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40789457

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档