private void UpdateRGBPose() { Thread.Sleep(0); while (IsRealsensePipelineOn) { var marix3DElement = RealsenseControl.GetPoseFrame(); if (marix3DElement != null) { IsT265TrackingConfidence3 = true; CurrentPose = new Matrix3D(marix3DElement[0], marix3DElement[1], marix3DElement[2], marix3DElement[3], marix3DElement[4], marix3DElement[5], marix3DElement[6], marix3DElement[7], marix3DElement[8], marix3DElement[9], marix3DElement[10], marix3DElement[11], marix3DElement[12], marix3DElement[13], marix3DElement[14], marix3DElement[15]); } else { IsT265TrackingConfidence3 = false; CurrentPose = new Matrix3D(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } Bitmap tempBitmap = new Bitmap(1, 1); RealsenseControl.GetRealTimeRGB(ref tempBitmap); //tempBitmap.Save("E:\\OneDrive - 한양대학교\\01.Hurel\\01.현재작업\\20201203 Comtpon GUI\\Compton GUI Main\\HUREL Compton\\RealsensWrapperTest\\bin\\Debug\\net5.0-windows\\test.png"); // Bitmap 담을 메모리스트림 if (tempBitmap == null || tempBitmap.Width == 1) { continue; } MemoryStream ms = new MemoryStream(); tempBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); BitmapImage img = new BitmapImage(); img.BeginInit(); ms.Seek(0, SeekOrigin.Begin); img.StreamSource = ms; img.CacheOption = BitmapCacheOption.OnLoad; img.EndInit(); img.Freeze(); //Debug.WriteLine("Img Update"); RealtimeRGB = img; tempBitmap.Dispose(); } }
private void UpdateRGBPose() { int tmpT265TrackingConfidence = 0; Thread.Sleep(0); while (IsRealsensePipelineOn) { var marix3DElement = RealsenseControl.GetPoseFrame(ref tmpT265TrackingConfidence); if (marix3DElement != null) { CurrentSystemTranformation = new Matrix3D(marix3DElement[0], marix3DElement[1], marix3DElement[2], marix3DElement[3], marix3DElement[4], marix3DElement[5], marix3DElement[6], marix3DElement[7], marix3DElement[8], marix3DElement[9], marix3DElement[10], marix3DElement[11], marix3DElement[12], marix3DElement[13], marix3DElement[14], marix3DElement[15]); } else { CurrentSystemTranformation = new Matrix3D(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } T265TrackingConfidence = tmpT265TrackingConfidence; if (tmpT265TrackingConfidence == 3) { IsT265TrackingConfidence3 = true; } else { IsT265TrackingConfidence3 = false; } Bitmap tempBitmap = new Bitmap(1, 1); int width = 1; int height = 1; int stride = 1; IntPtr data = IntPtr.Zero; RealsenseControl.GetRealTimeRGB(ref width, ref height, ref stride, ref data); //tempBitmap.Save("E:\\OneDrive - 한양대학교\\01.Hurel\\01.현재작업\\20201203 Comtpon GUI\\Compton GUI Main\\HUREL Compton\\RealsensWrapperTest\\bin\\Debug\\net5.0-windows\\test.png"); // Bitmap 담을 메모리스트림 if (data == IntPtr.Zero) { continue; } tempBitmap = new Bitmap(width, height, stride, System.Drawing.Imaging.PixelFormat.Format24bppRgb, data); //tempBitmap = new Bitmap(width, height, stride, System.Drawing.Imaging.PixelFormat.Format16bppGrayScale, data); //for (int x = 0; x < tempBitmap.Width; ++x) //{ // for (int y = 0; y < tempBitmap.Height; ++y) // { // System.Drawing.Color tmpColor = tempBitmap.GetPixel(x, y); // int brightness = (int)(0.299 * tmpColor.R + 0.587 * tmpColor.G + 0.114 * tmpColor.B); // System.Drawing.Color grey = System.Drawing.Color.FromArgb(brightness, brightness, brightness); // tempBitmap.SetPixel(x, y, grey); // } //} if (tempBitmap.Width == 1) { continue; } //to gray scale //tempBitmap = MakeGrayscale3(tempBitmap); MemoryStream ms = new MemoryStream(); //System.Windows.Forms.ToolStripRenderer.CreateDisabledImage(tempBitmap) tempBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); BitmapImage img = new BitmapImage(); img.BeginInit(); ms.Seek(0, SeekOrigin.Begin); img.StreamSource = ms; img.CacheOption = BitmapCacheOption.OnLoad; img.EndInit(); img.Freeze(); //Debug.WriteLine("Img Update"); RealtimeRGB = img; tempBitmap.Dispose(); } }