示例#1
0
        ///<summary> Create a capture using the specific camera</summary>
        ///<param name="camIndex"> The index of the camera to create capture from, starting from 0</param>
        private CapturePi(int camIndex)
        {
            try
            {
                CvInvoke.CheckLibraryLoaded();
            }
            catch (Exception e)
            {
                if (Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    Log.Fatal(m => m("Failed to load OpenCV libraries. Did you copy emguCV binaries from Windows to Linux? You must use Linux compiled emguCV binaries."), e);
                }
                throw;
            }
            _captureModuleType = CaptureModuleType.Camera;

            try
            {
                _ptr = CvInvokeRaspiCamCV.cvCreateCameraCapture(camIndex);
            }
            catch (DllNotFoundException e)
            {
                Log.Fatal("Are you running with the solution configuration matched to the right OS?", e);
                throw;
            }
            if (_ptr == IntPtr.Zero)
            {
                throw new NullReferenceException(String.Format("Error: Unable to create capture from camera {0}", camIndex));
            }
        }
示例#2
0
        /*
         * /// <summary>
         * /// Create a capture using the specific camera
         * /// </summary>
         * /// <param name="captureType">The capture type</param>
         * public VideoCapture(API captureType)
         * : this((int)captureType)
         * {
         * }*/

        /// <summary> Create a capture using the specific camera</summary>
        /// <param name="camIndex"> The index of the camera to create capture from, starting from 0</param>
        /// <param name="captureApi">The preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available.</param>
        public VideoCapture(int camIndex = 0, API captureApi = API.Any)
        {
            _captureModuleType = CaptureModuleType.Camera;

#if TEST_CAPTURE
#else
            _ptr = CvInvoke.cveVideoCaptureCreateFromDevice(camIndex, captureApi);
            if (_ptr == IntPtr.Zero)
            {
                throw new NullReferenceException(String.Format("Error: Unable to create capture from camera {0}", camIndex));
            }
#endif
        }
示例#3
0
        ///<summary> Create a capture using the specific camera</summary>
        ///<param name="camIndex"> The index of the camera to create capture from, starting from 0</param>
        public Capture(int camIndex)
        {
            _captureModuleType = CaptureModuleType.Camera;

#if TEST_CAPTURE
#else
            _ptr = CvInvoke.cvCreateCameraCapture(camIndex);
            if (_ptr == IntPtr.Zero)
            {
                throw new NullReferenceException(String.Format("Error: Unable to create capture from camera {0}", camIndex));
            }
#endif
        }
        ///<summary> Create a capture using the specific camera</summary>
        ///<param name="camIndex"> The index of the camera to create capture from, starting from 0</param>
        public Capture(int camIndex)
        {
            _captureModuleType = CaptureModuleType.Camera;

            #if TEST_CAPTURE
            #else
             _ptr = CvInvoke.cvCreateCameraCapture(camIndex);
             if (_ptr == IntPtr.Zero)
             {
            throw new NullReferenceException(String.Format("Error: Unable to create capture from camera {0}", camIndex));
             }
            #endif
        }
示例#5
0
        /// <summary>
        /// Create a capture from file or a video stream
        /// </summary>
        /// <param name="fileName">The name of a file, or an url pointed to a stream.</param>
        /// <param name="captureApi">The preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available.</param>
        /// <param name="captureProperties">Optional capture properties. e.g. new Tuple&lt;CvEnum.CapProp&gt;(CvEnum.CapProp.HwAcceleration, (int) VideoAccelerationType.Any)</param>
        public VideoCapture(String fileName, API captureApi = API.Any, params Tuple <CvEnum.CapProp, int>[] captureProperties)
        {
            using (CvString s = new CvString(fileName))
                using (VectorOfInt vectInt = ConvertCaptureProperties(captureProperties))
                {
                    _captureModuleType = CaptureModuleType.Highgui;
                    _ptr = CvInvoke.cveVideoCaptureCreateFromFile(s, captureApi, vectInt);

                    if (_ptr == IntPtr.Zero)
                    {
                        throw new NullReferenceException(String.Format("Unable to create capture from {0}", fileName));
                    }
                }
            _needDispose = true;
        }
