public void prepareExtraction() { if (!VisionDLL.prepareExtraction(task)) { throw new FaceRecognitionTask.FaceRecognitionException("Extraction preparation: failed!"); } }
public void executeExtractionStep2(bool student) { if (VisionDLL.executeExtractionStep2(task, student)) { extractionDebug = VisionDLL.getBitmapFromRGBImage(VisionDLL.getExtractionDebugImage(task)); return; } throw new FaceRecognitionTask.FaceRecognitionException("Extraction step 2: failed!"); }
public void executeLocalizationStep5(bool student) { if (VisionDLL.executeLocalizationStep5(task, student)) { localizationDebug = VisionDLL.getBitmapFromRGBImage(VisionDLL.getLocalizationDebugImage(task)); return; } throw new FaceRecognitionTask.FaceRecognitionException("Localization step 5: failed!"); }
public void executePreProcessingStep4(bool student) { if (VisionDLL.executePreProcessingStep4(task, student)) { IntPtr image = VisionDLL.getResultPreProcessingStep4(task); preProcessing4 = VisionDLL.getBitmapFromRGBImage(image); VisionDLL.imageFreeRGB(image); return; } throw new FaceRecognitionTask.FaceRecognitionException("Pre-Processing step 4: failed!"); }
//Method to get a c# Bitmap from a native C++ image pointer //DONT USE, HARDCODED! public static Bitmap getBitmapFromRGBImage(IntPtr image) { Console.WriteLine("pointer c#: " + image); int width = VisionDLL.imageWidth(image); int height = VisionDLL.imageHeight(image); Console.WriteLine("width: " + width); Console.WriteLine("Height: " + height); Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format24bppRgb); unsafe { BitmapData data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); IntPtr ptr = data.Scan0; Console.WriteLine("stride: " + data.Stride); int bytes = Math.Abs(data.Stride) * bitmap.Height; Console.WriteLine("bytes: " + bytes); byte[] rgbValues = new byte[bytes]; // Copy the RGB values into the array. Marshal.Copy(ptr, rgbValues, 0, bytes); fixed(byte *bytePtr = rgbValues) { getImageBytes(image, (IntPtr)bytePtr, data.Stride); } // Copy the RGB values back to the bitmap Marshal.Copy(rgbValues, 0, ptr, bytes); bitmap.UnlockBits(data); } return(bitmap); }
public double[] getFacialParameters() { double[] parameters = new double[16]; VisionDLL.getFacialParameters(task, parameters); return(parameters); }
public bool executeRepresentation() { return(VisionDLL.executeRepresentation(task)); }
public bool executePostProcessing() { return(VisionDLL.executePostProcessing(task)); }
public static void setImageImplementation(bool student) { VisionDLL.setImageImplementation(student); }
public void dispose() { VisionDLL.freeDLLExecutionTask(task); VisionDLL.imageFreeRGB(inputPointer); }
public FaceRecognitionTask(Bitmap input) { inputPointer = VisionDLL.getRGBImageFromBitmap(input); task = VisionDLL.getDLLExecutionTask(inputPointer); }