private void handleImageCompletion(ref LEAP_IMAGE_COMPLETE_EVENT imageMsg) { if (_leapConnection == IntPtr.Zero) { return; } LEAP_IMAGE_PROPERTIES props = StructMarshal <LEAP_IMAGE_PROPERTIES> .PtrToStruct(imageMsg.properties); ImageFuture pendingImage = _pendingImageRequestList.FindAndRemove(imageMsg.token); if (pendingImage == null) { return; } //Update distortion data, if changed if ((_currentDistortionData.Version != imageMsg.matrix_version) || !_currentDistortionData.IsValid) { _currentDistortionData = new DistortionData(); _currentDistortionData.Version = imageMsg.matrix_version; _currentDistortionData.Width = LeapC.DistortionSize; //fixed value for now _currentDistortionData.Height = LeapC.DistortionSize; //fixed value for now if (_currentDistortionData.Data == null || _currentDistortionData.Data.Length != (2 * _currentDistortionData.Width * _currentDistortionData.Height * 2)) { _currentDistortionData.Data = new float[(int)(2 * _currentDistortionData.Width * _currentDistortionData.Height * 2)]; //2 float values per map point } LEAP_DISTORTION_MATRIX matrix = StructMarshal <LEAP_DISTORTION_MATRIX> .PtrToStruct(imageMsg.distortionMatrix); Array.Copy(matrix.matrix_data, _currentDistortionData.Data, matrix.matrix_data.Length); this.LeapDistortionChange.Dispatch <DistortionEventArgs>(this, new DistortionEventArgs(_currentDistortionData)); } pendingImage.imageData.CompleteImageData(props.type, props.format, props.bpp, props.width, props.height, imageMsg.info.timestamp, imageMsg.info.frame_id, props.x_offset, props.y_offset, props.x_scale, props.y_scale, _currentDistortionData, LeapC.DistortionSize, imageMsg.matrix_version); Image completedImage = pendingImage.imageObject; this.LeapImageReady.Dispatch <ImageEventArgs>(this, new ImageEventArgs(completedImage)); }
private void handleImageCompletion(ref LEAP_IMAGE_COMPLETE_EVENT imageMsg) { LEAP_IMAGE_PROPERTIES props = LeapC.PtrToStruct <LEAP_IMAGE_PROPERTIES>(imageMsg.properties); ImageReference pendingImage = null; lock (lockPendingImageList) { _pendingImageRequests.TryGetValue(imageMsg.token.requestID, out pendingImage); } if (pendingImage != null) { //Update distortion data, if changed if ((_currentDistortionData.Version != imageMsg.matrix_version) || !_currentDistortionData.IsValid) { _currentDistortionData = new DistortionData(); _currentDistortionData.Version = imageMsg.matrix_version; _currentDistortionData.Width = LeapC.DistortionSize; //fixed value for now _currentDistortionData.Height = LeapC.DistortionSize; //fixed value for now if (_currentDistortionData.Data == null || _currentDistortionData.Data.Length != (2 * _currentDistortionData.Width * _currentDistortionData.Height * 2)) { _currentDistortionData.Data = new float[(int)(2 * _currentDistortionData.Width * _currentDistortionData.Height * 2)]; //2 float values per map point } LEAP_DISTORTION_MATRIX matrix = LeapC.PtrToStruct <LEAP_DISTORTION_MATRIX>(imageMsg.distortionMatrix); Array.Copy(matrix.matrix_data, _currentDistortionData.Data, matrix.matrix_data.Length); this.LeapDistortionChange.Dispatch <DistortionEventArgs>(this, new DistortionEventArgs(_currentDistortionData)); } pendingImage.imageData.CompleteImageData(props.type, props.format, props.bpp, props.width, props.height, imageMsg.info.timestamp, imageMsg.info.frame_id, props.x_offset, props.y_offset, props.x_scale, props.y_scale, _currentDistortionData, LeapC.DistortionSize, imageMsg.matrix_version); Image completedImage = pendingImage.imageObject; lock (lockPendingImageList) { _pendingImageRequests.Remove(imageMsg.token.requestID); } this.LeapImageReady.Dispatch <ImageEventArgs>(this, new ImageEventArgs(completedImage)); } }