Esempio n. 1
0
        public void UpdateImage()
        {
            if (_camera.Handle != IntPtr.Zero)
            {
                if (!_camera.ShowImage)
                {
                    return;
                }

                //display useful information
                if (_camera.Annotate)
                {
                    PsMoveApi.psmove_tracker_annotate(_camera.Handle);
                }
                //retrieve and convert image frame
                Image <Bgr, Byte> img = GetImage();

                if (OnImageReady != null)
                {
                    OnImageReady(this, new OnImageReadyEventArgs(img));
                }

                if (_camera.Debug)
                {
                    DrawCubeToImage(img);
                    // draw center of image for calibration
                    img.Draw(new Rectangle(315, 235, 10, 10), new Bgr(0, 255, 0), 1);
                }

                BitmapSource bitmapSource = BitmapHelper.ToBitmapSource(img);
                //_camera.ImageSource = (BitmapSource) Emgu.CV.WPF.BitmapSourceConvert.ToBitmapSource(new Image<Bgr, byte>(rgb32Image.width, rgb32Image.height, rgb32Image.widthStep, rgb32Image.imageData)).GetAsFrozen();
                //display image
                //System.Drawing.Bitmap bitmap = MIplImagePointerToBitmap(rgb32Image);
                //BitmapSource bitmapSource = loadBitmap(bitmap);
                bitmapSource.Freeze();
                _camera.ImageSource = bitmapSource;
            }
        }