2011-02-14 71 views

回答

2

發現:

  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(); 
相關問題