public bool Build(int width, int height, AVProLiveCameraPlugin.VideoFrameFormat format, bool flipX, bool flipY, bool deinterlace = false) { Reset(); _width = width; _height = height; _deinterlace = deinterlace; _format = format; _flipX = flipX; _flipY = flipY; //_manager = AVProLiveCameraManager.Instance; if (CreateMaterials()) { CreateBuffers(); CreateRenderTexture(); switch (_format) { case AVProLiveCameraPlugin.VideoFrameFormat.RAW_BGRA32: _conversionMaterial.SetTexture("_MainTex", _buffers[0]._texture); break; case AVProLiveCameraPlugin.VideoFrameFormat.RAW_MONO8: _conversionMaterial.SetFloat("_TextureWidth", _finalTexture.width); _conversionMaterial.SetTexture("_MainTex", _buffers[0]._texture); break; case AVProLiveCameraPlugin.VideoFrameFormat.YUV_422_YUY2: case AVProLiveCameraPlugin.VideoFrameFormat.YUV_422_UYVY: case AVProLiveCameraPlugin.VideoFrameFormat.YUV_422_YVYU: case AVProLiveCameraPlugin.VideoFrameFormat.YUV_422_HDYC: _conversionMaterial.SetFloat("_TextureWidth", _finalTexture.width); _conversionMaterial.SetTexture("_MainTex", _buffers[0]._texture); break; case AVProLiveCameraPlugin.VideoFrameFormat.YUV_420_PLANAR_YV12: case AVProLiveCameraPlugin.VideoFrameFormat.YUV_420_PLANAR_I420: _conversionMaterial.SetFloat("_TextureWidth", _finalTexture.width); _conversionMaterial.SetTexture("_MainTex", _buffers[0]._texture); _conversionMaterial.SetTexture("_MainU", _buffers[1]._texture); _conversionMaterial.SetTexture("_MainV", _buffers[2]._texture); break; } SetFlip(_flipX, _flipY); } else { Debug.LogWarning("[AVPro LiveCamera] couldn't create conversion materials"); return false; } return true; }
private void Update_FrameRates() { CaptureFPS = AVProLiveCameraPlugin.GetCaptureFrameRate(_deviceIndex); CaptureFramesDropped = AVProLiveCameraPlugin.GetCaptureFramesDropped(_deviceIndex); }
public void SetVideoInputByIndex(int index) { AVProLiveCameraPlugin.SetVideoInputByIndex(_deviceIndex, index); }
public bool Start(AVProLiveCameraDeviceMode mode, int videoInputIndex = -1) { // Resolve the internal mode index int internalModeIndex = -1; if (mode != null) { internalModeIndex = mode.InternalIndex; } // Start the device if (AVProLiveCameraPlugin.StartDevice(_deviceIndex, internalModeIndex, videoInputIndex)) { int modeIndex = -1; if (mode != null) { for (int i = 0; i < _modes.Count; i++) { if (_modes[i] == mode) { modeIndex = i; break; } } } Debug.Log("[AVProLiveCamera] Started device using mode index " + modeIndex + " (internal index " + internalModeIndex + ")"); // Get format mode properties int width = AVProLiveCameraPlugin.GetWidth(_deviceIndex); int height = AVProLiveCameraPlugin.GetHeight(_deviceIndex); AVProLiveCameraPlugin.VideoFrameFormat format = (AVProLiveCameraPlugin.VideoFrameFormat)AVProLiveCameraPlugin.GetFormat(_deviceIndex); _width = width; _height = height; _format = format.ToString(); _deviceFormat = AVProLiveCameraPlugin.GetDeviceFormat(_deviceIndex); _frameRate = AVProLiveCameraPlugin.GetFrameRate(_deviceIndex); _frameDurationHNS = AVProLiveCameraPlugin.GetFrameDurationHNS(_deviceIndex); // Validate properties if (width <= 0 || width > MaxVideoResolution || height <= 0 || height > MaxVideoResolution) { Debug.LogWarning("[AVProLiveCamera] invalid width or height"); Close(); return(false); } // Create format converter _isTopDown = AVProLiveCameraPlugin.IsFrameTopDown(_deviceIndex); if (!_formatConverter.Build(width, height, format, _flipX, _isTopDown != _flipY, Deinterlace)) { Debug.LogWarning("[AVProLiveCamera] unable to convert camera format"); Close(); return(false); } // Run camera IsActive = true; IsRunning = false; IsPicture = false; IsPaused = true; _lastModeIndex = modeIndex; _lastVideoInputIndex = videoInputIndex; Play(); return(IsRunning); } Debug.LogWarning("[AVProLiveCamera] unable to start camera"); Close(); return(false); }
public bool ShowConfigWindow() { return(AVProLiveCameraPlugin.ShowDeviceConfigWindow(_deviceIndex)); }
public bool Start(int modeIndex = -1, int videoInputIndex = -1) { if (AVProLiveCameraPlugin.StartDevice(_deviceIndex, modeIndex, videoInputIndex)) { // Get format mode properties int width = AVProLiveCameraPlugin.GetWidth(_deviceIndex); int height = AVProLiveCameraPlugin.GetHeight(_deviceIndex); AVProLiveCameraPlugin.VideoFrameFormat format = (AVProLiveCameraPlugin.VideoFrameFormat)AVProLiveCameraPlugin.GetFormat(_deviceIndex); _width = width; _height = height; _format = format.ToString(); _frameRate = AVProLiveCameraPlugin.GetFrameRate(_deviceIndex); _frameDurationHNS = AVProLiveCameraPlugin.GetFrameDurationHNS(_deviceIndex); // Validate properties if (width <= 0 || width > 4096 || height <= 0 || height > 4096) { Debug.LogWarning("[AVProLiveCamera] invalid width or height"); Close(); return(false); } // Create format converter _isTopDown = AVProLiveCameraPlugin.IsFrameTopDown(_deviceIndex); if (!_formatConverter.Build(width, height, format, _flipX, _isTopDown != _flipY, Deinterlace)) { Debug.LogWarning("[AVProLiveCamera] unable to convert camera format"); Close(); return(false); } // Run camera IsActive = true; IsRunning = false; IsPicture = false; IsPaused = true; _lastModeIndex = modeIndex; _lastVideoInputIndex = videoInputIndex; Play(); return(IsRunning); } Debug.LogWarning("[AVProLiveCamera] unable to start camera"); Close(); return(false); }
public Shader GetPixelConversionShader(AVProLiveCameraPlugin.VideoFrameFormat format) { Shader result = null; switch (format) { case AVProLiveCameraPlugin.VideoFrameFormat.YUV_422_YUY2: result = _shaderYUY2; break; case AVProLiveCameraPlugin.VideoFrameFormat.YUV_422_UYVY: result = _shaderUYVY; break; case AVProLiveCameraPlugin.VideoFrameFormat.YUV_422_YVYU: result = _shaderYVYU; break; case AVProLiveCameraPlugin.VideoFrameFormat.YUV_422_HDYC: result = _shaderHDYC; break; case AVProLiveCameraPlugin.VideoFrameFormat.RAW_BGRA32: result= _shaderBGRA32; break; case AVProLiveCameraPlugin.VideoFrameFormat.RAW_MONO8: result= _shaderMONO8; break; case AVProLiveCameraPlugin.VideoFrameFormat.YUV_420_PLANAR_I420: result= _shaderI420; break; case AVProLiveCameraPlugin.VideoFrameFormat.YUV_420_PLANAR_YV12: result= _shaderYV12; break; default: Debug.LogError("[AVProLiveCamera] Unknown video format '" + format); break; } return result; }