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


C# Mat.Total方法代码示例

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


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

示例1: Update


//.........这里部分代码省略.........
                    }
                    fs.Write(nodeName, kinectPts.ToCvMat());
                    nodeName = "projectorPoints";
                    Mat projPts = new Mat(1, projectorCoordinates.Count, MatType.CV_64FC2);
                    for (int i = 0; i < projectorCoordinates.Count; i++)
                    {
                        projPts.Set<CvPoint2D64f>(0, i, (CvPoint2D64f)projectorCoordinates[i]);
                    }
                    fs.Write(nodeName, projPts.ToCvMat());
                    fs.Dispose();
                }
                Debug.Log("Calib Data saved!");
            }
            if (Input.GetKeyDown(KeyCode.Q))
            {
                delLastPoints();
            }
            if (kinect.GetDepthRaw())
            {
                try
                {

                    Mat src = DoDepthBuffer(kinect.usersDepthMap, KinectWrapper.GetDepthWidth(), KinectWrapper.GetDepthHeight());
                    dBuffer = src.Clone();
                    src.ConvertTo(src, OpenCvSharp.CPlusPlus.MatType.CV_8UC1, 255.0f / NUI_IMAGE_DEPTH_MAXIMUM);

                    Mat show = new Mat(KinectWrapper.GetDepthHeight(), KinectWrapper.GetDepthWidth(), OpenCvSharp.CPlusPlus.MatType.CV_8UC4);
                    Mat alpha = new Mat(KinectWrapper.GetDepthHeight(), KinectWrapper.GetDepthWidth(), OpenCvSharp.CPlusPlus.MatType.CV_8UC1, new Scalar(255));
                    Mat[] planes = new Mat[4] { src, src, src, alpha };
                    Cv2.Merge(planes, show);
                    //Mat falseColorsMap = new Mat();
                    //Cv2.ApplyColorMap(src, falseColorsMap, OpenCvSharp.CPlusPlus.ColorMapMode.Rainbow);
                    //Cv2.ImShow("show", falseColorsMap);
                    int matSize = (int)show.Total() * show.Channels();
                    byte[] rColors = new byte[matSize];
                    Marshal.Copy(show.DataStart, rColors, 0, matSize);
                    scTex.LoadRawTextureData(rColors);
                    scTex.Apply(false);
                    ScreenObject.GetComponent<RawImage>().texture = scTex;
                    if (showResult)
                    {
                        //ResultObject.SetActive(true);
                        screenTx.SetPixels32(resetPixels);
                        long discarded = 0;
                        long drawn = 0;
                        long bounds = 0;
                        //Color32[] txcl = (Color32[])resetPixels.Clone();
                        Color32[] txcl = new Color32[screenTx.height * screenTx.width];
                        for (int i = 0; i < txcl.Length; i++)
                        {
                            Color32 cCol = new Color32(0, 0, 0, 255);
                            txcl[i] = cCol;
                        }
                        screenTx.SetPixels32(txcl, 0);
                        Color32 sccolor = Color.white;
                        for (int i = 0; i < show.Rows; i += 5)
                        {
                            for (int j = 0; j < show.Cols; j += 5)
                            {
                                CvPoint3D64f realVal = NuiTransformDepthImageToSkeleton((long)j, (long)i, dBuffer.Get<ushort>((int)i, (int)j));
                                if (realVal.Z < projThresh && realVal.Z > 1.0)
                                {
                                    CvPoint2D64f scCoord = convertKinectToProjector(realVal);
                                    if (scCoord.X > 0.0 && scCoord.X < Screen.width && scCoord.Y > 0.0 && scCoord.Y < Screen.height)
                                    {
                                        //Debug.Log(scCoord.X.ToString() + " " + scCoord.Y.ToString());
开发者ID:Titoulion,项目名称:Shoal,代码行数:67,代码来源:KinectProjectorCalibrator.cs


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