开发者

short[] array to EMGU Image , fastest way?

I have an array of Int16[19200]

I want to turn it into an 开发者_如何学PythonImage[160,120,1]

What is the fastest way of doing this?

I need to do it at 120fps, so it needs to be really efficient.

Thanks

SW


Found it:

            GCHandle handle = GCHandle.Alloc(dataArray, GCHandleType.Pinned);
            IntPtr imageHeaderForBytes = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(MIplImage)));
            CvInvoke.cvInitImageHeader(
                  imageHeaderForBytes,
                  new Size(160, 120),
                  Emgu.CV.CvEnum.IPL_DEPTH.IPL_DEPTH_16S, 1, 0, 4);
            Marshal.WriteIntPtr(
                  imageHeaderForBytes,
                  (int)Marshal.OffsetOf(typeof(MIplImage), "imageData"),
                  handle.AddrOfPinnedObject());

            CvInvoke.cvCopy(imageHeaderForBytes, EMGUImage.Ptr, IntPtr.Zero);

            Marshal.FreeHGlobal(imageHeaderForBytes);
            handle.Free();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