public void Play() { if (isPlaying) { return; } // if changing cameras if ((_usingFrontCamera != useFrontCamera) && (webCamTexture != null)) { WebCamTexture.Destroy(webCamTexture); webCamTexture = null; } _usingFrontCamera = useFrontCamera; // Unity 3 and 4 has flipped camera textures isMirrored = Application.unityVersion.StartsWith("4") ? useFrontCamera : !useFrontCamera; _InitDrawData(); if (webCamTexture == null) { webCamTexture = new WebCamTexture((useFrontCamera ? "Front Camera" : "Back Camera")); } webCamTexture.requestedWidth = _cameraWidth; webCamTexture.requestedHeight = _cameraHeight; webCamTexture.requestedFPS = requestedCameraFPS; webCamTexture.Play(); }
/// <summary> /// Releases all resource. /// </summary> private void Dispose() { isInitWaiting = false; hasInitDone = false; if (webCamTexture != null) { webCamTexture.Stop(); WebCamTexture.Destroy(webCamTexture); webCamTexture = null; } if (frameMat != null) { frameMat.Dispose(); frameMat = null; } if (grayMatrix != null) { grayMatrix.Dispose(); grayMatrix = null; } if (texture != null) { Texture2D.Destroy(texture); texture = null; } //Reset material if (preview) { preview.material = originalMaterial; } //Destroy view material Destroy(viewMaterial); }
/// <summary> /// Releases all resource. /// </summary> private void Dispose() { rotate90Degree = false; isInitWaiting = false; hasInitDone = false; if (pointsthread_running) { // This forces the while loop in the ThreadedWork function to abort. pointsthread_running = false; // This waits until the thread exits, // ensuring any cleanup we do after this is safe. pointsthread.Join(); } if (webCamTexture != null) { webCamTexture.Stop(); WebCamTexture.Destroy(webCamTexture); webCamTexture = null; } if (texture != null) { Texture2D.Destroy(texture); texture = null; } }
public void StartPreview(DeviceCamera genericCamera, Action startCallback, Action frameCallback) { this.startCallback = startCallback; this.frameCallback = frameCallback; var camera = genericCamera as DeviceCameraLegacy; // Create preview if (PreviewTexture && this.camera != camera) { WebCamTexture.Destroy(PreviewTexture); PreviewTexture = null; } if (!PreviewTexture) { if (camera.PreviewResolution.x == 0) { PreviewTexture = new WebCamTexture(camera.Device.name); } else { PreviewTexture = new WebCamTexture( camera.Device.name, camera.PreviewResolution.x, camera.PreviewResolution.y, (int)Mathf.Max(camera.Framerate, 30) ); } this.camera = camera as DeviceCameraLegacy; } // Start preview firstFrame = true; PreviewTexture.Play(); DispatchUtility.onFrame += Update; }
/// <summary> /// To release the resources. /// </summary> protected virtual void ReleaseResources() { isInitWaiting = false; hasInitDone = false; if (webCamTexture != null) { webCamTexture.Stop(); WebCamTexture.Destroy(webCamTexture); webCamTexture = null; } if (frameMat != null) { frameMat.Dispose(); frameMat = null; } if (baseMat != null) { baseMat.Dispose(); baseMat = null; } if (rotatedFrameMat != null) { rotatedFrameMat.Dispose(); rotatedFrameMat = null; } }
/// <summary> /// To release the resources. /// </summary> protected virtual void ReleaseResources() { isInitWaiting = false; hasInitDone = false; #if !UNITY_EDITOR // MLInput.OnControllerButtonDown -= OnButtonDown; lock (_cameraLockObject) { if (_isCameraConnected) { // MLCamera.OnRawImageAvailable -= OnCaptureRawImageComplete; _isCapturing = false; DisableMLCamera(); } } #else if (webCamTexture != null) { webCamTexture.Stop(); WebCamTexture.Destroy(webCamTexture); webCamTexture = null; } #endif if (frameMat != null) { frameMat.Dispose(); frameMat = null; } if (rotatedFrameMat != null) { rotatedFrameMat.Dispose(); rotatedFrameMat = null; } }
void OnDisable() { if (webCamTexture != null) { webCamTexture.Stop(); WebCamTexture.Destroy(webCamTexture); } }
public override void StopPreview() { DispatchUtility.onFrame -= OnFrame; previewTexture.Stop(); WebCamTexture.Destroy(previewTexture); previewTexture = null; startCallback = null; frameCallback = null; }
public void Dispose() { Camera.onPostRender -= OnFrame; webCamTexture.Stop(); WebCamTexture.Destroy(webCamTexture); webCamTexture = null; sourceBuffer = null; uprightBuffer = null; }
void OnDestroy() { // WebCamTexture 리소스 반환 if (webCamTexture != null) { webCamTexture.Stop(); WebCamTexture.Destroy(webCamTexture); webCamTexture = null; } }
public void StopPreview() { DispatchUtility.onFrame -= Update; PreviewTexture.Stop(); WebCamTexture.Destroy(PreviewTexture); PreviewTexture = null; previewBuffer = null; camera = null; startCallback = frameCallback = null; }
public void Dispose() { StopRunning(); if (activeCamera != null) { WebCamTexture.Destroy(activeCamera); activeCamera = null; } sourceBuffer = null; uprightBuffer = null; }
void OnDestroy() { if (CoreXT.IsDevice) { UIDevice.CurrentDevice().OrientationDidChange -= _OnOrientationChanged; if (webCamTexture != null) { WebCamTexture.Destroy(webCamTexture); } } }
public override void StopPreview() { CameraDeviceAttachment.Destroy(frameHelper); webcamTexture.Stop(); WebCamTexture.Destroy(webcamTexture); Texture2D.Destroy(previewTexture); frameHelper = null; webcamTexture = null; previewTexture = null; startCallback = null; frameCallback = null; pixelBuffer = null; }
public void Dispose() { Camera.onPostRender -= OnFrame; if (activeCamera != null) { activeCamera.Stop(); WebCamTexture.Destroy(activeCamera); activeCamera = null; } sourceBuffer = null; uprightBuffer = null; }
public void Release() { if (!PreviewTexture) { return; } OnStart = OnFrame = null; PreviewTexture.Stop(); WebCamTexture.Destroy(PreviewTexture); PreviewTexture = null; previewBuffer = null; dispatch.Dispose(); dispatch = null; camera = -1; }
/// <summary> /// Releases all resource. /// </summary> private void Dispose() { isInitWaiting = false; hasInitDone = false; if (webCamTexture != null) { webCamTexture.Stop(); WebCamTexture.Destroy(webCamTexture); webCamTexture = null; } if (texture != null) { Texture2D.Destroy(texture); texture = null; } }
public void Dispose() { Camera.onPostRender -= OnFrame; if (sourceMatrix != null) { sourceMatrix.Dispose(); } if (uprightMatrix != null) { uprightMatrix.Dispose(); } sourceMatrix = uprightMatrix = null; bufferColors = null; webCamTexture.Stop(); WebCamTexture.Destroy(webCamTexture); webCamTexture = null; }
public override void StopInput() { StopTracking(); if (_inputTexture != null) { _inputTexture = null; } if (_inputWebcam != null) { _inputWebcam.Stop(); WebCamTexture.Destroy(_inputWebcam); _inputWebcam = null; } _rgbaPixels = null; _monoPixels = null; _finalTexture = null; }
public void Dispose() { StopRunning(); if (activeCamera != null) { WebCamTexture.Destroy(activeCamera); activeCamera = null; } if (sourceMatrix != null) { sourceMatrix.Dispose(); } if (uprightMatrix != null) { uprightMatrix.Dispose(); } sourceMatrix = uprightMatrix = null; bufferColors = null; }
public void StopCamera() { cameraTexture.Stop(); WebCamTexture.Destroy(cameraTexture); cameraTexture = null; }