예제 #1
0
        public void TestRuntimeSerialize()
        {
            UMat img = new UMat(100, 80, DepthType.Cv8U, 3);

            using (MemoryStream ms = new MemoryStream())
            {
                //img.SetRandNormal(new MCvScalar(100, 100, 100), new MCvScalar(50, 50, 50));
                //img.SerializationCompressionRatio = 9;
                CvInvoke.SetIdentity(img, new MCvScalar(1, 2, 3));
                System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
                    formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                formatter.Serialize(ms, img);
                Byte[] bytes = ms.GetBuffer();

                using (MemoryStream ms2 = new MemoryStream(bytes))
                {
                    Object o    = formatter.Deserialize(ms2);
                    UMat   img2 = (UMat)o;
                    EmguAssert.IsTrue(img.Equals(img2));
                }
            }
        }
예제 #2
0
      public void TestRuntimeSerialize()
      {
         UMat img = new UMat(100, 80, DepthType.Cv8U, 3);

         using (MemoryStream ms = new MemoryStream())
         {
            //img.SetRandNormal(new MCvScalar(100, 100, 100), new MCvScalar(50, 50, 50));
            //img.SerializationCompressionRatio = 9;
            CvInvoke.SetIdentity(img, new MCvScalar(1, 2, 3));
            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
                formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
            formatter.Serialize(ms, img);
            Byte[] bytes = ms.GetBuffer();

            using (MemoryStream ms2 = new MemoryStream(bytes))
            {
               Object o = formatter.Deserialize(ms2);
               UMat img2 = (UMat)o;
               EmguAssert.IsTrue(img.Equals(img2));
            }
         }
      }