public override bool Equals(object other) { if (!(other is RsVideoStreamRequest)) { return(false); } RsVideoStreamRequest vsr = other as RsVideoStreamRequest; if (Stream != vsr.Stream) { return(false); } if (Format != vsr.Format) { return(false); } if (Width != vsr.Width) { return(false); } if (Height != vsr.Height) { return(false); } if (Framerate != vsr.Framerate) { return(false); } if (StreamIndex != vsr.StreamIndex) { return(false); } return(true); }
void Start() { _videoStreamFilter = new RsVideoStreamRequest(); _currVideoStreamFilter = _videoStreamFilter.Clone(); RsDevice.Instance.OnNewSampleSet += OnFrames; RsDevice.Instance.OnStop += Dispose; }
public bool HasConflict(RsVideoStreamRequest other) { if (Stream != Stream.Any && Stream != other.Stream) { return(true); } if (Format != Format.Any && Format != other.Format) { return(true); } if (Width != 0 && Width != other.Width) { return(true); } if (Height != 0 && Height != other.Height) { return(true); } if (Framerate != 0 && Framerate != other.Framerate) { return(true); } if (StreamIndex != 0 && StreamIndex != other.StreamIndex) { return(true); } return(false); }
public void Awake() { ResetProcessingBlock(); foreach (Stream stream in Enum.GetValues(typeof(Stream))) { _videoStreamFilter[stream] = new RsVideoStreamRequest(); } }
virtual protected void Awake() { threadId = Thread.CurrentThread.ManagedThreadId; _videoStreamFilter = new RsVideoStreamRequest() { Stream = _stream, Format = _format, StreamIndex = _streamIndex }; _currVideoStreamFilter = _videoStreamFilter.Clone(); }
private void ResetTexture(RsVideoStreamRequest vsr) { if (texture != null) { Destroy(texture); } texture = new Texture2D(vsr.Width, vsr.Height, Convert(vsr.Format), false, true) { wrapMode = TextureWrapMode.Clamp, filterMode = filterMode }; _currVideoStreamFilter = vsr.Clone(); texture.Apply(); textureBinding.Invoke(texture); }
void OnEnable() { m_pipeline = new Pipeline(); using (var cfg = DeviceConfiguration.ToPipelineConfig()) { ActiveProfile = m_pipeline.Start(cfg); } using (var activeStreams = ActiveProfile.Streams) { DeviceConfiguration.Profiles = new RsVideoStreamRequest[activeStreams.Count]; for (int i = 0; i < DeviceConfiguration.Profiles.Length; i++) { var s = activeStreams[i]; var p = new RsVideoStreamRequest() { Stream = s.Stream, Format = s.Format, Framerate = s.Framerate, StreamIndex = s.Index, }; var vs = s as VideoStreamProfile; if (vs != null) { p.Width = vs.Width; p.Height = vs.Height; } DeviceConfiguration.Profiles[i] = p; } } if (processMode == ProcessMode.Multithread) { stopEvent.Reset(); worker = new Thread(WaitForFrames); worker.IsBackground = true; worker.Start(); } StartCoroutine(WaitAndStart()); }
private void ResetMesh(RsVideoStreamRequest vsr) { int width = vsr.Width; int height = vsr.Height; if (width == 0 || height == 0) { return; } Dispose(); Assert.IsTrue(SystemInfo.SupportsTextureFormat(TextureFormat.RGFloat)); uvmap = new Texture2D(width, height, TextureFormat.RGFloat, false, true) { wrapMode = TextureWrapMode.Clamp, filterMode = FilterMode.Point, }; GetComponent <MeshRenderer>().sharedMaterial.SetTexture("_UVMap", uvmap); if (mesh != null) { mesh.Clear(); } else { mesh = new Mesh() { indexFormat = IndexFormat.UInt32, } }; vertices = new Vector3[width * height]; handle = GCHandle.Alloc(vertices, GCHandleType.Pinned); verticesPtr = handle.AddrOfPinnedObject(); var indices = new int[vertices.Length]; for (int i = 0; i < vertices.Length; i++) { indices[i] = i; } mesh.MarkDynamic(); mesh.vertices = vertices; var uvs = new Vector2[width * height]; Array.Clear(uvs, 0, uvs.Length); for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { uvs[i + j * width].x = i / (float)width; uvs[i + j * width].y = j / (float)height; } } mesh.uv = uvs; mesh.SetIndices(indices, MeshTopology.Points, 0, false); mesh.bounds = new Bounds(Vector3.zero, Vector3.one * 10f); GetComponent <MeshFilter>().sharedMesh = mesh; _currVideoStreamFilter = vsr.Clone(); } void OnDestroy() { Dispose(); if (mesh != null) { Destroy(null); } }