コード例 #1
0
 protected GridGenerator(
     ISegmentation segmentation,
     IShipRandomiser shipRandomiser,
     List <IShip> ships)
 {
     this.segmentation   = segmentation;
     this.shipRandomiser = shipRandomiser;
     this.ships          = ships;
 }
コード例 #2
0
 public GridGenerator(
     ISegmentation segmentation,
     IShipRandomiser shipRandomiser,
     IConsoleHelper consoleHelper,
     List <IShip> ships)
 {
     this.segmentation   = segmentation;
     this.consoleHelper  = consoleHelper;
     this.shipRandomiser = shipRandomiser;
     this.ships          = ships;
 }
コード例 #3
0
        public GridGeneratorTests()
        {
            PlayerStats   playerStats   = new PlayerStats();
            ConsoleHelper consoleHelper = ConsoleHelper.Instance(playerStats);

            ISegmentation segmentation = Segmentation.Instance();

            shipRandomiser = ShipRandomiser.Instance();

            gridGenerator = new GridGenerator(segmentation, shipRandomiser, consoleHelper, new List <IShip>());
        }
コード例 #4
0
        public static GridGenerator Instance()
        {
            if (instance == null)
            {
                lock (SyncObject)
                {
                    if (instance == null)
                    {
                        ISegmentation   segmentation   = Segmentation.Instance();
                        IShipRandomiser shipRandomiser = ShipRandomiser.Instance();
                        List <IShip>    ships          = new List <IShip>();
                        instance = new GridGenerator(segmentation, shipRandomiser, ships);
                    }
                }
            }

            return(instance);
        }
コード例 #5
0
        public Program()
        {
            // Game play objects
            List <IShip> ships = new List <IShip> {
                new BattleShip(1), new Destroyer(2), new Destroyer(3)
            };

            playerStats = new PlayerStats();

            // Not using a IoC framework (manual singletons), so it will just get new up a instance here,
            // and injected directly. Once we go out of scope here, allow the GC to clean up behind us
            ISegmentation   segmentation   = Segmentation.Instance();
            IShipRandomiser shipRandomiser = ShipRandomiser.Instance();

            consoleHelper = ConsoleHelper.Instance(playerStats);

            gridGenerator = new GridGenerator(segmentation, shipRandomiser, consoleHelper, ships);

            shipCounter = ships.Count;
            message     = consoleHelper.StartGameMessage;
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: xusiwen/Navigation
        //segment images using grabcut, mainly segment the bones
        private void segmentImages()
        {
            _segmentation = new GrabCutSegmentation();
            Pen    redPen = new Pen(Color.Red, 3);
            int    index  = 1;
            string imageLocation;

            while ((imageLocation = this._imageAssets.GetFirstAsset()) != string.Empty)
            {
                Image <Bgr, Byte> CTImage     = new Image <Bgr, byte>(imageLocation);
                Bitmap            bitmapImage = CTImage.ToBitmap();
                Bitmap            result      = _segmentation.Segment(bitmapImage, CTImage, _selectedRect);
                if (checkBitmap(result))
                {
                    _resultImages.Add(result);
                    this.pictureBoxCT.Image = result;
                    this.pictureBoxCT.Refresh();
                    System.Console.WriteLine(index++);
                    this._imageAssets.RemoveFirstAsset();
                    result.Save(imageLocation.Replace(".bmp", "new.bmp"));
                }
                else
                {
                    this.pictureBoxCT.ImageLocation = imageLocation;
                    this.pictureBoxCT.Load();
                    break;
                }
            }
            //index = 1;
            //foreach (Bitmap resultImage in resultImages)
            //{
            //    this.pictureBoxCT.Image = resultImage;
            //    this.pictureBoxCT.Refresh();
            //    _painter.DrawRectangle(redPen, _selectedSurfRect);
            //    MessageBox.Show("This the " + index + "result");
            //    index++;
            //}
            GC.Collect();
        }
コード例 #7
0
 public SegmentationTests()
 {
     shipRandomiser = ShipRandomiser.Instance();
     segmentation   = Segmentation.Instance();
 }
コード例 #8
0
ファイル: Form1.cs プロジェクト: hylhero/Navigation
 //segment images using grabcut, mainly segment the bones
 private void segmentImages()
 {
     _segmentation = new GrabCutSegmentation();
     Pen redPen = new Pen(Color.Red, 3);
     int index = 1;
     string imageLocation;
     while ((imageLocation = this._imageAssets.GetFirstAsset()) != string.Empty)
     {
         Image<Bgr, Byte> CTImage = new Image<Bgr, byte>(imageLocation);
         Bitmap bitmapImage = CTImage.ToBitmap();
         Bitmap result = _segmentation.Segment(bitmapImage, CTImage, _selectedRect);
         if (checkBitmap(result))
         {
             _resultImages.Add(result);
             this.pictureBoxCT.Image = result;
             this.pictureBoxCT.Refresh();
             System.Console.WriteLine(index++);
             this._imageAssets.RemoveFirstAsset();
             result.Save(imageLocation.Replace(".bmp", "new.bmp"));
         }
         else
         {
             this.pictureBoxCT.ImageLocation = imageLocation;
             this.pictureBoxCT.Load();
             break;
         }
     }
     //index = 1;
     //foreach (Bitmap resultImage in resultImages)
     //{
     //    this.pictureBoxCT.Image = resultImage;
     //    this.pictureBoxCT.Refresh();
     //    _painter.DrawRectangle(redPen, _selectedSurfRect);
     //    MessageBox.Show("This the " + index + "result");
     //    index++;
     //}
     GC.Collect();
 }
コード例 #9
0
 public SegmentationTests()
 {
     segmentation = Segmentation.Instance();
 }