C# 联合OpenCV开发,并附C#安装包教程

话不说多,直接上代码,不懂私聊我。

 Console.WriteLine("开始生成图片:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"));
            int row = (int)imageWidth;
            int col = (int)imageHeight;
            OpenCvSharp.Mat picMat = new OpenCvSharp.Mat(row, col, OpenCvSharp.MatType.CV_16UC1);
            int r = 0;
            int c = 0;
          
            unsafe
            {
                for (r = 0; r < row; r++)
                {
                    IntPtr p = picMat.Ptr(r);
                    ushort* pp = (ushort*)p.ToPointer();
                    for (c = 0; c < col; c++)
                    {
                        //picMat.Set(r,c, data[r * col + c]);
                        pp[c] = orginImgData[r * col + c];
                    }
                }
               
                OpenCvSharp.Cv2.ImWrite(filename, picMat

你可能感兴趣的:(视觉_Opencv,openCv,C#版)