예제 #1
0
        public static void LoadImageDataset <T>(string path, out IEnumerable <Matrix <T> > images, out IEnumerable <IEnumerable <MModRect> > boxes)
            where T : struct
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (!File.Exists(path))
            {
                throw new FileNotFoundException("", path);
            }

            var str = Encoding.UTF8.GetBytes(path);

            using (var matrix = new Matrix <T>())
                using (var retImages = new VectorOfMatrix <T>())
                    using (var retBoxes = new VectorOfVectorMModRect())
                    {
                        var type = matrix.MatrixElementType.ToNativeMatrixElementType();
                        var ret  = Native.load_image_dataset(type, retImages.NativePtr, retBoxes.NativePtr, str);
                        if (ret == Native.ErrorType.ElementTypeNotSupport)
                        {
                            throw new ArgumentException($"{type} is not supported.");
                        }

                        images = retImages.ToArray();
                        boxes  = retBoxes.ToArray().Select(box => box.ToArray()).ToList();
                    }
        }
예제 #2
0
        public void CreateWithSize()
        {
            const int size   = 10;
            var       vector = new VectorOfVectorMModRect(size);

            this.DisposeAndCheckDisposedState(vector);
        }
예제 #3
0
        public void CreateWithCollection()
        {
            const int size   = 10;
            var       source = Enumerable.Range(0, size).Select(j => new List <MModRect>(Enumerable.Range(0, size).Select(i => new MModRect {
                Ignore = true, DetectionConfidence = i
            })));
            var vector = new VectorOfVectorMModRect(source);

            Assert.AreEqual(vector.Size, size);
            var ret = vector.ToArray();

            for (var j = 0; j < size; j++)
            {
                var tmp = ret[j].ToArray();
                for (var i = 0; i < size; i++)
                {
                    Assert.AreEqual(tmp[i].DetectionConfidence, i);
                    Assert.AreEqual(tmp[i].Ignore, true);
                }
            }
            this.DisposeAndCheckDisposedState(vector);
        }
예제 #4
0
        public void Create()
        {
            var vector = new VectorOfVectorMModRect();

            this.DisposeAndCheckDisposedState(vector);
        }