Inheritance: OpenCvSharp.DisposableCvObject
Esempio n. 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="fs"></param>
 public override void SetInput(FrameSource fs)
 {
     ThrowIfDisposed();
     if (fs == null)
     {
         throw new ArgumentNullException("nameof(fs)");
     }
     NativeMethods.superres_SuperResolution_setInput(ptr, fs.CvPtr);
 }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        public virtual void Reset()
        {
            if (FrameSource == null)
            {
                throw new NotSupportedException("frameSource == null");
            }

            FrameSource.Reset();
            FirstCall = true;
        }
Esempio n. 3
0
        /// <summary>
        /// Creates instance from cv::Ptr&lt;T&gt; .
        /// ptr is disposed when the wrapper disposes.
        /// </summary>
        /// <param name="ptr"></param>
        private static FrameSource FromPtr(IntPtr ptr)
        {
            if (ptr == IntPtr.Zero)
            {
                throw new OpenCvSharpException("Invalid FrameSource pointer");
            }
            var obj    = new FrameSource();
            var ptrObj = new Ptr(ptr);

            obj.ptrObj = ptrObj;
            obj.ptr    = ptr;
            return(obj);
        }
Esempio n. 4
0
        /// <summary>
        /// Set input frame source for Super Resolution algorithm.
        /// </summary>
        /// <param name="fs">Input frame source</param>
        public virtual void SetInput(FrameSource fs)
        {
            ThrowIfDisposed();
            if (fs == null)
            {
                throw new ArgumentNullException(nameof(fs));
            }
            fs.ThrowIfDisposed();

            NativeMethods.HandleException(
                NativeMethods.superres_SuperResolution_setInput(ptr, fs.CvPtr));
            GC.KeepAlive(this);
            GC.KeepAlive(fs);
        }
Esempio n. 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="fs"></param>
 /// <param name="output"></param>
 protected abstract void ProcessImpl(FrameSource fs, OutputArray output);
Esempio n. 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="fs"></param>
 protected abstract void InitImpl(FrameSource fs);
Esempio n. 7
0
 /// <summary>
 ///
 /// </summary>
 protected SuperResolution()
 {
     frameSource = null;
     firstCall   = true;
 }
Esempio n. 8
0
 /// <summary>
 /// </summary>
 /// <param name="fs"></param>
 /// <param name="output"></param>
 protected virtual void ProcessImpl(FrameSource fs, OutputArray output)
 {
 }
Esempio n. 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="fileName"></param>
 /// <returns></returns>
 public static FrameSource CreateFrameSource_Video_CUDA(string fileName)
 {
     return(FrameSource.CreateVideoSourceCuda(fileName));
 }
Esempio n. 10
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="fs"></param>
 public override void SetInput(FrameSource fs)
 {
     ThrowIfDisposed();
     if (fs == null)
         throw new ArgumentNullException(nameof(fs));
     NativeMethods.superres_SuperResolution_setInput(ptr, fs.CvPtr);
 }
