Example #1
0
        public KinectBO(System.Windows.Forms.Control myParentControl, System.Windows.Forms.PictureBox myPictureBoxColor, System.Windows.Forms.PictureBox myPictureBoxDepth, System.Windows.Forms.PictureBox mypictureBoxIR, OGLControl myOpenGLControl,
                        System.Windows.Forms.PictureBox mypictureBoxEntropy, System.Windows.Forms.PictureBox mypictureBoxPolygon,
                        System.Windows.Forms.Label mycameraFpsLabel, Label mylabelRefreshRateOpenGL, Label mylabelDepth1) : this()
        {
            openGLPart = new OpenGLPart(this, myParentControl, myOpenGLControl);

            parent                 = myParentControl;
            pictureBoxDepth        = myPictureBoxDepth;
            pictureBoxColor        = myPictureBoxColor;
            pictureBoxIR           = mypictureBoxIR;
            cameraFpsLabel         = mycameraFpsLabel;
            openGLControl          = myOpenGLControl;
            this.pictureBoxEntropy = mypictureBoxEntropy;
            this.pictureBoxPolygon = mypictureBoxPolygon;

            labelFramesPerSecond   = mycameraFpsLabel;
            labelRefreshRateOpenGL = mylabelRefreshRateOpenGL;
            labelDepth1            = mylabelDepth1;

            InitPictureBoxesForUI();
            //try
            //{

            //}
            //catch (Exception err)
            //{
            //    System.Windows.Forms.MessageBox.Show("SW Error initializing Scanner : " + err.Message);
            //}
            this.ellipseFace = new Ellipse(faceX, faceY, 0.6f);
        }
Example #2
0
        public RealsenseBO(System.Windows.Forms.Control myParentControl, System.Windows.Forms.PictureBox myPictureBoxColor, System.Windows.Forms.PictureBox myPictureBoxDepth, System.Windows.Forms.PictureBox mypictureBoxIR, OGLControl myOpenGLControl,
                           System.Windows.Forms.Label mycameraFpsLabel) : this()
        {
            parentControl = myParentControl;
            openGLPart    = new OpenGLPart(this, myParentControl, myOpenGLControl);
            DepthMetaData = new DepthMetaData();
            PathModels    = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + GLSettings.PathPointClouds;


            try
            {
                pictureBoxDepth = myPictureBoxDepth;
                pictureBoxColor = myPictureBoxColor;
                pictureBoxIR    = mypictureBoxIR;
                cameraFpsLabel  = mycameraFpsLabel;
                openGLControl   = myOpenGLControl;


                GetRealSenseCameras(out DevicesDepth, out DevicesColor, out videoDevices);
                NumberOfDevices = DevicesDepth.Count;


                SetConversionMatrices();
            }
            catch (Exception err)
            {
                System.Windows.Forms.MessageBox.Show("SW Error initializing Scanner : " + err.Message);
            }
        }
Example #3
0
 public OpenGLPart(IScanner myparentScanner, Control myparentControl, OGLControl myopenGLControl)
 {
     parentScanner = myparentScanner;
     parentControl = myparentControl;
     openGLControl = myopenGLControl;
 }
Example #4
0
        private void lvFiles_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvFiles.SelectedItems.Count <= 0)
            {
                pbPreview.Width    = 0;
                pbPreview.Visible  = false;
                rtbPreview.Width   = 0;
                rtbPreview.Visible = false;
                splitContainer.SplitterDistance = this.Width;

                lbSelection.Text = String.Empty;

                return;
            }

            if (File.Exists(currentMeshFile))
            {
                File.Delete(currentMeshFile);
            }

            if (File.Exists(currentMeshFile + ".mtl"))
            {
                File.Delete(currentMeshFile + ".mtl");
            }

            if (glControl != null)
            {
                if (glControl.GLrender != null)
                {
                    glControl.GLrender.ClearAllObjects();
                    glControl.GLrender.GLControlInstance.Dispose();
                }
                glControl.Dispose();
            }

            ListViewItem Item = lvFiles.SelectedItems[0];

            lbSelection.Text = String.Format("Sel {0}", Item.Index + 1);

            ImageListIndex indx = FileType.GetImageIndex(Path.GetExtension(Item.Text));

            if (indx == ImageListIndex.Image)
            {
                pbPreview.Width    = 399;
                pbPreview.Visible  = true;
                rtbPreview.Width   = 0;
                rtbPreview.Visible = false;
                pnlPreview.Visible = false;

                ArchiveEntry ent = m_Archive.getByName(Path.GetFileNameWithoutExtension(Item.Text));
                Image        img = null;

                using (MemoryStream ms = new MemoryStream(ent.getData()))
                {
                    try
                    {
                        if (Path.GetExtension(Item.Text) == ".tga")
                        {
                            TargaImage tgaImg = new TargaImage(ms);
                            img = tgaImg.Image;
                        }
                        else
                        {
                            img = Image.FromStream(ms);
                        }
                    }
                    catch
                    { }
                }

                if (img != null)
                {
                    pbPreview.Image    = img;
                    pbPreview.Width    = img.Width;
                    pbPreview.Location = new Point(pbPreview.Location.X, (this.Height / 2) - (img.Height / 2) - 20);
                    splitContainer.SplitterDistance = Math.Max(this.Width - img.Width - 20, 200);
                }
            }
            else if (indx == ImageListIndex.Text)
            {
                pbPreview.Width    = 0;
                pbPreview.Visible  = false;
                rtbPreview.Width   = 500;
                rtbPreview.Visible = true;
                pnlPreview.Visible = false;
                splitContainer.SplitterDistance = this.Width - 500;

                rtbPreview.Text = "";

                ArchiveEntry ent = m_Archive.getByName(Path.GetFileNameWithoutExtension(Item.Text));
                if (ent != null)
                {
                    rtbPreview.Text = Encoding.Default.GetString(ent.getData());
                }
            }
            else if (indx == ImageListIndex.Mesh)
            {
                pnlPreview.Visible = true;
                splitContainer.SplitterDistance = this.Width - 500;

                glControl        = new OGLControl();
                glControl.Parent = pnlPreview;
                glControl.Dock   = DockStyle.Fill;
                glContext        = new OpenGLContext(glControl);
                glControl.GLrender.PrimitiveTypes = OpenTK.Graphics.OpenGL.PrimitiveType.Triangles;
                glControl.GLrender.Camera.ZNear   = 0.01f;
                glControl.GLrender.Camera.ZFar    = float.MaxValue;

                string tempFile = Path.GetTempFileName();
                currentMeshFile = Path.ChangeExtension(Path.GetTempFileName(), "obj");
                ArchiveEntry ent = m_Archive.getByName(Path.GetFileNameWithoutExtension(Item.Text));
                ent.extractTo(tempFile, true);

                using (AssimpContext context = new AssimpContext())
                {
                    Scene mesh = context.ImportFile(tempFile);
                    context.ExportFile(mesh, currentMeshFile, "obj");
                }
                File.Delete(tempFile);

                Model model = new Model(currentMeshFile);

                glControl.GLrender.AddModel(model);
                glControl.GLrender.SelectedModelIndex = 0;
            }
            else
            {
                pbPreview.Width    = 0;
                pbPreview.Visible  = false;
                rtbPreview.Width   = 0;
                rtbPreview.Visible = false;
                pnlPreview.Visible = false;
            }
        }