コード例 #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
ファイル: CapturePi.cs プロジェクト: zhangzheng1205/PiCamCV
 private void InitCapture(int camIndex, PiCameraConfig config)
 {
     try
     {
         if (config.Width == 0)
         {
             _ptr = CvInvokeRaspiCamCV.cvCreateCameraCapture(camIndex);
         }
         else
         {
             Log.InfoFormat("Requesting capture config {0}", config);
             _ptr = CvInvokeRaspiCamCV.cvCreateCameraCapture2(camIndex, ref config);
         }
     }
     catch (DllNotFoundException e)
     {
         Log.Fatal("Are you running with the solution configuration matched to the right OS? or missing libraspicamcv.so?", e);
         throw;
     }
     if (_ptr == IntPtr.Zero)
     {
         throw new NullReferenceException($"Error: Unable to create capture from camera #{camIndex}");
     }
 }