Exemplo n.º 1
0
        private void UpdatePropertyView(double x, double y, uint width, uint height, EventTypePluginData data)
        {
            Debug.Assert(data != null);

            bool doEvent = false;

            lock (this.lockObj)
            {
                if (this.selectedData != data)
                {
                    doEvent           = true;
                    this.selectedData = data;
                }

                data.selected2DPixelX         = 0;
                data.selected2DPixelY         = 0;
                data.selected2DPixelIntensity = 0;
                data.selected2DPixelDepth     = 0;

                if (width == data.imageWidth)
                {
                    data.selected2DPixelX = (uint)x;
                }
                else
                {
                    data.selected2DPixelX = (uint)((x / width) * data.imageWidth);
                }

                if (height == data.imageHeight)
                {
                    data.selected2DPixelY = (uint)y;
                }
                else
                {
                    data.selected2DPixelY = (uint)((y / height) * data.imageHeight);
                }

                RawIrPlugin.UpdateSelectedPixelValue(data);
            }

            this.RaisePropertyChanged("Selected2DPixelX");
            this.RaisePropertyChanged("Selected2DPixelY");
            this.RaisePropertyChanged("Selected2DPixelIrIntensity");
            this.RaisePropertyChanged("Selected2DPixelDepth");

            if (doEvent)
            {
                this.RaisePropertyChanged("HasSelected2DPixelData");
            }
        }
Exemplo n.º 2
0
        private void HandleEvent(EventType eventType, KStudioEvent eventObj, EventTypePluginData data)
        {
            Debug.Assert(data != null);

            if (eventObj != null)
            {
                bool doDataEvent    = false;
                bool doVisibleEvent = false;

                if (eventObj.EventStreamDataTypeId == KStudioEventStreamDataTypeIds.RawIr)
                {
                    lock (this.lockObj)
                    {
                        bool isSelectedData = (this.selectedData == data);

                        HGlobalBuffer newSharedFrame = eventObj.GetRetainableEventDataBuffer();
                        doVisibleEvent      = isSelectedData && (newSharedFrame == null) != (data.sharedRawFrame == null);
                        data.sharedRawFrame = newSharedFrame;

                        uint newWidth  = nui.Constants.STREAM_IR_WIDTH;
                        uint newHeight = nui.Constants.STREAM_IR_HEIGHT;

                        if ((data.rawIrTexture == null) || (newWidth != data.imageWidth) || (newHeight != data.imageHeight))
                        {
                            data.imageWidth  = newWidth;
                            data.imageHeight = newHeight;

                            viz.Context context = null;

                            if (this.pluginService != null)
                            {
                                context = this.pluginService.GetContext(eventType);
                            }

                            RawIrPlugin.CreateTextures(data, context);
                        }

                        DepthIrEngine depthIrEngine = this.pluginService.DepthIrEngine;

                        if ((depthIrEngine != null) && (data.depthFrame != null) && (data.irFrame != null))
                        {
                            unsafe
                            {
                                fixed(ushort *pDepthFrame = &data.depthFrame[0], pIrFrame = &data.irFrame[0])
                                {
                                    depthIrEngine.HandleEvent(data.sharedRawFrame.Buffer, data.sharedRawFrame.Size, pDepthFrame, pIrFrame, data.imageWidth, data.imageHeight);

                                    uint imageDataSize = data.imageWidth * data.imageHeight * sizeof(ushort);

                                    if (data.rawIrTexture != null)
                                    {
                                        data.rawIrTexture.UpdateData((byte *)pIrFrame, imageDataSize);
                                    }

                                    if (data.depthMap != null)
                                    {
                                        data.depthMap.UpdateData(pDepthFrame, imageDataSize);
                                    }
                                }
                            }
                        }

                        if (RawIrPlugin.UpdateSelectedPixelValue(data))
                        {
                            doDataEvent = isSelectedData;
                        }
                    }

                    if (doVisibleEvent)
                    {
                        this.RaisePropertyChanged("HasSelected2DPixelData");
                    }

                    if (doDataEvent)
                    {
                        this.RaisePropertyChanged("Selected2DPixelIrIntensity");
                        this.RaisePropertyChanged("Selected2DPixelDepth");
                    }
                }
            }
        }