Esempio n. 1
0
        private void UpdateNatDeviceCameraProps(NatDeviceCamPreviewToMatHelper helper)
        {
            var cameraProps = new Dictionary <string, string>();

            cameraProps.Add("exposureBias", helper.exposureBias.ToString());
            cameraProps.Add("exposureLock", helper.exposureLock.ToString());
            cameraProps.Add("exposureLockSupported", helper.exposureLockSupported.ToString());
            cameraProps.Add("exposureRange", helper.exposureRange.max + "x" + helper.exposureRange.min);
            cameraProps.Add("fieldOfView", helper.fieldOfView.width + "x" + helper.fieldOfView.height);
            cameraProps.Add("flashMode", helper.flashMode.ToString());
            cameraProps.Add("flashSupported", helper.flashSupported.ToString());
            cameraProps.Add("focusLock", helper.focusLock.ToString());
            cameraProps.Add("focusLockSupported", helper.focusLockSupported.ToString());
            cameraProps.Add("frameRate", helper.frameRate.ToString());
            cameraProps.Add("frontFacing", helper.frontFacing.ToString());
            cameraProps.Add("photoResolution", helper.photoResolution.width + "x" + helper.photoResolution.height);
            cameraProps.Add("previewResolution", helper.previewResolution.width + "x" + helper.previewResolution.height);
            cameraProps.Add("running", helper.running.ToString());
            cameraProps.Add("torchEnabled", helper.torchEnabled.ToString());
            cameraProps.Add("torchSupported", helper.torchSupported.ToString());
            cameraProps.Add("uniqueID", helper.uniqueID.ToString());
            cameraProps.Add("whiteBalanceLock", helper.whiteBalanceLock.ToString());
            cameraProps.Add("whiteBalanceLockSupported", helper.whiteBalanceLockSupported.ToString());
            cameraProps.Add("zoomRange", helper.zoomRange.max + "x" + helper.zoomRange.min);
            cameraProps.Add("zoomRatio", helper.zoomRatio.ToString());

            if (fpsMonitor != null)
            {
                fpsMonitor.boxWidth  = 240;
                fpsMonitor.boxHeight = 800;
                fpsMonitor.LocateGUI();

                foreach (string key in cameraProps.Keys)
                {
                    fpsMonitor.Add(key, cameraProps[key]);
                }
            }
        }
Esempio n. 2
0
        protected override void OnStart()
        {
            base.OnStart();

            // Create pixel buffer
            pixelBuffer = new byte[cameraSource.width * cameraSource.height * 4];
            // Create texture
            if (texture != null)
            {
                Texture2D.Destroy(texture);
            }
            texture = new Texture2D(
                cameraSource.width,
                cameraSource.height,
                TextureFormat.RGBA32,
                false,
                false
                );
            // Display preview
            rawImage.texture         = texture;
            aspectFitter.aspectRatio = cameraSource.width / (float)cameraSource.height;
            Debug.Log("NatDevice camera source started with resolution: " + cameraSource.width + "x" + cameraSource.height + " isFrontFacing: " + cameraSource.isFrontFacing);
            // Log camera properties
            var cameraProps = new Dictionary <string, string>();
            var camera      = cameraSource.activeCamera as CameraDevice;

            if (camera != null)
            {
                cameraProps.Add("exposureBias", camera.exposureBias.ToString());
                cameraProps.Add("exposureLock", camera.exposureLock.ToString());
                cameraProps.Add("exposureLockSupported", camera.exposureLockSupported.ToString());
                cameraProps.Add("exposureRange", camera.exposureRange.max + "x" + camera.exposureRange.min);
                cameraProps.Add("fieldOfView", camera.fieldOfView.width + "x" + camera.fieldOfView.height);
                cameraProps.Add("flashMode", camera.flashMode.ToString());
                cameraProps.Add("flashSupported", camera.flashSupported.ToString());
                cameraProps.Add("focusLock", camera.focusLock.ToString());
                cameraProps.Add("focusLockSupported", camera.focusLockSupported.ToString());
                cameraProps.Add("frameRate", camera.frameRate.ToString());
                cameraProps.Add("frontFacing", camera.frontFacing.ToString());
                cameraProps.Add("photoResolution", camera.photoResolution.width + "x" + camera.photoResolution.height);
                cameraProps.Add("previewResolution", camera.previewResolution.width + "x" + camera.previewResolution.height);
                cameraProps.Add("running", camera.running.ToString());
                cameraProps.Add("torchEnabled", camera.torchEnabled.ToString());
                cameraProps.Add("torchSupported", camera.torchSupported.ToString());
                cameraProps.Add("uniqueID", camera.uniqueID.ToString());
                cameraProps.Add("whiteBalanceLock", camera.whiteBalanceLock.ToString());
                cameraProps.Add("whiteBalanceLockSupported", camera.whiteBalanceLockSupported.ToString());
                cameraProps.Add("zoomRange", camera.zoomRange.max + "x" + camera.zoomRange.min);
                cameraProps.Add("zoomRatio", camera.zoomRatio.ToString());
            }

            Debug.Log("# Active Camera Properties #####################");
            foreach (string key in cameraProps.Keys)
            {
                Debug.Log(key + ": " + cameraProps[key]);
            }
            Debug.Log("#######################################");

            if (fpsMonitor != null)
            {
                fpsMonitor.Add("width", cameraSource.width.ToString());
                fpsMonitor.Add("height", cameraSource.height.ToString());
                fpsMonitor.Add("orientation", Screen.orientation.ToString());

                fpsMonitor.boxWidth  = 240;
                fpsMonitor.boxHeight = 800;
                fpsMonitor.LocateGUI();

                foreach (string key in cameraProps.Keys)
                {
                    fpsMonitor.Add(key, cameraProps[key]);
                }
            }
        }