public PImageFilter(PImageFilter other) : this(PapillonPINVOKE.new_PImageFilter__SWIG_1(PImageFilter.getCPtr(other)), true) { if (PapillonPINVOKE.SWIGPendingException.Pending) { throw PapillonPINVOKE.SWIGPendingException.Retrieve(); } }
public static PResult Create(string productName, PProperties parameters, PImageFilter imageFilter) { PResult ret = new PResult(PapillonPINVOKE.PImageFilter_Create__SWIG_0(productName, PProperties.getCPtr(parameters), PImageFilter.getCPtr(imageFilter)), true); if (PapillonPINVOKE.SWIGPendingException.Pending) { throw PapillonPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static PResult Create(SWIGTYPE_p_papillon__PPlugin plugin, PProperties parameters, PImageFilter imageFilter) { PResult ret = new PResult(PapillonPINVOKE.PImageFilter_Create__SWIG_1(SWIGTYPE_p_papillon__PPlugin.getCPtr(plugin), PProperties.getCPtr(parameters), PImageFilter.getCPtr(imageFilter)), true); if (PapillonPINVOKE.SWIGPendingException.Pending) { throw PapillonPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PImageFilter obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
static void Main(string[] args) { // ********************** // intialise Papillon SDK // ********************** PLog.OpenConsoleLogger(); PapillonSDK.Initialise("PapillonCSharpDemo"); string SAMPLE_DIR = PPath.Join(PUtils.GetEnv("PAPILLON_INSTALL_DIR"), "Data", "Samples"); // ********************************************************************* // load an image from disk (can be JPEG, TIF, BMP or PNG) and display it // ********************************************************************* PImage image = new PImage(); image.Load(PPath.Join(SAMPLE_DIR, "sample.jpg")).OrDie(); image.Display("MySampleImage"); // ********************************************************** // set an image from a pixel buffer (a byte[]) and display it //*********************************************************** int width = 600; int height = 400; int depth = 3; var buf = new byte[width * height * depth]; for (int i = 0; i < buf.Length; i+=depth) { buf[i] = 127; buf[i + 1] = 0; buf[i + 2] = 255; } PImage image2 = new PImage(); image2.Set(buf, width, height, PImage.EPixelFormat.E_BGR8U); image2.Display("Pink"); // ********************************************************** // open a video stream from local webcam, then // 1. display the video stream // 2. write it on the disk (AVI file) // 3. stabilise the video stream (if the "stabilisation" plugin is available) // 4. perform face detection on the video stream //*********************************************************** PInputVideoStream inputStream = new PInputVideoStream(); PInputVideoStream.Open("device:0", inputStream).OrDie(); POutputVideoStream outputStream = new POutputVideoStream(); POutputVideoStream.Open("webcam.avi?fps=20.0", outputStream).OrDie(); bool isStabilisationEnabled = false; PImage stabilisedImage = new PImage(); PImageFilterOptions stabilisationOptions = new PImageFilterOptions(); PImageFilter stabilisationFilter = new PImageFilter(); if (PImageFilter.Create("Stabilisation", "", stabilisationFilter).Ok()) { stabilisationOptions.SetDoubleParameter("motion", 0.5); stabilisationOptions.SetIntParameter("panning", 0); isStabilisationEnabled = true; } PFrame frame = new PFrame(); PDetector faceDetector = new PDetector(); PDetector.Create("FaceDetector", "", faceDetector).OrDie(); PDetectorOptions detectorOptions = new PDetectorOptions(); detectorOptions.SetIntParameter("LOCALISER", 0); // no localiser detectorOptions.SetMinDetectionSize(60); PDetectionList detectionList = new PDetectionList(); while (inputStream.GetFrame(frame).Ok()) { frame.Display("Web-cam image", 50); outputStream.PutImage(frame.GetImage()); if (isStabilisationEnabled) { stabilisationFilter.Apply(frame.GetImage(), stabilisationOptions, stabilisedImage); stabilisedImage.Display("Stabilised stream"); } faceDetector.Detect(frame, detectorOptions, detectionList); PUtils.DisplayDetectionList(frame, detectionList, "Face Detector"); } }
static void Main(string[] args) { PLog.OpenConsoleLogger(); PapillonSDK.Initialise(); string SAMPLE_DIR = PPath.Join(PUtils.GetEnv("PAPILLON_INSTALL_DIR"), "Data", "Samples"); // 1. load an image from disk (can be JPEG, TIF, BMP or PNG) and display it on screen PImage image = new PImage(); image.Load(PPath.Join(SAMPLE_DIR, "sample.jpg")).OrDie(); image.DisplayScaled("Papillon SDK - Original"); // 2. perform some basic manipulations PImage image2 = new PImage(); image.Resize(image2, 2.0f, PImage.EInterpolation.E_INTERPOLATION_CUBIC); // create a new image by resizing the image loaded before image2.ExtractSubImage(image2, 50, 50, 700, 500); // extract a sub-image image2.DrawRectangle(new PRectanglei(5, 5, 690, 490), PColour3i.Black(), 2); // draw a rectangle on top of the image image2.Convert(image2, PImage.EPixelFormat.E_GREY8U); // convert image to grayscale image2.Display("Papillon SDK - Some basic manipulations"); // display the new image in another window PImage rotatedImage = new PImage(); image.Rotate(rotatedImage, 0); rotatedImage.Display("Rotated", 1500); image.Rotate(rotatedImage, 90); rotatedImage.Display("Rotated", 1500); image.Rotate(rotatedImage, 270); rotatedImage.Display("Rotated", 1500); image.Rotate(rotatedImage, -90); rotatedImage.Display("Rotated", 1500); // 3. save image to JPG format with a quality set to 90% image.Save("img1.jpg", 90); // quality is an optional parameter; set to 95 by default image2.Save("img2.png"); // 4. apply ENHANCE BRIGHTNESS image filter if the plugin is available) PImageFilter brightnessFilter = new PImageFilter(); PProperties param = new PProperties(); if (PImageFilter.Create("EnhanceBrightness", param, brightnessFilter).Ok()) // create image filter from plugin { brightnessFilter.Set("scale", new PDouble(1.5)); brightnessFilter.Set("delta", new PDouble(20)); PImage brightImage = new PImage(); brightnessFilter.Apply(image, brightImage); brightImage.Display("Papillon SDK - Enhance brightness"); // swap red and blue channels PImage brightImageSwapped = new PImage(); brightImage.SwapRGB(brightImageSwapped); brightImageSwapped.Display("Papillon SDK - Enhance brightness (rgb swapped)"); } // 5. apply LACE image filter (if the plugin is available) PImageFilter laceFilter = new PImageFilter(); PProperties laceFilterParameters = new PProperties(); laceFilterParameters.Set("strength", new PDouble(0.5)); if (PImageFilter.Create("LACE", laceFilterParameters, laceFilter).Ok()) // create image filter from plugin { PImage lacedImage = new PImage(); laceFilter.Apply(image, lacedImage); lacedImage.Display("Papillon SDK - LACE (strength 0.5)"); } // 6. apply HISTOGRAM EQUALISATION image filter (if the plugin is available) PImageFilter histogramEqualisationFilter = new PImageFilter(); if (PImageFilter.Create("HistogramEqualisation", new PProperties(), histogramEqualisationFilter).Ok()) // create image filter from plugin { PImage histogramEqualisedImage = new PImage(); histogramEqualisationFilter.Apply(image, histogramEqualisedImage); histogramEqualisedImage.Display("Papillon SDK - Histogram Equalised", 1000); } }