public void set_detect_images(List <Bitmap> bitmap_list)
        {
            // transform images
            BatchAidiImage aidi_images = new BatchAidiImage();

            //AidiImage image_t = new AidiImage();
            //image_t.read_image("D:/aidi_benchmark/location_sample_mobilephone/Location_0/source/1.bmp");
            for (int i = 0; i < bitmap_list.Count; i++)
            {
                Bitmap current_bitmap = bitmap_list[i];

                AidiImage image          = new AidiImage();
                string    bit_number     = current_bitmap.PixelFormat.ToString();
                int       channel_number = 1;
                if (bit_number.Contains("24")) // 24位即为3通道,8位为1通道
                {
                    channel_number = 3;
                }
                else
                {
                    channel_number = 1;
                }
                int      stride;
                DateTime dt1             = System.DateTime.Now;
                byte[]   transform_image = GetBGRValues(bitmap_list[i], out stride);
                image.char_ptr_to_mat(transform_image, current_bitmap.Height, current_bitmap.Width, channel_number);
                aidi_images.add_image(image);
                DateTime dt2 = System.DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt1);
                Console.WriteLine("wrap image time time {0}", ts.TotalMilliseconds);
                Console.WriteLine(aidi_images.get_images_size());
            }
            aidi_.set_test_batch_image(aidi_images);
        }
Example #2
0
 public void set_test_data(AidiImage test_source_image)
 {
     csharpaidiclientPINVOKE.AidiLocation_set_test_data(swigCPtr, AidiImage.getCPtr(test_source_image));
     if (csharpaidiclientPINVOKE.SWIGPendingException.Pending)
     {
         throw csharpaidiclientPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public void add_image(AidiImage image)
 {
     csharpaidiclientPINVOKE.BatchAidiImage_add_image(swigCPtr, AidiImage.getCPtr(image));
     if (csharpaidiclientPINVOKE.SWIGPendingException.Pending)
     {
         throw csharpaidiclientPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #4
0
        public AidiImage start_test(AidiImage source_image)
        {
            AidiImage ret = new AidiImage(csharpaidiclientPINVOKE.AidiSegment_start_test__SWIG_0(swigCPtr, AidiImage.getCPtr(source_image)), true);

            if (csharpaidiclientPINVOKE.SWIGPendingException.Pending)
            {
                throw csharpaidiclientPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public string entrance_test_image(AidiImage image)
        {
            string ret = csharpaidiclientPINVOKE.AIDIEntrance_entrance_test_image(swigCPtr, AidiImage.getCPtr(image));

            if (csharpaidiclientPINVOKE.SWIGPendingException.Pending)
            {
                throw csharpaidiclientPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #6
0
        public string start_test(AidiImage image)
        {
            string ret = csharpaidiclientPINVOKE.AIDI_start_test__SWIG_0(swigCPtr, AidiImage.getCPtr(image));

            if (csharpaidiclientPINVOKE.SWIGPendingException.Pending)
            {
                throw csharpaidiclientPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public int start_test(AidiImage image)
        {
            int ret = csharpaidiclientPINVOKE.AidiClassify_start_test(swigCPtr, AidiImage.getCPtr(image));

            if (csharpaidiclientPINVOKE.SWIGPendingException.Pending)
            {
                throw csharpaidiclientPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public List <string> Run(List <Bitmap> bitmap_list)
        {
            if (!is_ready)
            {
                throw new Exception("模型未初始化");
            }
            List <string> result_list = new List <string>();
            // transform images
            BatchAidiImage aidi_images = new BatchAidiImage();

            //AidiImage image_t = new AidiImage();
            //image_t.read_image("D:/aidi_benchmark/location_sample_mobilephone/Location_0/source/1.bmp");
            for (int i = 0; i < bitmap_list.Count; i++)
            {
                Bitmap    current_bitmap = bitmap_list[i];
                AidiImage image          = new AidiImage();
                string    bit_number     = current_bitmap.PixelFormat.ToString();
                int       channel_number = 1;
                if (bit_number.Contains("24")) //24位即为3通道,8位为1通道
                {
                    channel_number = 3;
                }
                else
                {
                    channel_number = 1;
                }
                int      stride;
                DateTime dt1             = System.DateTime.Now;
                byte[]   transform_image = GetBGRValues(bitmap_list[i], out stride);
                image.char_ptr_to_mat(transform_image, current_bitmap.Height, current_bitmap.Width, channel_number);
                aidi_images.add_image(image);
                DateTime dt2 = System.DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt1);
                Console.WriteLine("wrap image time time {0}", ts.TotalMilliseconds);
                Console.WriteLine(aidi_images.get_images_size());
            }
            aidi_.set_test_batch_image(aidi_images);
            StringVector results = aidi_.get_detect_result();

            //image_t.draw_result(results[0]);
            //image_t.show_image(0);
            for (int i = 0; i < results.Count; i++)
            {
                result_list.Add(results[i]);
            }
            //string result = aidi_.start_test(image_t);
            //result_list.Add(result);

            return(result_list);
        }
        /// <summary>
        /// 将单张图片灌入Aidi对象
        /// </summary>
        /// <param name="bitmap"></param>
        /// <returns></returns>
        public BatchAidiImage GetBatch_images(Bitmap bitmap)
        {
            BatchAidiImage batch_images = new BatchAidiImage();
            int            channelNum   = Image.GetPixelFormatSize(bitmap.PixelFormat) / 8;//判断8位、24位、32位
            int            stride;

            byte[] data = GetBGRValues(bitmap, out stride);
            //转换图片格式,供aidi使用
            AidiImage image = new AidiImage();

            image.char_ptr_to_mat(data, bitmap.Height, bitmap.Width, channelNum);
            batch_images.add_image(image);
            return(batch_images);
        }
        /// <summary>
        /// 将批量图片灌入Aidi对象
        /// </summary>
        /// <param name="bitmaps"></param>
        /// <returns></returns>
        public BatchAidiImage GetBatch_images(List <Bitmap> bitmaps)
        {
            BatchAidiImage batch_images = new BatchAidiImage();

            int _count = bitmaps.Count;

            for (int i = 0; i < _count; i++)
            {
                int channelNum = Image.GetPixelFormatSize(bitmaps[i].PixelFormat) / 8;//判断8位、24位、32位

                int    stride;
                byte[] data = GetBGRValues(bitmaps[i], out stride);
                //转换图片格式,供aidi使用
                AidiImage image = new AidiImage();

                image.char_ptr_to_mat(data, bitmaps[i].Height, bitmaps[i].Width, channelNum);
                batch_images.add_image(image);
            }
            return(batch_images);
        }
Example #11
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(AidiImage obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
        public AidiImage at(int index)
        {
            AidiImage ret = new AidiImage(csharpaidiclientPINVOKE.BatchAidiImage_at(swigCPtr, index), true);

            return(ret);
        }