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


C# CvMat.Split方法代码示例

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


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

示例1: viewDepthUndistionMat

        void viewDepthUndistionMat(CvMat src, CvMat depthMat)
        {
            if (src == null)
            {
                return;
            }
            double pX = this.UndistortionData.CameraStruct.PrincipalX;
            double pY = this.UndistortionData.CameraStruct.PrincipalY;
            int focalX = (int)(this.UndistortionData.CameraStruct.FocalX / 2);
            int focalY = (int)(this.UndistortionData.CameraStruct.FocalY / 2);

            if (src.ElemChannels == 3)
            {
                CvMat quadratic = CvEx.InitCvMat(src, MatrixType.F32C1);
                CvMat scale = CvEx.InitCvMat(src, MatrixType.F32C1);
                CvMat offset = CvEx.InitCvMat(src, MatrixType.F32C1);
                src.Split(quadratic, scale, offset, null);
                float maxQuadratic, minQuadratic;
                float maxScale, minScale;
                float maxOffset, minOffset;
                using (CvMat displayMatQuadratic = getDepthUndistortMatImage(out maxQuadratic, out minQuadratic, quadratic, 0f))
                using (CvMat displayMatScale = getDepthUndistortMatImage(out maxScale, out minScale, scale, 1f))
                using (CvMat displayMatOffset = getDepthUndistortMatImage(out maxOffset, out minOffset, offset, null))
                {
                    using (CvMat black = CvEx.InitCvMat(src, MatrixType.U8C1))
                    {
                        CvMat total = CvEx.InitCvMat(src, MatrixType.U8C3);
                        black.Zero();
                        total.Merge(displayMatQuadratic, displayMatScale, displayMatOffset, null);
                        total.PutText(string.Format("RangeQuadatic: {0:0.000} to {1:0.000}", minQuadratic, maxQuadratic), new CvPoint(0, 20), new CvFont(FontFace.HersheyPlain, 1, 1), new CvScalar(255, 255, 255));
                        total.PutText(string.Format("RangeScale: {0:0.000} to {1:0.000}", minScale, maxScale), new CvPoint(0, 40), new CvFont(FontFace.HersheyPlain, 1, 1), new CvScalar(255, 255, 255));
                        total.PutText(string.Format("RangeOffset: {0:0.000} to {1:0.000}", minOffset, maxOffset), new CvPoint(0, 60), new CvFont(FontFace.HersheyPlain, 1, 1), new CvScalar(255, 255, 255));
                        total.DrawLine(new CvPoint((int)pX, 0), new CvPoint((int)pX, total.Rows), new CvScalar(255, 255, 0));
                        total.DrawLine(new CvPoint(0, (int)pY), new CvPoint(total.Cols, (int)pY), new CvScalar(255, 255, 0));
                        total.DrawEllipse(new CvPoint((int)pX, (int)pY), new CvSize(focalX, focalY), 0, 0, 360, new CvScalar(255, 0, 0));
                        putImage(total, PixelFormats.Bgr24);
                    }
                }
            }
            else if (src.ElemChannels == 2)
            {
                CvMat scale = CvEx.InitCvMat(src, MatrixType.F32C1);
                CvMat offset = CvEx.InitCvMat(src, MatrixType.F32C1);
                src.Split(scale, offset, null, null);
                float maxScale, minScale;
                float maxOffset, minOffset;
                using (CvMat displayMatScale = getDepthUndistortMatImage(out maxScale, out minScale, scale, 1f))
                using (CvMat displayMatOffset = getDepthUndistortMatImage(out maxOffset, out minOffset, offset, null))
                {
                    using (CvMat black = CvEx.InitCvMat(src, MatrixType.U8C1))
                    {
                        CvMat total = CvEx.InitCvMat(src, MatrixType.U8C3);
                        black.Zero();
                        total.Merge(black, displayMatScale, displayMatOffset, null);
                        total.PutText(string.Format("RangeScale: {0:0.000} to {1:0.000}", minScale, maxScale), new CvPoint(0, 20), new CvFont(FontFace.HersheyPlain, 1, 1), new CvScalar(255, 255, 255));
                        total.PutText(string.Format("RangeOffset: {0:0.000} to {1:0.000}", minOffset, maxOffset), new CvPoint(0, 40), new CvFont(FontFace.HersheyPlain, 1, 1), new CvScalar(255, 255, 255));
                        total.DrawLine(new CvPoint((int)pX, 0), new CvPoint((int)pX, total.Rows), new CvScalar(255, 255, 0));
                        total.DrawLine(new CvPoint(0, (int)pY), new CvPoint(total.Cols, (int)pY), new CvScalar(255, 255, 0));
                        total.DrawEllipse(new CvPoint((int)pX, (int)pY), new CvSize(focalX, focalY), 0, 0, 360, new CvScalar(255, 0, 0));
                        putImage(total, PixelFormats.Bgr24);
                    }
                }
            }
            else if (src.ElemChannels == 1)
            {
                float max, min;
                using (CvMat displayMat = getDepthUndistortMatImage(out max, out min, src, null))
                {
                    CvMat total = CvEx.InitCvMat(src, MatrixType.U8C3);
                    total.Merge(displayMat, displayMat, displayMat, null);
                    total.PutText(string.Format("Range: {0:0.000} to {1:0.000}", min, max), new CvPoint(0, 20), new CvFont(FontFace.HersheyPlain, 1, 1), new CvScalar(255, 255, 0));
                    if (depthMat != null)
                    {
                        double? pDepth = CvEx.Get2DSubPixel(depthMat, new CvPoint2D32f(pX, pY), 0);
                        if (pDepth.HasValue)
                        {
                            total.PutText(pDepth.Value.ToString("0"), new CvPoint((int)pX, (int)pY), new CvFont(FontFace.HersheyPlain, 1, 1), new CvScalar(255, 255, 0));
                        }
                        total.DrawLine(new CvPoint((int)pX, 0), new CvPoint((int)pX, total.Rows), new CvScalar(255, 255, 0));
                        total.DrawLine(new CvPoint(0, (int)pY), new CvPoint(total.Cols, (int)pY), new CvScalar(255, 255, 0));
                        total.DrawEllipse(new CvPoint((int)pX, (int)pY), new CvSize(focalX, focalY), 0, 0, 360, new CvScalar(255, 0, 0));

                    }
                    putImage(total, PixelFormats.Bgr24);
                }
            }
        }
开发者ID:guozanhua,项目名称:KinectMotionCapture,代码行数:87,代码来源:CameraUndistortWindow.xaml.cs


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