Beispiel #1
0
 /// <summary>
 /// Writes data to a file storage.
 /// </summary>
 /// <param name="val"></param>
 public FileStorage Add(Vec3i val)
 {
     ThrowIfDisposed();
     NativeMethods.core_FileStorage_shift_Vec3i(ptr, val);
     GC.KeepAlive(this);
     return(this);
 }
Beispiel #2
0
        /// <summary>
        /// Creates a proxy class of the specified Vec*b
        /// </summary>
        /// <param name="vec"></param>
        /// <returns></returns>
        public static InputArray Create(IVec vec)
        {
            if (vec == null)
            {
                throw new ArgumentNullException(nameof(vec));
            }

            return(vec switch
            {
                Vec2b v => new InputArray(new[] { v.Item0, v.Item1 }),
                Vec3b v => new InputArray(new[] { v.Item0, v.Item1, v.Item2 }),
                Vec4b v => new InputArray(new[] { v.Item0, v.Item1, v.Item2, v.Item3 }),
                Vec6b v => new InputArray(new[] { v.Item0, v.Item1, v.Item2, v.Item3, v.Item4, v.Item5 }),
                Vec2s v => new InputArray(new[] { v.Item0, v.Item1 }),
                Vec3s v => new InputArray(new[] { v.Item0, v.Item1, v.Item2 }),
                Vec4s v => new InputArray(new[] { v.Item0, v.Item1, v.Item2, v.Item3 }),
                Vec6s v => new InputArray(new[] { v.Item0, v.Item1, v.Item2, v.Item3, v.Item4, v.Item5 }),
                Vec2w v => new InputArray(new[] { v.Item0, v.Item1 }),
                Vec3w v => new InputArray(new[] { v.Item0, v.Item1, v.Item2 }),
                Vec4w v => new InputArray(new[] { v.Item0, v.Item1, v.Item2, v.Item3 }),
                Vec6w v => new InputArray(new[] { v.Item0, v.Item1, v.Item2, v.Item3, v.Item4, v.Item5 }),
                Vec2i v => new InputArray(new[] { v.Item0, v.Item1 }),
                Vec3i v => new InputArray(new[] { v.Item0, v.Item1, v.Item2 }),
                Vec4i v => new InputArray(new[] { v.Item0, v.Item1, v.Item2, v.Item3 }),
                Vec6i v => new InputArray(new[] { v.Item0, v.Item1, v.Item2, v.Item3, v.Item4, v.Item5 }),
                Vec2f v => new InputArray(new[] { v.Item0, v.Item1 }),
                Vec3f v => new InputArray(new[] { v.Item0, v.Item1, v.Item2 }),
                Vec4f v => new InputArray(new[] { v.Item0, v.Item1, v.Item2, v.Item3 }),
                Vec6f v => new InputArray(new[] { v.Item0, v.Item1, v.Item2, v.Item3, v.Item4, v.Item5 }),
                Vec2d v => new InputArray(new[] { v.Item0, v.Item1 }),
                Vec3d v => new InputArray(new[] { v.Item0, v.Item1, v.Item2 }),
                Vec4d v => new InputArray(new[] { v.Item0, v.Item1, v.Item2, v.Item3 }),
                Vec6d v => new InputArray(new[] { v.Item0, v.Item1, v.Item2, v.Item3, v.Item4, v.Item5 }),
                _ => throw new ArgumentException($"Not supported type: '{vec.GetType().Name}'", nameof(vec))
            });
Beispiel #3
0
        public void Start(cv.Mat color, cv.Mat result1, int filterSize, int levels)
        {
            int[] intensityBin = new int[levels];

            int filterOffset = (filterSize - 1) / 2;
            int currentIntensity = 0, maxIntensity = 0, maxIndex = 0;

            for (int offsetY = filterOffset; offsetY < color.Height - filterOffset; offsetY++)
            {
                for (int offsetX = filterOffset; offsetX < color.Width - filterOffset; offsetX++)
                {
                    maxIntensity = maxIndex = 0;

                    intensityBin = new int[levels];
                    cv.Vec3i[] bins = new cv.Vec3i[levels];

                    for (int y = offsetY - filterOffset; y < offsetY + filterOffset; y++)
                    {
                        for (int x = offsetX - filterOffset; x < offsetX + filterOffset; x++)
                        {
                            cv.Vec3b rgb = color.Get <cv.Vec3b>(y, x);
                            currentIntensity = (int)(Math.Round((Double)(rgb.Item0 + rgb.Item1 + rgb.Item2) / 3.0 * (levels - 1)) / 255.0);

                            intensityBin[currentIntensity] += 1;
                            bins[currentIntensity].Item0   += rgb.Item0;
                            bins[currentIntensity].Item1   += rgb.Item1;
                            bins[currentIntensity].Item2   += rgb.Item2;

                            if (intensityBin[currentIntensity] > maxIntensity)
                            {
                                maxIntensity = intensityBin[currentIntensity];
                                maxIndex     = currentIntensity;
                            }
                        }
                    }

                    if (maxIntensity == 0)
                    {
                        maxIntensity = 1;
                    }
                    double blue  = bins[maxIndex].Item0 / maxIntensity;
                    double green = bins[maxIndex].Item1 / maxIntensity;
                    double red   = bins[maxIndex].Item2 / maxIntensity;

                    result1.Set <cv.Vec3b>(offsetY, offsetX, new cv.Vec3b(ClipByte(blue), ClipByte(green), ClipByte(red)));
                }
            }
        }
Beispiel #4
0
 public static extern void core_Mat_push_back_Vec3i(IntPtr self, Vec3i v);
 public static extern ExceptionStatus core_FileNode_read_Vec3i(IntPtr node, out Vec3i returnValue);
Beispiel #6
0
 public static extern ExceptionStatus core_FileStorage_shift_Vec3i(IntPtr fs, Vec3i val);
 public static extern ExceptionStatus core_Mat_push_back_Vec3i(IntPtr self, Vec3i v);
 public static extern void core_FileStorage_shift_Vec3i(IntPtr fs, Vec3i val);
Beispiel #9
0
 public static void Run(IntPtr ptr, Vec3i v) => NativeMethods.core_Mat_push_back_Vec3i(ptr, v);
Beispiel #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(Vec3i other)
 {
     return(Item0 == other.Item0 && Item1 == other.Item1 && Item2 == other.Item2);
 }