Ejemplo n.º 1
0
        public static Board ReadFromFrame(Image <Bgr, byte> frame, FilteringParameters filteringParameters)
        {
            Image <Gray, byte>[] filtered = new Image <Gray, byte> [4];
            DetectionData[]      dds      = new DetectionData[4];
            Board board;

            var hsvImg = frame.Convert <Hsv, byte>();

            for (int i = 0; i < 4; i++)
            {
                filtered[i] = ImageTools.FilterColor(hsvImg, filteringParameters.ColorsRanges[i]);
                dds[i]      = ImageTools.DetectSquares(filtered[i]);
                dds[i].RemoveNoises();
                filtered[i].Dispose();
            }
            ;

            dds[0].AddColor(dds[1]);
            dds[0].AddColor(dds[2]);
            dds[0].AddColor(dds[3]);
            board = dds[0].CreateBoard();
            if (board != null)
            {
                board.DetectRooms();
            }
            return(board);
        }
        public static Board ReadFromFrame(Image<Bgr, byte> frame, FilteringParameters filteringParameters)
        {
            Image<Gray, byte>[] filtered = new Image<Gray, byte>[4];
            DetectionData[] dds = new DetectionData[4];
            Board board;

            var hsvImg = frame.Convert<Hsv, byte>();

            for (int i = 0; i < 4; i++)
            {

                filtered[i] = ImageTools.FilterColor(hsvImg, filteringParameters.ColorsRanges[i]);
                dds[i] = ImageTools.DetectSquares(filtered[i]);
                dds[i].RemoveNoises();
                filtered[i].Dispose();
            };

            dds[0].AddColor(dds[1]);
            dds[0].AddColor(dds[2]);
            dds[0].AddColor(dds[3]);
            board = dds[0].CreateBoard();
            if (board!=null)
                board.DetectRooms();
            return board;
        }
 private void Awake()
 {
     filteringParameters = new FilteringParameters(new UnityAppSettingsManager());
     if (CamerasDetected())
     {
         capture = new Capture();
         newFrame = true;
         cameraTimer = new Timer(40);
         cameraTimer.Elapsed += new ElapsedEventHandler(OnCameraFrame);
         capture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FPS, 25);
         ChangeEditedRange(0);
     }
     else
     {
         NoCameraWarning.SetActive(true);
     }
 }