Пример #1
0
        private static PhotoFingerPrintWrapper Convert(PhotoFingerPrint?fingerPrint)
        {
            PhotoFingerPrint fingerPrintNotNull = TypeUtils.NullThrows(fingerPrint);

            byte[] edgeGrayScaleThumb = (
                from i in Enumerable.Range(0, fingerPrintNotNull.EdgeGrayScaleThumbLength)
                select fingerPrintNotNull.EdgeGrayScaleThumb(i)
                ).ToArray();

            return(new PhotoFingerPrintWrapper
            {
                FilePath = fingerPrintNotNull.FilePath,
                PHash = fingerPrintNotNull.Phash,
                EdgeGrayScaleThumb = edgeGrayScaleThumb,
            });
        }
Пример #2
0
        private static Offset <PhotoFingerPrint>[] CreatePhotoFingerPrintArray(PhotoFingerPrintDatabaseWrapper database, FlatBufferBuilder builder)
        {
            int photoFingerPrintCounter = 0;
            var photoFingerPrintArray   = new Offset <PhotoFingerPrint> [database.PhotoFingerPrints.Length];

            foreach (PhotoFingerPrintWrapper fingerPrint in database.PhotoFingerPrints)
            {
                StringOffset filePathOffset       = builder.CreateString(fingerPrint.FilePath);
                VectorOffset grayScaleImageOffset = PhotoFingerPrint.CreateEdgeGrayScaleThumbVector(builder, fingerPrint.EdgeGrayScaleThumb);

                PhotoFingerPrint.StartPhotoFingerPrint(builder);
                PhotoFingerPrint.AddFilePath(builder, filePathOffset);
                PhotoFingerPrint.AddPhash(builder, fingerPrint.PHash);
                PhotoFingerPrint.AddEdgeGrayScaleThumb(builder, grayScaleImageOffset);

                photoFingerPrintArray[photoFingerPrintCounter] = PhotoFingerPrint.EndPhotoFingerPrint(builder);
                photoFingerPrintCounter++;
            }

            return(photoFingerPrintArray);
        }