///<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)); } }
public virtual bool Retrieve(IOutputArray outputArray) { if (FlipType == FlipType.None) { var ptr = CvInvokeRaspiCamCV.cvQueryFrame(_ptr); using (Mat m = CvInvoke.CvArrToMat(ptr)) { m.CopyTo(outputArray); } return(true); } else { using (Mat tmp = new Mat()) { var ptr = CvInvokeRaspiCamCV.cvQueryFrame(Ptr); var managedImage = Image <Bgr, Byte> .FromIplImagePtr(ptr); managedImage.Mat.CopyTo(tmp); CvInvoke.Flip(tmp, outputArray, FlipType); return(true); } } }
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}"); } }
/// <summary> /// Release the resource for this capture /// </summary> protected override void DisposeObject() { Stop(); CvInvokeRaspiCamCV.cvReleaseCapture(ref _ptr); }
public double GetCaptureProperty(CapProp index) { return(CvInvokeRaspiCamCV.cvGetCaptureProperty(_ptr, (int)index)); }