示例#1
0
            /// <summary>
            /// Create or retrieve a texture of type Normalize Measure (from Camera::retrieveNormaliseMeasure() of the C++ ZED SDK)
            /// </summary>
            /// <param name="mode"></param>
            /// <param name="min">defines the lower bound of the normalization, default : automatically found</param>
            /// <param name="max">defines the upper bound of the normalization, default : automatically found</param>
            /// <returns></returns>
            public Texture2D CreateTextureNormalizeMeasureType(MEASURE mode, float min = 0.0f, float max = 0.0f)
            {
                if (IsTextureExist((int)TYPE_VIEW.NORMALIZE_MEASURE, (int)mode))
                {
                    return textures[(int)TYPE_VIEW.NORMALIZE_MEASURE][(int)mode];
                }
                if (!cameraIsReady)
                    return null;

                Texture2D m_Texture;
                if (mode == MEASURE.XYZ)
                {
                    m_Texture = new Texture2D(WidthImage, HeightImage, TextureFormat.RGBAFloat, false);
                }
                else m_Texture = new Texture2D(WidthImage, HeightImage, TextureFormat.RGBA32, false);
                m_Texture.Apply();
                IntPtr idTexture = m_Texture.GetNativeTexturePtr();
                int error = dllz_register_texture_normalize_measure_type((int)mode, idTexture, min, max);
                if (error != 0)
                {
                    Debug.Log("Error Cuda " + error);
                    //DestroyCamera();
                }
                if (!textures.ContainsKey((int)TYPE_VIEW.NORMALIZE_MEASURE))
                {
                    textures.Add((int)TYPE_VIEW.NORMALIZE_MEASURE, new Dictionary<int, Texture2D>());
                }
                RegisterTexture(m_Texture, (int)TYPE_VIEW.NORMALIZE_MEASURE, (int)mode);

                return m_Texture;
            }
示例#2
0
        /// <summary>
        /// Create or retrieve a texture of type Measure (from Camera::retrieveMeasure()). Create the texture if needed.
        /// </summary>
        /// <param name="mode"></param>
        /// <returns></returns>
        public Texture2D CreateTextureMeasureType(MEASURE mode)
        {
            if (HasTexture((int)TYPE_VIEW.RETRIEVE_MEASURE, (int)mode))
            {
                return textures[(int)TYPE_VIEW.RETRIEVE_MEASURE][(int)mode];
            }
            if (!cameraIsReady)
                return null;

            Texture2D m_Texture;

            if (mode == MEASURE.XYZ || mode == MEASURE.XYZABGR || mode == MEASURE.XYZARGB || mode == MEASURE.XYZBGRA || mode == MEASURE.XYZRGBA || mode == MEASURE.NORMALS)
            {
                m_Texture = new Texture2D(ImageWidth, ImageHeight, TextureFormat.RGBAFloat, false, true);
            }
            else if (mode == MEASURE.DEPTH || mode == MEASURE.CONFIDENCE || mode == MEASURE.DISPARITY)
            {
                m_Texture = new Texture2D(ImageWidth, ImageHeight, TextureFormat.RFloat, false, true);
            }
            else m_Texture = new Texture2D(ImageWidth, ImageHeight, TextureFormat.RGBA32, false, true);
            m_Texture.filterMode = FilterMode.Point;

            m_Texture.Apply();

            IntPtr idTexture = m_Texture.GetNativeTexturePtr();

            int error = dllz_register_texture_measure_type((int)mode, idTexture);

            if (error != 0)
            {
                throw new Exception("Error Cuda " + error + " if the problem appears again, please contact the support");
            }
            if (!textures.ContainsKey((int)TYPE_VIEW.RETRIEVE_MEASURE))
            {
                textures.Add((int)TYPE_VIEW.RETRIEVE_MEASURE, new Dictionary<int, Texture2D>());
            }

            RegisterTexture(m_Texture, (int)TYPE_VIEW.RETRIEVE_MEASURE, (int)mode);

            return m_Texture;
        }