// Update is called once per frame void Update() { if (_isConnected && _streamer.IsStreaming) { _srcTexWrapper.ConvertTexture(SrcTexture); _imageGrabber.SetTexture2D(_srcTexWrapper.WrappedTexture); _imageGrabber.Update(); } }
void BlitImage() { if (!new_image) { return; } new_image = false; _RenderedTexture = Src.Output.GetTexture((int)Eye); RenderTexture.active = _subTexture; GL.Clear(true, true, Color.black); Graphics.Blit(_RenderedTexture, _subTexture); RenderTexture.active = null; if (!_isTriggered) { return; } _texWrapper.ConvertTexture(_subTexture); if (_texWrapper.WrappedTexture != null) { Color[] data = _texWrapper.WrappedTexture.GetPixels(); int w = _texWrapper.WrappedTexture.width; int h = _texWrapper.WrappedTexture.height; int x = (int)(w * _sampleX); int y = (int)(h * _sampleY); _pixelColor = data [y * w + x]; //sample pixel in the middle _sampledTexture.SetPixel(0, 0, _pixelColor); _sampledTexture.Apply(); if (_isTriggered) { if (_pixelColor.r > 0.5f) { _isTriggered = false; _receivedTime = Time.time; latencyTime = (_receivedTime - _TriggerTime); minLatency = Mathf.Min(latencyTime, minLatency); maxLatency = Mathf.Max(latencyTime, maxLatency); averageLatency += latencyTime; _samplesCount++; _OnChangeState(!_currentState); _dbWriter.AddData("latency", ((int)(latencyTime * 1000)).ToString()); _dbWriter.AddData("Framerate", Receiver.GetCaptureRate(_eye).ToString()); GstNetworkMultipleTexture tex = Receiver as GstNetworkMultipleTexture; if (tex != null) { _dbWriter.AddData("Network", ((float)tex.Player.NetworkUsage * 8 / (float)(1024 * 1024)).ToString("F3")); } else { _dbWriter.AddData("Network", "0"); } _dbWriter.PushData(); } } } }
public void TakeScreenshot(Texture tex, string path) { if (tex == null) { return; } Texture2D t = m_wrapper.ConvertTexture(tex); System.IO.Directory.CreateDirectory(path); byte[] data = t.EncodeToPNG(); System.IO.File.WriteAllBytes(path + prefix + m_counter.ToString() + ".png", data); m_counter++; }
// Update is called once per frame void UpdateState() { if (CamSource == null) { return; } if (CamSource.targetTexture == null) { CamSource.targetTexture = new RenderTexture(Width, Height, 24, RenderTextureFormat.ARGB32); } if (texture.GetPersistentEventCount() > 0) { var t = _wrapper.ConvertTexture(CamSource.targetTexture); texture.Invoke(t); } }
void BlitTexture() { if (SourceImage == null) { return; } { _wrapper.ConvertTexture(SourceImage); _sampled = true; } var h = _wrapper.WrappedTexture; _imageGrabber.SetTexture2D(h.GetRawTextureData(), h.width, h.height, h.format);//,HandRenderer.LeapRetrival [0].Width,HandRenderer.LeapRetrival [0].Height,TextureFormat.Alpha8 _imageGrabber.Update(); }
public override void OnScreenShot(string path) { base.OnScreenShot(path); byte[] data; //if (_camSource != null) { Texture t = Provider.GetTexture(TargetStream); if (t != null) { data = _camTexWrapper.ConvertTexture(t).EncodeToPNG(); System.IO.File.WriteAllBytes(path + gameObject.name + "_main.png", data); } data = _finalTexWrapper.ConvertTexture(_renderProcessor.ResultTexture).EncodeToPNG(); System.IO.File.WriteAllBytes(path + gameObject.name + "_final.png", data); } }
public void RenderImage(RenderTexture source) { Texture tex = source; if (Flip) { tex = _BlitterProcessor.ProcessTexture(tex, 0); } else { tex = _BlitterProcessor.ProcessTexture(tex, 1); } _wrapper.ConvertTexture(tex); tex = _wrapper.WrappedTexture; //Send the rendered image to the plugin SendTexture(_instance, tex.GetNativeTexturePtr()); }
public void TakeScreenshot(Texture tex, string path) { if (tex == null) { return; } Texture2D t = m_wrapper.ConvertTexture(tex); System.IO.Directory.CreateDirectory(path); byte[] data; if (Format == FileFormat.PNG) { data = t.EncodeToPNG(); } else { data = t.EncodeToJPG(); } System.IO.File.WriteAllBytes(path + prefix + m_counter.ToString() + "." + Format.ToString().ToLower(), data); m_counter++; }