Esempio n. 1
0
 public ImageProcessor(Size ImageSize)
 {
     try
     {
         Factory = new DirectCanvasFactory();
         thresholdEffect = new ThresholdEffect(Factory);
         edgeEffect = new EdgeDetectEffect(Factory);
         unpackEffect = new UnpackDepthEffect(Factory);
         colorMapEffect = new ColorMapDepthEffect(Factory);
         InitLayers(ImageSize);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine("Exception initializing ImageProcessor: " + ex.ToString());
     }
 }
Esempio n. 2
0
        private void OnNewAllocatorSurfaceCallback(object sender, IntPtr pSurface, IntPtr sharedHandle, Misc.Size size)
        {
            /* Reset our fields */
            IsVideoReady = false;
            NaturalSize = new Size(0, 0);

            /* Free any resources that may be in use */
            if(m_internalBitmap != null)
            {
                m_internalBitmap.Dispose();
                m_internalBitmap = null;
            }

            if(m_sharedSurface != null)
            {
                m_sharedSurface.Dispose();
                m_sharedSurface = null;
            }

            Texture2D sharedTexture2D = null;
            var device = m_directCanvasFactory.DeviceContext.Device;

            if (sharedHandle == IntPtr.Zero)
                return;

            try
            {
                /* Open up the shared surface using the passed shared handle */
                sharedTexture2D = device.OpenSharedResource<Texture2D>(sharedHandle);
            }
            catch (Exception)
            {
            }
            
            if(sharedTexture2D == null)
            {
                return;
            }

            /* Wrap our Texture2D in our Texture class */
            m_sharedSurface = new Texture(sharedTexture2D);


            var props = new BitmapProperties();
            props.PixelFormat = new PixelFormat(Format.Unknown, 
                                                AlphaMode.Premultiplied);

            /* Create a Direct2D bitmap, using the shared surface provided by 
             * our custom allocator */
            m_internalBitmap = new Bitmap(ResourceOwner.InternalRenderTarget, 
                                          m_sharedSurface.InternalDxgiSurface, 
                                          props);

            NaturalSize = new Size(m_sharedSurface.Description.Width, 
                                   m_sharedSurface.Description.Height);
            IsVideoReady = true;
        }
Esempio n. 3
0
        public void InitLayers(Size ImageSize)
        {
            hoverBrush = Factory.CreateSolidColorBrush(new Color4(.4f, 0, 0, 0));
            contactBrush = Factory.CreateSolidColorBrush(new Color4(.8f, 0, 0, 0));

            DepthPresenter = new WPFPresenter(Factory, ImageSize.Width, ImageSize.Height);
            intermediateLayer = Factory.CreateDrawingLayer(ImageSize.Width, ImageSize.Height);
            rawDepthLayer = Factory.CreateDrawingLayer(ImageSize.Width, ImageSize.Height);

            DepthBrush = Factory.CreateDrawingLayerBrush(DepthPresenter);
            DepthBrush.Alignment = DirectCanvas.Brushes.BrushAlignment.DrawingLayerAbsolute;
        }
Esempio n. 4
0
 /// <summary>
 /// Fires the OnNewAllocatorSurface event, notifying the
 /// subscriber that new surfaces are available
 /// </summary>
 private void InvokeNewSurfaceEvent(IntPtr pSurface, IntPtr sharedHandle, Size size)
 {
     if (NewAllocatorSurface != null)
         NewAllocatorSurface(this, pSurface, sharedHandle, size);
 }