Beispiel #1
0
        public List <BBox> RunYoloList(BitmapData bitmap, bool swapRGB, bool runGPU)
        {
            if (!netBuilt)
            {
                throw new Exception("Net wasn't built yet");
            }
            List <BBox>   bboxVec       = new List <BBox>();
            IntPtr        msg           = new IntPtr();
            BBoxContainer bboxContainer = new BBoxContainer();
            int           detectNum     = 0;

            unsafe
            {
                if (_runYoloList(ref msg, (byte *)bitmap.Scan0, bitmap.Width, bitmap.Height, bitmap.Stride / bitmap.Width, ref bboxContainer, ref detectNum, swapRGB?1:0, runGPU?1:0) != 1)
                {
                    string mstr = Marshal.PtrToStringAnsi(msg);
                    throw new Exception(mstr);
                }
            }

            for (int i = 0; i < detectNum; i++)
            {
                bboxVec.Add(bboxContainer.boxes[i]);
            }

            return(bboxVec);
        }
Beispiel #2
0
        /// <summary>
        /// run yolo
        /// </summary>
        /// <param name="imagePath">image path</param>
        /// <param name="runGPU">run with GPU</param>
        /// <returns></returns>
        public List <BBox> RunYoloFile(string imagePath, bool runGPU)
        {
            List <BBox>   bboxVec       = new List <BBox>();
            IntPtr        msg           = new IntPtr();
            BBoxContainer bboxContainer = new BBoxContainer();
            int           detectNum     = 0;

            if (!netBuilt)
            {
                throw new Exception("Net wasn't built yet");
            }

            if (_runYoloFile(ref msg, imagePath, ref bboxContainer, ref detectNum, runGPU?1:0) != 1)
            {
                string mstr = Marshal.PtrToStringAnsi(msg);
                throw new Exception(mstr);
            }

            for (int i = 0; i < detectNum; i++)
            {
                bboxVec.Add(bboxContainer.boxes[i]);
            }

            return(bboxVec);
        }
Beispiel #3
0
 static unsafe extern int _runYoloList(ref IntPtr msg, byte *data, int width, int height, int channel, ref BBoxContainer bboxContainer, ref int detectedNum, int swapRGB, int runGPU);
Beispiel #4
0
 static extern int _runYoloFile(ref IntPtr msg, string imagePath, ref BBoxContainer bboxContainer, ref int detectedNum, int runGPU);