Ejemplo n.º 1
0
        /// <summary>
        /// Extracts the raw image result batch from the result binary data.
        /// </summary>
        /// <param name="nBatchCount">Specifies the number of results in the batch.</param>
        /// <param name="rgData">Specifies the binary batch data.</param>
        /// <returns>An array of tuples containing SimpleDatum/Result pairs is returned.</returns>
        public static List <Tuple <SimpleDatum, List <Result> > > GetResults(int nBatchCount, byte[] rgData)
        {
            if (nBatchCount <= 0)
            {
                throw new Exception("The batch count must be >= 1!");
            }

            List <Tuple <SimpleDatum, List <Result> > > rgRes1 = new List <Tuple <SimpleDatum, List <Result> > >();

            using (MemoryStream ms = new MemoryStream(rgData))
                using (BinaryReader br = new BinaryReader(ms))
                {
                    int nCount = br.ReadInt32();
                    if (nCount != nBatchCount)
                    {
                        throw new Exception("The batch count does not match the expected count of " + nCount.ToString());
                    }

                    for (int i = 0; i < nCount; i++)
                    {
                        int           nImageID = br.ReadInt32();
                        int           nIdx     = br.ReadInt32();
                        long          lTime    = br.ReadInt64();
                        DateTime      dt       = DateTime.FromFileTimeUtc(lTime);
                        List <Result> rgRes    = GetResults(br);

                        SimpleDatum sd = new SimpleDatum();
                        sd.SetImageID(nImageID);
                        sd.Index     = nIdx;
                        sd.TimeStamp = dt;

                        rgRes1.Add(new Tuple <SimpleDatum, List <Result> >(sd, rgRes));
                    }
                }

            return(rgRes1);
        }