Ejemplo n.º 1
0
        private void playbackVideoComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string videoFilename = playbackFileComboBox.SelectedItem.ToString();

                if (videoFilename.isVideoFile())
                {
                    depthReader = null;
                    loadVideo(videoFilename);

                    if (videoReader != null)
                    {
                        //endPoint = startPoint = new Point();
                        boundingBoxLocationMark = new RectangleLocationMark(-1, new RectangleF());
                        label3.Text = "Frame: " + frameTrackBar.Value;

                        Mat m = videoReader.getFrame(0);
                        if (m != null)
                        {
                            pictureBoard.mat = m;
                            pictureBoard.Image = pictureBoard.mat.Bitmap;
                        }

                        setLeftTopPanel();
                    }
                }

                if (videoFilename.isDepthFile())
                {
                    videoReader = null;
                    depthReader = currentSession.getDepth(videoFilename);

                    if (depthReader == null) return;

                    if (depthValuesToByte == null)
                    {
                        depthValuesToByte = new byte[depthReader.getWidth() * depthReader.getHeight() * 4];
                    }

                    if (depthBitmap == null)
                    {
                        depthBitmap = new Bitmap(depthReader.getWidth(), depthReader.getHeight(), PixelFormat.Format32bppRgb);
                    }

                    depthReader.readFrameAtTimeToBitmap(0, depthBitmap, depthValuesToByte, 8000.0f / 256);

                    if (depthBitmap != null)
                    {
                        pictureBoard.Image = depthBitmap;
                    }
                }

                frameTrackBar_ValueChanged(null, null);
            }
            catch (Exception exc)
            {
                Console.WriteLine("Select video file exception");
                MessageBox.Show("Exception in opening this file, please try another file", "File exception", MessageBoxButtons.OK);
            }
        }