示例#1
0
        public RetagWindow()
        {
            Init();
            PngCodec.Register();
            JPEGCodec.Register();
            CreateDirectories();

            manager          = new ConfigurationManager();
            attentionHandler = new AttentionHandler()
            {
                ConfigurationManager = manager
            };
            retag = new Retagger()
            {
                ConfigurationManager = manager
            };
            analyser = new AttentionMapAnalizer()
            {
                ConfigurationManager = manager
            };

            manager.Init();
            analyser.Init();
            retag.Init();
            model = new DisplayModel(this);

            last = new PointF(-windowSize, -windowSize);
        }
示例#2
0
        public ShowWindow()
        {
            Init();
            PngCodec.Register();
            JPEGCodec.Register();

            var img = Program.file_in;

            var dataset = img?.Split("/")[0];
            var imgName = img?.Split("/")[1];

            var full_file_name_image = "data/" + dataset + "/images/" + imgName + ".jpg";
            var full_file_name_label = "data/" + dataset + "/labels/" + imgName + ".txt";

            image = Program.LoadFile_<Pixel>(full_file_name_image);

            var label = Program.LoadLabelEnd(full_file_name_label);
            label.Resize(image.Width, image.Height, 1, 1);

            Graphics<Pixel> g = Graphics<Pixel>.FromImage(image);
            var measure = g.MeasureString("1", BaseFonts.Premia, 3);
            foreach (var lbl in label.labels)
            {
               
                g.DrawRectangle(Pixels.White, lbl.box2d.x1 , lbl.box2d.y1 , lbl.box2d.width , lbl.box2d.height );
                g.DrawString(lbl.category, new FontSize(BaseFonts.Premia, 3), Pixels.White, new PointF(lbl.box2d.x1 , lbl.box2d.y1  - measure.Height));
            }
        }
示例#3
0
        public NewTagWindow()
        {
            CreateDirectories();

            Init();
            PngCodec.Register();
            JPEGCodec.Register();

            manager = new ConfigurationManager()
            {
                NeedLabel = false
            };
            attentionHandler = new AttentionHandler()
            {
                ConfigurationManager = manager, AllowWithoutLabel = true
            };
            tagger = new Tagger()
            {
                ConfigurationManager = manager
            };
            analyser = new AttentionMapAnalizer()
            {
                ConfigurationManager = manager
            };

            manager.Init();
            analyser.Init();
            model = new DisplayModelTagWindow(this);

            last = new PointF(-windowSize, -windowSize);
            buttonsPressed[1] = false;
            buttonsPressed[2] = false;
            buttonsPressed[3] = false;
        }
示例#4
0
        private BinaryBitmap GetImage(Stream mstream)
        {
            PngCodec.Register();
            JPEGCodec.Register();
            var          png     = new Hjg.Pngcs.Chunks.PngChunkIHDR(new Hjg.Pngcs.ImageInfo(10, 10, 8, true));
            BinaryBitmap bBitmap = null;

            try
            {
                using (Stream stream = mstream)
                {
                    stream.Position = 0;
                    Image <Pixel> result;

                    BitmapFactory factory = new BitmapFactory();
                    factory.AddCodec(new BitmapCodec());
                    factory.AddCodec(new PngCodec());
                    factory.AddCodec(new JPEGCodec());
                    factory.AddCodec(new TGACodec());
                    result = factory.Decode(stream);
                    result = result.GetBitmap(0, 0, result.Width, result.Height);

                    byte[] rgbBytes = GetRgbBytes(result);
                    var    bin      = new HybridBinarizer(new RGBLuminanceSource(rgbBytes, result.Width, result.Height));
                    Log.Logger.Debug("Memory:" + rgbBytes.Length);
                    Log.Logger.Debug("Size:" + (result.Width * result.Height) * 3);
                    bBitmap = new BinaryBitmap(bin);
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error(ex, "BarcodeDecoding.GetImage");
                Tools.Instance.Dialogs.CustomMessageBox.Show(ex.Message);
            }
            return(bBitmap);
        }