Esempio n. 1
0
        public void InitializeRender(EventType eventType, viz.Context context)
        {
            switch (eventType)
            {
            case EventType.Monitor:
                Debug.Assert(this.monitorData != null);
                break;

            case EventType.Inspection:
                Debug.Assert(this.inspectionData != null);

                if (this.inspectionData.sharedRawFrame != null)
                {
                    EventTypePluginData data = this.inspectionData;

                    RawIrPlugin.CreateTextures(this.inspectionData, 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);
                                }
                            }
                        }
                    }
                }
                break;
            }
        }
Esempio 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");
                    }
                }
            }
        }