Beispiel #1
0
        public Zed(RESOLUTION resolution, DEPTH_MODE depthMode = DEPTH_MODE.QUALITY, bool stabilisation = true)
            : this(new InitParameters
        {
            resolution = resolution,
            depthMode = depthMode,
            depthStabilization = stabilisation,
            enableRightSideMeasure = true,

            coordinateUnit = UNIT.MILLIMETER,
            depthMinimumDistance = 200f
                                   //depthMinimumDistance = 0.2f
        })
        {
        }
Beispiel #2
0
        /// <summary>
        /// The Init function must be called after the instantiation. The function checks if the ZED camera is plugged and opens it, initialize the projection matix and command buffers to update textures
        /// </summary>
        /// <param name="mode_">defines the quality of the depth map, affects the level of details and also the computation time.</param>
        /// <param name="minDist_">specify the minimum depth information that will be computed, in the unit you previously define.</param>
        /// <param name="disable">if set to true, it will disable self-calibration and take the initial calibration parameters without optimizing them</param>
        /// <returns>ERROR_CODE : The error code gives information about the
        /// internal process, if SUCCESS is returned, the camera is ready to use.
        /// Every other code indicates an error and the program should be stopped.
        /// 
        /// For more details see sl::zed::ERRCODE.</returns>
        public ERROR_CODE Init(DEPTH_MODE mode_ = DEPTH_MODE.PERFORMANCE, float minDist_ = -1, bool disable = false)
        {
            int v = dllz_open((int)mode_, minDist_, disable, false);
            if ((ERROR_CODE)v != ERROR_CODE.SUCCESS)
            {
                cameraIsReady = false;
                throw new Exception("Error initialization camera, no zed available [" + ((ERROR_CODE)v).ToString() + "]");
            }
            cameraIsReady = true;
            imageWidth = dllz_get_width();
            imageHeight = dllz_get_height();
            FillProjectionMatrix();
            baseline = GetCameraInformation().calibParameters.Trans[0];

            return ((ERROR_CODE)v);
        }
Beispiel #3
0
 public InitParameters()
 {
     resolution = RESOLUTION.HD720;
     cameraFPS = 60;
     cameraLinuxID = 0;
     pathSVO = "";
     svoRealTimeMode = false;
     coordinateUnit = UNIT.METER;
     coordinateSystem = COORDINATE_SYSTEM.IMAGE;
     depthMode = DEPTH_MODE.PERFORMANCE;
     depthMinimumDistance = -1;
     cameraImageFlip = false;
     cameraDisableSelfCalib = false;
     cameraBufferCountLinux = 4;
     sdkVerbose = false;
     sdkGPUId = -1;
     sdkVerboseLogFile = "";
     enableRightSideMeasure = false;
     depthStabilization = true;
 }