示例#6
0
        /// <summary> Create a capture using the specific camera</summary>
        /// <param name="camIndex"> The index of the camera to create capture from, starting from 0</param>
        /// <param name="captureApi">The preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available.</param>
        /// <param name="captureProperties">Optional capture properties. e.g. new Tuple&lt;CvEnum.CapProp&gt;(CvEnum.CapProp.HwAcceleration, (int) VideoAccelerationType.Any)</param>
        public VideoCapture(int camIndex = 0, API captureApi = API.Any, params Tuple <CvEnum.CapProp, int>[] captureProperties)
        {
            _captureModuleType = CaptureModuleType.Camera;

#if TEST_CAPTURE
#else
            using (VectorOfInt vectInt = ConvertCaptureProperties(captureProperties))
            {
                _ptr = CvInvoke.cveVideoCaptureCreateFromDevice(camIndex, captureApi, vectInt);
            }

            if (_ptr == IntPtr.Zero)
            {
                throw new NullReferenceException(String.Format("Error: Unable to create capture from camera {0}", camIndex));
            }
#endif
        }
        /// <summary>
        /// Create a capture from file or a video stream
        /// </summary>
        /// <param name="fileName">The name of a file, or an url pointed to a stream.</param>
        public Capture(String fileName)
        {
            /*
             if (Util.CvToolbox.HasFFMPEG)
             {
            _captureModuleType = CaptureModuleType.FFMPEG;
            _ptr = CvInvoke.cvCreateFileCapture_FFMPEG(fileName);
             }
             else*/
             {
            _captureModuleType = CaptureModuleType.Highgui;
            _ptr = CvInvoke.cvCreateFileCapture(fileName);
             }

             if (_ptr == IntPtr.Zero)
            throw new NullReferenceException(String.Format("Unable to create capture from {0}", fileName));
        }
示例#8
0
        /// <summary>
        /// Create a capture from file or a video stream
        /// </summary>
        /// <param name="fileName">The name of a file, or an url pointed to a stream.</param>
        public Capture(String fileName)
        {
            /*
             * if (Util.CvToolbox.HasFFMPEG)
             * {
             * _captureModuleType = CaptureModuleType.FFMPEG;
             * _ptr = CvInvoke.cvCreateFileCapture_FFMPEG(fileName);
             * }
             * else*/
            {
                _captureModuleType = CaptureModuleType.Highgui;
                _ptr = CvInvoke.cvCreateFileCapture(fileName);
            }

            if (_ptr == IntPtr.Zero)
            {
                throw new NullReferenceException(String.Format("Unable to create capture from {0}", fileName));
            }
        }
示例#9
0
        /// <summary>
        /// Create a capture from file or a video stream
        /// </summary>
        /// <param name="fileName">The name of a file, or an url pointed to a stream.</param>
        /// <param name="captureApi">The preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available.</param>
        public VideoCapture(String fileName, API captureApi = API.Any)
        {
            using (CvString s = new CvString(fileName))
            {
                /*
                 * if (Util.CvToolbox.HasFFMPEG)
                 * {
                 * _captureModuleType = CaptureModuleType.FFMPEG;
                 * _ptr = CvInvoke.cvCreateFileCapture_FFMPEG(fileName);
                 * }
                 * else*/
                {
                    _captureModuleType = CaptureModuleType.Highgui;
                    _ptr = CvInvoke.cveVideoCaptureCreateFromFile(s, captureApi);
                }

                if (_ptr == IntPtr.Zero)
                {
                    throw new NullReferenceException(String.Format("Unable to create capture from {0}", fileName));
                }
            }
        }
示例#10
0
 ///<summary> Create a capture using the specific camera</summary>
 ///<param name="camIndex"> The index of the camera to create capture from, starting from 0</param>
 private CapturePi(int camIndex, CaptureConfig config)
 {
     _captureModuleType = CaptureModuleType.Camera;
     InitOpenCV();
     InitCapture(camIndex, PiCameraConfig.FromConfig(config));
 }