示例#1
0
 public void prepareExtraction()
 {
     if (!VisionDLL.prepareExtraction(task))
     {
         throw new FaceRecognitionTask.FaceRecognitionException("Extraction preparation: failed!");
     }
 }
示例#2
0
 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!");
 }
示例#3
0
 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!");
 }
示例#4
0
 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!");
 }
示例#5
0
        //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);
        }
示例#6
0
 public double[] getFacialParameters()
 {
     double[] parameters = new double[16];
     VisionDLL.getFacialParameters(task, parameters);
     return(parameters);
 }
示例#7
0
 public bool executeRepresentation()
 {
     return(VisionDLL.executeRepresentation(task));
 }
示例#8
0
 public bool executePostProcessing()
 {
     return(VisionDLL.executePostProcessing(task));
 }
示例#9
0
 public static void setImageImplementation(bool student)
 {
     VisionDLL.setImageImplementation(student);
 }
示例#10
0
 public void dispose()
 {
     VisionDLL.freeDLLExecutionTask(task);
     VisionDLL.imageFreeRGB(inputPointer);
 }
示例#11
0
 public FaceRecognitionTask(Bitmap input)
 {
     inputPointer = VisionDLL.getRGBImageFromBitmap(input);
     task         = VisionDLL.getDLLExecutionTask(inputPointer);
 }