Beispiel #4
0
        void Update()
        {
            try
            {
#if UNITY_WEBGL
                //There is a issue with the webGL projection matrix in the build when converting the
                //depth to world position. Have to use the depth pass instead.
                if (depthMode == DEPTH_MODE.USE_DEPTH_BUFFER)
                {
                    Ocean.LogWarning("Underwater depth mode for WebGL can not be USE_DEPTH_BUFFER. Changing to USE_OCEAN_DEPTH_PASS");
                    depthMode = DEPTH_MODE.USE_OCEAN_DEPTH_PASS;
                }
#endif

                Vector4 absCof   = new Vector4(absorptionR, absorptionG, absorptionB, 1.0f);
                Vector4 sssCof   = absCof;
                Vector4 belowCof = absCof;

                absCof.w   = Mathf.Max(0.0f, aboveAbsorptionModifier.scale);
                sssCof.w   = Mathf.Max(0.0f, subSurfaceScatterModifier.scale);
                belowCof.w = Mathf.Max(0.0f, belowAbsorptionModifier.scale);

                Color absTint   = aboveAbsorptionModifier.tint * Mathf.Max(0.0f, aboveAbsorptionModifier.intensity);
                Color sssTint   = subSurfaceScatterModifier.tint * Mathf.Max(0.0f, subSurfaceScatterModifier.intensity);
                Color belowTint = belowAbsorptionModifier.tint * Mathf.Max(0.0f, belowAbsorptionModifier.intensity);

                Vector4 causticParam = new Vector4();
                causticParam.x = (causticTexture.scale.x != 0.0f) ? 1.0f / causticTexture.scale.x : 1.0f;
                causticParam.y = (causticTexture.scale.y != 0.0f) ? 1.0f / causticTexture.scale.y : 1.0f;
                causticParam.z = 0.0f;
                causticParam.w = Mathf.Clamp01(causticModifier.depthFade);

                Vector2 causticDistortion = new Vector2();
                causticDistortion.x = causticModifier.aboveDistortion;
                causticDistortion.y = causticModifier.belowDistortion;

                Shader.SetGlobalVector("Ceto_AbsCof", absCof);
                Shader.SetGlobalColor("Ceto_AbsTint", absTint);

                Shader.SetGlobalVector("Ceto_SSSCof", sssCof);
                Shader.SetGlobalColor("Ceto_SSSTint", sssTint);

                Shader.SetGlobalVector("Ceto_BelowCof", belowCof);
                Shader.SetGlobalColor("Ceto_BelowTint", belowTint);

                Color aboveInscatterCol = aboveInscatterModifier.color;
                aboveInscatterCol.a = Mathf.Clamp01(aboveInscatterModifier.intensity);

                Shader.SetGlobalFloat("Ceto_AboveInscatterScale", Mathf.Max(0.1f, aboveInscatterModifier.scale));
                Shader.SetGlobalVector("Ceto_AboveInscatterMode", InscatterModeToMask(aboveInscatterModifier.mode));
                Shader.SetGlobalColor("Ceto_AboveInscatterColor", aboveInscatterCol);

                Color belowInscatterCol = belowInscatterModifier.color;
                belowInscatterCol.a = Mathf.Clamp01(belowInscatterModifier.intensity);

                Shader.SetGlobalFloat("Ceto_BelowInscatterScale", Mathf.Max(0.1f, belowInscatterModifier.scale));
                Shader.SetGlobalVector("Ceto_BelowInscatterMode", InscatterModeToMask(belowInscatterModifier.mode));
                Shader.SetGlobalColor("Ceto_BelowInscatterColor", belowInscatterCol);

                Shader.SetGlobalFloat("Ceto_AboveRefractionIntensity", Mathf.Max(0.0f, aboveRefractionIntensity));
                Shader.SetGlobalFloat("Ceto_BelowRefractionIntensity", Mathf.Max(0.0f, belowRefractionIntensity));
                Shader.SetGlobalFloat("Ceto_RefractionDistortion", refractionDistortion * 0.05f);
                Shader.SetGlobalFloat("Ceto_MaxDepthDist", Mathf.Max(0.0f, MAX_DEPTH_DIST));
                Shader.SetGlobalFloat("Ceto_DepthBlend", Mathf.Clamp01(depthBlend));
                Shader.SetGlobalFloat("Ceto_EdgeFade", Mathf.Lerp(20.0f, 2.0f, Mathf.Clamp01(edgeFade)));

                Shader.SetGlobalTexture("Ceto_CausticTexture", ((causticTexture.tex != null) ? causticTexture.tex : Texture2D.blackTexture));
                Shader.SetGlobalVector("Ceto_CausticTextureScale", causticParam);
                Shader.SetGlobalVector("Ceto_CausticDistortion", causticDistortion);
                Shader.SetGlobalColor("Ceto_CausticTint", causticModifier.tint * causticModifier.intensity);

                if (depthMode == DEPTH_MODE.USE_OCEAN_DEPTH_PASS)
                {
                    Shader.EnableKeyword("CETO_USE_OCEAN_DEPTHS_BUFFER");

                    if (underwaterMode == UNDERWATER_MODE.ABOVE_ONLY)
                    {
                        SetBottomActive(m_bottomMask, false);
                    }
                    else
                    {
                        SetBottomActive(m_bottomMask, true);
                        UpdateBottomBounds();
                    }
                }
                else
                {
                    Shader.DisableKeyword("CETO_USE_OCEAN_DEPTHS_BUFFER");

                    if (underwaterMode == UNDERWATER_MODE.ABOVE_ONLY)
                    {
                        SetBottomActive(m_bottomMask, false);
                    }
                    else
                    {
                        SetBottomActive(m_bottomMask, true);
                        UpdateBottomBounds();
                    }
                }
            }
            catch (Exception e)
            {
                Ocean.LogError(e.ToString());
                WasError = true;
                enabled  = false;
            }
        }