Esempio n. 11
0
        // opens the default sensor and needed readers
        public static SensorData OpenDefaultSensor(List<DepthSensorInterface> listInterfaces,
                                                   FrameSource dwFlags, float sensorAngle, bool bUseMultiSource)
        {
            SensorData sensorData = null;
            if (listInterfaces == null)
                return sensorData;

            foreach (DepthSensorInterface sensorInt in listInterfaces)
            {
                try
                {
                    if (sensorData == null)
                    {
                        sensorData = sensorInt.OpenDefaultSensor(dwFlags, sensorAngle, bUseMultiSource);

                        if (sensorData != null)
                        {
                            sensorData.sensorInterface = sensorInt;
                            sensorData.sensorIntPlatform = sensorInt.GetSensorPlatform();
                            Debug.Log("Interface used: " + sensorInt.GetType().Name);

                            //Debug.Log("Shader level: " + SystemInfo.graphicsShaderLevel);
                            if (sensorData.bodyIndexImage != null && IsDirectX11Available())
                            {
                                Shader bodyIndexShader = Shader.Find("Kinect/BodyShader");

                                if (bodyIndexShader != null)
                                {
                                    sensorData.bodyIndexTexture = new RenderTexture(sensorData.depthImageWidth, sensorData.depthImageHeight, 0);
                                    sensorData.bodyIndexTexture.wrapMode = TextureWrapMode.Clamp;
                                    sensorData.bodyIndexTexture.filterMode = FilterMode.Point;
                                    //Debug.Log(sensorData.bodyIndexTexture.format);

                                    sensorData.bodyIndexMaterial = new Material(bodyIndexShader);

                                    sensorData.bodyIndexMaterial.SetFloat("_TexResX", (float)sensorData.depthImageWidth);
                                    sensorData.bodyIndexMaterial.SetFloat("_TexResY", (float)sensorData.depthImageHeight);

                                    sensorData.bodyIndexBuffer = new ComputeBuffer(sensorData.bodyIndexImage.Length, sizeof(float));
                                    sensorData.bodyIndexMaterial.SetBuffer("_BodyIndexBuffer", sensorData.bodyIndexBuffer);
                                }
                            }

                            if (sensorData.depthImage != null && IsDirectX11Available())
                            {
                                Shader depthImageShader = Shader.Find("Kinect/DepthShader");

                                if (depthImageShader != null)
                                {
                                    sensorData.depthImageTexture = new RenderTexture(sensorData.depthImageWidth, sensorData.depthImageHeight, 0);
                                    sensorData.depthImageTexture.wrapMode = TextureWrapMode.Clamp;
                                    sensorData.depthImageTexture.filterMode = FilterMode.Point;

                                    sensorData.depthImageMaterial = new Material(depthImageShader);

                                    sensorData.depthImageMaterial.SetTexture("_MainTex", sensorData.bodyIndexTexture);

                                    sensorData.depthImageMaterial.SetFloat("_TexResX", (float)sensorData.depthImageWidth);
                                    sensorData.depthImageMaterial.SetFloat("_TexResY", (float)sensorData.depthImageHeight);

                                    sensorData.depthImageBuffer = new ComputeBuffer(sensorData.depthImage.Length, sizeof(float));
                                    sensorData.depthImageMaterial.SetBuffer("_DepthBuffer", sensorData.depthImageBuffer);

                                    sensorData.depthHistBuffer = new ComputeBuffer(5001, sizeof(float));
                                    sensorData.depthImageMaterial.SetBuffer("_HistBuffer", sensorData.depthHistBuffer);
                                }
                            }

                            if (sensorData.colorImage != null)
                            {
                                sensorData.colorImageTexture = new Texture2D(sensorData.colorImageWidth, sensorData.colorImageHeight, TextureFormat.RGBA32, false);
                            }

                            if (sensorData.bodyIndexImage != null && sensorData.colorImage != null && IsDirectX11Available())
                            {
                                Shader depth2ColorShader = Shader.Find("Kinect/Depth2ColorShader");

                                if (depth2ColorShader)
                                {
                                    sensorData.depth2ColorTexture = new RenderTexture(sensorData.depthImageWidth, sensorData.depthImageHeight, 0);
                                    sensorData.depth2ColorTexture.wrapMode = TextureWrapMode.Clamp;
                                    //sensorData.depth2ColorTexture.filterMode = FilterMode.Point;

                                    sensorData.depth2ColorMaterial = new Material(depth2ColorShader);

                                    sensorData.depth2ColorMaterial.SetFloat("_ColorResX", (float)sensorData.colorImageWidth);
                                    sensorData.depth2ColorMaterial.SetFloat("_ColorResY", (float)sensorData.colorImageHeight);
                                    sensorData.depth2ColorMaterial.SetFloat("_DepthResX", (float)sensorData.depthImageWidth);
                                    sensorData.depth2ColorMaterial.SetFloat("_DepthResY", (float)sensorData.depthImageHeight);

                                    sensorData.depth2ColorBuffer = new ComputeBuffer(sensorData.depthImage.Length, sizeof(float) * 2);
                                    sensorData.depth2ColorMaterial.SetBuffer("_ColorCoords", sensorData.depth2ColorBuffer);
                                }
                            }

                            if (sensorData.bodyIndexImage != null && sensorData.colorImage != null)
                            {
                                sensorData.depth2ColorCoords = new Vector2[sensorData.depthImage.Length];
                            }

                        }
                        kinectSensor = sensorInt.GetType().Name;
                    }
                    else
                    {
                        sensorInt.FreeSensorInterface(false);
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogError("Initialization of the sensor failed.");
                    Debug.LogError(ex.ToString());

                    try
                    {
                        sensorInt.FreeSensorInterface(false);
                    }
                    catch (Exception)
                    {
                        // do nothing
                    }
                }
            }

            return sensorData;
        }
Esempio n. 12
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="fs"></param>
 /// <param name="output"></param>
 protected abstract void ProcessImpl(FrameSource fs, OutputArray output);
Esempio n. 13
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="fs"></param>
 protected abstract void InitImpl(FrameSource fs);
Esempio n. 14
0
    // opens the default sensor and needed readers
    public static SensorData OpenDefaultSensor(List<DepthSensorInterface> listInterfaces, 
	                                           FrameSource dwFlags, float sensorAngle, bool bUseMultiSource)
    {
        SensorData sensorData = null;
        if(listInterfaces == null)
            return sensorData;

        foreach(DepthSensorInterface sensorInt in listInterfaces)
        {
            try
            {
                if(sensorData == null)
                {
                    sensorData = sensorInt.OpenDefaultSensor(dwFlags, sensorAngle, bUseMultiSource);

                    if(sensorData != null)
                    {
                        sensorData.sensorInterface = sensorInt;
                        Debug.Log("Interface used: " + sensorInt.GetType().Name);
                    }
                }
                else
                {
                    sensorInt.FreeSensorInterface();
                }
            }
            catch (Exception ex)
            {
                Debug.LogError("Initialization of sensor failed.");
                Debug.LogError(ex.ToString());

                try
                {
                    sensorInt.FreeSensorInterface();
                }
                catch (Exception)
                {
                    // do nothing
                }
            }
        }

        return sensorData;
    }
Esempio n. 15
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="fs"></param>
 /// <param name="output"></param>
 protected override void ProcessImpl(FrameSource fs, OutputArray output)
 {
     // ネイティブ実装なので特別に空で。
 }
Esempio n. 16
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="fs"></param>
 protected override void InitImpl(FrameSource fs)
 {
     // ネイティブ実装なので特別に空で。
 }
Esempio n. 17
0
 /// <summary>
 /// Set input frame source for Super Resolution algorithm.
 /// </summary>
 /// <param name="fs">Input frame source</param>
 public virtual void SetInput(FrameSource fs)
 {
     FrameSource = fs;
 }
Esempio n. 18
0
 /// <inheritdoc />
 /// <summary>
 /// </summary>
 /// <param name="fs"></param>
 protected override void InitImpl(FrameSource fs)
 {
     // ネイティブ実装なので特別に空で。
 }
Esempio n. 19
0
 /// <summary>
 /// 
 /// </summary>
 protected SuperResolution()
 {
     frameSource = null;
     firstCall = true;
 }
Esempio n. 20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="deviceId"></param>
 /// <returns></returns>
 public static FrameSource CreateFrameSource_Camera(int deviceId)
 {
     return(FrameSource.CreateCameraSource(deviceId));
 }
Esempio n. 21
0
 /// <summary>
 /// Set input frame source for Super Resolution algorithm.
 /// </summary>
 /// <param name="fs">Input frame source</param>
 public virtual void SetInput(FrameSource fs)
 {
     frameSource = fs;
 }
Esempio n. 22
0
 /// <summary>
 /// </summary>
 /// <param name="fs"></param>
 protected virtual void InitImpl(FrameSource fs)
 {
 }
Esempio n. 23
0
 /// <inheritdoc />
 /// <summary>
 /// </summary>
 /// <param name="fs"></param>
 /// <param name="output"></param>
 protected override void ProcessImpl(FrameSource fs, OutputArray output)
 {
     // ネイティブ実装なので特別に空で。
 }
Esempio n. 24
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public static FrameSource CreateFrameSource_Empty()
 {
     return(FrameSource.CreateEmptySource());
 }