Ejemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     freeSpaceManager = GameObject.Find("GlobalManagers").GetComponent <FreeSpaceManager>();
     currentStep      = -1;
     NextStep();
     levelSettings = GameObject.Find("LevelSettings").GetComponent <LevelSettings>();
 }
Ejemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        if (!Application.isPlaying)
        {
            return;
        }
        FreeSpaceManager myScript = (FreeSpaceManager)target;

        if (GUILayout.Button("Spawn single box"))
        {
            myScript.SpawnBox(Box.BoxType.Single, Random.Range(0, 10));
        }

        if (GUILayout.Button("Spawn double box"))
        {
            myScript.SpawnBox(Box.BoxType.Double, Random.Range(0, 10));
        }

        if (GUILayout.Button("Spawn quad box"))
        {
            myScript.SpawnBox(Box.BoxType.Quad, Random.Range(0, 10));
        }
    }
Ejemplo n.º 3
0
        public void ProcessBoxProjection(Image <Bgra, byte> pColorBitSource)
        {
            if (SettingsManager.Instance.Settings.CheckBoxStartProjection == false)
            {
                return;
            }

            Image <Gray, Int32> depthImg = KinectManager.Instance.GetCurrentDepthImageCropped();

            int[,] map = new int[SettingsManager.Instance.Settings.IntegerUpDownXBox, SettingsManager.Instance.Settings.IntegerUpDownYBox];
            BlobManager.Instance.MasterBlob = BlobManager.FindAllBlob(
                depthImg,
                BlobManager.Instance.MasterBlob,
                pColorBitSource,
                SettingsManager.Instance.Settings.BlobRadio);
            Image <Bgra, byte> outputImage = depthImg.Convert <Bgra, byte>();
            Tuple <RectangleF, System.Windows.Media.Color>             outputFree     = new Tuple <RectangleF, System.Windows.Media.Color>(new RectangleF(), new System.Windows.Media.Color());
            List <Tuple <PointF[], System.Windows.Media.Color> >       outputBoxPoint = new List <Tuple <PointF[], System.Windows.Media.Color> >();
            List <Tuple <PointF, String, System.Windows.Media.Color> > outputString   = new List <Tuple <PointF, String, System.Windows.Media.Color> >();

            Bgra color = new Bgra(0, 255, 0, 0);

            if (BlobManager.Instance.MasterBlob != null)
            {
                for (int i = 0; i < BlobManager.Instance.MasterBlob.Count; i++)
                {
                    BlobObject currentBlob = BlobManager.Instance.MasterBlob[i];
                    //currentBlob.Id == 0;

                    if (m_Free_Checked)
                    {
                        map = FreeSpaceManager.RenderObject(currentBlob.CornerPoints, map, depthImg.Width, depthImg.Height);
                    }

                    // map_check fliegt raus
                    if (m_Map_Checked)
                    {
                        if (BlobManager.Instance.MasterBlob[i].Hits == 0)
                        {
                            int count;
                            count = UtilitiesImage.FeaturePerObject(pColorBitSource, BlobManager.Instance.MasterBlob[i].Rect);

                            BlobManager.Instance.MasterBlob[i].Hits = count;
                        }
                        color = UtilitiesImage.MappingColor(BlobManager.Instance.MasterBlob[i].Hits);
                    }

                    if (m_Tracking_Checked)
                    {
                        System.Drawing.Point center = new System.Drawing.Point((int)(currentBlob.Center.X * depthImg.Width), (int)(currentBlob.Center.Y * depthImg.Height));
                        //outputImage.Draw(currentBlob.Name.ToString(), ref m_Font, center, new Bgr(System.Drawing.Color.Red));
                        outputString.Add(new Tuple <PointF, String, System.Windows.Media.Color>(currentBlob.Center, currentBlob.Name.ToString(), System.Windows.Media.Color.FromRgb(0, 255, 0)));
                    }

                    List <LineSegment2DF> depthboxLines = UtilitiesImage.PointsToImageLine(currentBlob.CornerPoints, depthImg.Width, depthImg.Height);
                    foreach (LineSegment2DF line in depthboxLines)
                    {
                        outputImage.Draw(line, color, 2);
                    }

                    PointF[] corner = new PointF[4];
                    for (int cur = 0; cur < 4; cur++)
                    {
                        corner[cur] = new PointF(BlobManager.Instance.MasterBlob[i].CornerPoints[cur].X, 1 - BlobManager.Instance.MasterBlob[i].CornerPoints[cur].Y);
                    }

                    outputBoxPoint.Add(new Tuple <PointF[], System.Windows.Media.Color>(corner, System.Windows.Media.Color.FromRgb((byte)color.Red, (byte)color.Green, (byte)color.Blue)));
                }
            }

            // update the reference
            ObjectDetectionManager.Instance.MasterBlob = BlobManager.Instance.MasterBlob;

            RectangleF freeSpace = new RectangleF();

            if (m_Free_Checked)
            {
                depthImg  = FreeSpaceManager.DrawMaxSubmatrix(depthImg.Convert <Bgra, byte>(), map).Convert <Gray, Int32>();
                freeSpace = FreeSpaceManager.DrawMaxSubmatrix(map, (float)(depthImg.Width / (float)SettingsManager.Instance.Settings.IntegerUpDownXBox / depthImg.Width),
                                                              (float)(depthImg.Height / (float)SettingsManager.Instance.Settings.IntegerUpDownYBox / depthImg.Height));
            }

            //draw on table
            # region projection
            if (SettingsManager.Instance.Settings.CheckBoxStartProjection)