当前位置: 首页>>代码示例>>C#>>正文


C# CvMat.SetReal2D方法代码示例

本文整理汇总了C#中CvMat.SetReal2D方法的典型用法代码示例。如果您正苦于以下问题:C# CvMat.SetReal2D方法的具体用法?C# CvMat.SetReal2D怎么用?C# CvMat.SetReal2D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CvMat的用法示例。


在下文中一共展示了CvMat.SetReal2D方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindExtrinsicCameraParams2Cs


//.........这里部分代码省略.........
                    _Mc[0] = Mc.Val0;
                    _Mc[1] = Mc.Val1;
                    _Mc[2] = Mc.Val2;
                    Reshape(matM, matM, 1, count);
                    MulTransposed(matM, _MM, true, _Mc);
                    SVD(_MM, matW, null, matV, SVDFlag.ModifyA | SVDFlag.V_T);

                    // initialize extrinsic parameters
                    if (W[2] / W[1] < 1e-3 || count < 4)
                    {
                        // a planar structure case (all M's lie in the same plane)
                        double[] h = new double[9];
                        CvMat R_transform = matV;
                        CvMat T_transform = new CvMat(3, 1, MatrixType.F64C1);
                        CvMat matH = new CvMat(3, 3, MatrixType.F64C1, h);
                        CvMat _h1, _h2, _h3;

                        if (V[2] * V[2] + V[5] * V[5] < 1e-10)
                            SetIdentity(R_transform);

                        if (Det(R_transform) < 0)
                            Scale(R_transform, R_transform, -1);

                        //GEMM(R_transform, _Mc, -1, null, 0, T_transform, GemmOperation.B_T);
                        for (int r = 0; r < 3; r++)
                        {                            
                            for (int c = 0; c < 1; c++)
                            {
                                double sum = 0;
                                for (int k = 0; k < 3; k++)
                                {
                                    sum += R_transform.GetReal2D(r, k) * _Mc.GetReal2D(c, k);
                                }
                                T_transform.SetReal2D(r, c, sum * -1);
                            }
                        }

                        for (int i = 0; i < count; i++)
                        {
                            double* Rp = R_transform.DataDouble;
                            double* Tp = T_transform.DataDouble;
                            double* src = matM.DataDouble + i * 3;
                            double* dst = _Mxy.DataDouble + i * 2;

                            dst[0] = Rp[0] * src[0] + Rp[1] * src[1] + Rp[2] * src[2] + Tp[0];
                            dst[1] = Rp[3] * src[0] + Rp[4] * src[1] + Rp[5] * src[2] + Tp[1];
                        }

                        FindHomography_(_Mxy, _mn, matH);

                        GetCol(matH, out _h1, 0);
                        GetCol(matH, out _h2, 0);
                        GetCol(matH, out _h3, 0);                        
                        _h2.DataDouble += 1;
                        _h3.DataDouble += 2;
                        double h1_norm = Math.Sqrt(h[0] * h[0] + h[3] * h[3] + h[6] * h[6]);
                        double h2_norm = Math.Sqrt(h[1] * h[1] + h[4] * h[4] + h[7] * h[7]);
                        Scale(_h1, _h1, 1.0 / h1_norm);
                        Scale(_h2, _h2, 1.0 / h2_norm);
                        Scale(_h3, _t, 2.0 / (h1_norm + h2_norm));                       
                        CrossProduct(_h1, _h2, _h3);

                        Rodrigues2_(matH, _r);
                        Rodrigues2_(_r, matH);
                        MatMulAdd(matH, T_transform, _t, _t);
                        MatMul(matH, R_transform, matR);
开发者ID:jorik041,项目名称:opencvsharp,代码行数:67,代码来源:Cv_F.cs


注:本文中的CvMat.SetReal2D方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。