protected override void OnStartStreaming(PipelineProfile activeProfile) { InitializePostProcessingFilter(); aligner = new Align(alignTo); StreamProfile profile = null; for (int i = 0; i < activeProfile.Streams.Count; i++) { if (activeProfile.Streams[i].Stream == alignTo) { profile = activeProfile.Streams[i]; } } if (profile == null) { Debug.LogWarningFormat("Stream {0} not in active profile", sourceStreamType); return; } var videoProfile = profile as VideoStreamProfile; //Decimation = 2 texture = new Texture2D(videoProfile.Width / decimationAmount, videoProfile.Height / decimationAmount, textureFormat, false, true) { wrapMode = TextureWrapMode.Clamp, filterMode = filterMode }; texture.Apply(); textureBinding.Invoke(texture); realSenseDevice.onNewSampleSet += OnFrameSet; }
/// <summary> /// 開啟RealSense相機並進行取像 /// </summary> internal void Open(out Image <Bgr, byte> ColorImg, out Image <Rgb, byte> DepthImg, out Image <Rgb, byte> FilteredImg, out VideoFrame color, out DepthFrame depth, out Frame filtered) { DepthImg = null; ColorImg = null; FilteredImg = null; color = null; depth = null; filtered = null; if (CamState != CameraState.Opened) { PipelineProfile = Camera.Start(cfg); // 以cfg設定並開始串流 vsp = PipelineProfile.GetStream <VideoStreamProfile>(Intel.RealSense.Stream.Depth); // 取得內部參數 intrinsics = vsp.GetIntrinsics(); sp = PipelineProfile.GetStream(Intel.RealSense.Stream.Color); // 取得外部參數 extrinsics = vsp.GetExtrinsicsTo(sp); CamState = CameraState.Opened; // 更新相機狀態 } else { try { FrameSet frames = Camera.WaitForFrames(); depth = frames.DepthFrame.DisposeWith(frames); color = frames.ColorFrame.DisposeWith(frames); filtered = depth; if (depth != null) { //Thres_Filter.Options[Option.MinDistance].Value = float.Parse(form1.textBox2.Text); //Thres_Filter.Options[Option.MaxDistance].Value = float.Parse(form1.textBox1.Text); //filtered = Thres_Filter.Process(filtered); //Spa_Filter.Options[Option.FilterMagnitude].Value = 1; //Spa_Filter.Options[Option.FilterSmoothAlpha].Value = 0.6f; //Spa_Filter.Options[Option.FilterSmoothDelta].Value = 8; //filtered = Spa_Filter.Process(filtered); Temp_Filter.Options[Option.FilterSmoothAlpha].Value = 0.5f; Temp_Filter.Options[Option.FilterSmoothDelta].Value = 20; Temp_Filter.Options[Option.HolesFill].Value = 2; filtered = Temp_Filter.Process(filtered); depColor = colorizer.Colorize(depth); filteredColor = colorizer.Colorize(filtered); ColorImg = new Image <Bgr, byte>(color.Width, color.Height, color.Stride, color.Data); DepthImg = new Image <Rgb, byte>(depColor.Width, depColor.Height, depColor.Stride, depColor.Data); FilteredImg = new Image <Rgb, byte>(filteredColor.Width, filteredColor.Height, filteredColor.Stride, filteredColor.Data); } } catch (Exception ex) { throw ex; } } }
public static RsVideoStreamRequest FromProfile(StreamProfile p) { return(new RsVideoStreamRequest( p.Stream, p.Format, p.Framerate, p.Index, p is VideoStreamProfile ? (p as VideoStreamProfile).Width : 0, p is VideoStreamProfile ? (p as VideoStreamProfile).Height : 0 )); }
public static RsVideoStreamRequest FromProfile(StreamProfile p) { var isVideo = p.Is(Extension.VideoProfile); using (p) using (var v = isVideo ? p.As <VideoStreamProfile>() : null) return(new RsVideoStreamRequest( p.Stream, p.Format, p.Framerate, p.Index, isVideo ? v.Width : 0, isVideo ? v.Height : 0 )); }
/// <summary> /// Creates a new coordinate mapper for the specified pipeline. /// </summary> /// <param name="pipeline">The specified pipeline.</param> /// <param name="colorWidth">The desired color frame width.</param> /// <param name="colorHeight">The desired color frame height.</param> /// <param name="depthWidth">The desired depth frame width.</param> /// <param name="depthHeight">The desired depth frame height.</param> /// <returns>The color/depth coordinate mapper of the current pipline, if all of the supported streams were found. Null otherwise.</returns> public static CoordinateMapper Create(PipelineProfile pipeline, int colorWidth, int colorHeight, int depthWidth, int depthHeight) { if (pipeline == null) { return(null); } if (pipeline.Streams == null) { return(null); } if (pipeline.Streams.Count == 0) { return(null); } StreamProfile colorProfile = null; StreamProfile depthProfile = null; foreach (StreamProfile profile in pipeline.Streams) { VideoStreamProfile videoProfile = profile as VideoStreamProfile; if (profile.Stream == Stream.Color && videoProfile.Width == colorWidth && videoProfile.Height == colorHeight) { colorProfile = profile; } else if (profile.Stream == Stream.Depth && videoProfile.Width == depthWidth && videoProfile.Height == depthHeight) { depthProfile = profile; } } if (colorProfile == null) { return(null); } if (depthProfile == null) { return(null); } Intrinsics colorIntrinsics = (colorProfile as VideoStreamProfile).GetIntrinsics(); Extrinsics colorExtrinsics = colorProfile.GetExtrinsicsTo(depthProfile); Intrinsics depthIntrinsics = (depthProfile as VideoStreamProfile).GetIntrinsics(); Extrinsics depthExtrinsics = depthProfile.GetExtrinsicsTo(colorProfile); return(Create(colorIntrinsics, colorExtrinsics, depthIntrinsics, depthExtrinsics)); }
internal StreamProfile[] ToStreamProfileArray() { StreamProfile[] streams = new StreamProfile[PXCMCapture.STREAM_LIMIT]; streams[0] = color; streams[1] = depth; streams[2] = ir; streams[3] = left; streams[4] = right; streams[5] = reserved1; streams[6] = reserved2; streams[7] = reserved3; return streams; }
internal StreamProfileSet(StreamProfile[] streams) { color = streams[0]; depth = streams[1]; ir = streams[2]; left = streams[3]; right = streams[4]; reserved1 = streams[5]; reserved2 = streams[6]; reserved3 = streams[7]; }
public StreamProfileSet() { color = new StreamProfile(); depth = new StreamProfile(); ir = new StreamProfile(); left = new StreamProfile(); right = new StreamProfile(); reserved1 = new StreamProfile(); reserved2 = new StreamProfile(); reserved3 = new StreamProfile(); }
/** @brief Access the configuration parameters by the stream type. @param[in] type The stream type. @return The StreamProfile instance. */ public StreamProfile this[StreamType type] { get { if (type == StreamType.STREAM_TYPE_COLOR) return color; if (type == StreamType.STREAM_TYPE_DEPTH) return depth; if (type == StreamType.STREAM_TYPE_IR) return ir; if (type == StreamType.STREAM_TYPE_LEFT) return left; if (type == StreamType.STREAM_TYPE_RIGHT) return right; if (type == StreamTypeFromIndex(5)) return reserved1; if (type == StreamTypeFromIndex(6)) return reserved2; if (type == StreamTypeFromIndex(7)) return reserved3; return null; } set { if (type == StreamType.STREAM_TYPE_COLOR) color = value; if (type == StreamType.STREAM_TYPE_DEPTH) depth = value; if (type == StreamType.STREAM_TYPE_IR) ir = value; if (type == StreamType.STREAM_TYPE_LEFT) left = value; if (type == StreamType.STREAM_TYPE_RIGHT) right = value; if (type == StreamTypeFromIndex(5)) reserved1 = value; if (type == StreamTypeFromIndex(6)) reserved2 = value; if (type == StreamTypeFromIndex(7)) reserved3 = value; } }