Git Product home page Git Product logo

Comments (11)

takuya-takeuchi avatar takuya-takeuchi commented on July 17, 2024 1

Angle is radian.
So you Should pass 1.57 instead of 90.
However, argument name confuse user.
I will change arg name to radian.

from facerecognitiondotnet.

takuya-takeuchi avatar takuya-takeuchi commented on July 17, 2024

Sample code. I can not guarantee it works.

private static byte[] ToManaged(Bitmap bitmap)
{
    var format = bitmap.PixelFormat;
    var width = bitmap.Width;
    var height = bitmap.Height;
    var array = new byte[width * height * 3]; // bitmap is treated as rgb

    BitmapData bitmapData = null;
    try
    {
        bitmapData = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, width, height),
            ImageLockMode.WriteOnly,
            format);

        var stride = bitmapData.Stride;
        var scan0 = bitmapData.Scan0;
        for (var y = 0; y < height; y++)
	{
		Marshal.Copy(new IntPtr(scan0 + y * stride), array, y * width * 3, width * 3)
	}
    }
    finally
    {
        if (bitmapData != null)
            bitmap.UnlockBits(bitmapData);
    }

    return array;
}

from facerecognitiondotnet.

MiyamuraMiyako avatar MiyamuraMiyako commented on July 17, 2024

Thanks, Referring to your code, I succeeded.

        private void VideoCapDev_NewFrame(object sender, AForge.Video.NewFrameEventArgs e)
        {
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, e.Frame.Width, e.Frame.Height);
            e.Frame.Clone(rect, PixelFormat.Format24bppRgb);
            var array = new byte[e.Frame.Width * e.Frame.Height * 3];
            BitmapData data = e.Frame.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
            Marshal.Copy(data.Scan0, array, 0, array.Length);
            e.Frame.UnlockBits(data);
            using (var img = FaceRecognition.LoadImage(array, e.Frame.Height, e.Frame.Width, 3))
            {
                var arr = FR.FaceEncodings(img).ToArray();
                if (arr.Length > 0)
                {
                    Invoke((MethodInvoker)(() => { label1.Text = FaceRecognition.CompareFace(feSample, arr[0], 0.5).ToString(); }));
                }
                else
                {
                    Invoke((MethodInvoker)(() => { label1.Text = "False"; }));
                }
            }
            return;
        }

from facerecognitiondotnet.

takuya-takeuchi avatar takuya-takeuchi commented on July 17, 2024

it's my pleasure

from facerecognitiondotnet.

atabora1 avatar atabora1 commented on July 17, 2024

Hi @takuya-takeuchi Any suggestions on how to efficiently rotate an image then perform the facial recognition?

This is a snippet of what I'm using. While this is great at detecting Faces from images that have a normal orientation, it doesn't detect them if the image is flipped.

            using (var image1 = FaceRecognition.LoadImageFile(strfullpath))
            {
             
                var faceEncodings = _FaceRecognition1.FaceEncodings(image1).ToArray();
          }

from facerecognitiondotnet.

atabora1 avatar atabora1 commented on July 17, 2024

I've also tried this without success. Your feedback would be appreciated.

DlibDotNet.Dlib.FlipImageLeftRight(array2D, array2D_Output);
var bytes = array2D_Output.ToBytes();

            using (var image = FaceRecognition.LoadImage(bytes, array2D_Output.Rows, array2D_Output.Columns, 3))//strFilePath using the smaller file size to optimize facial search
            {
                                   
                var faceEncodings = _FaceRecognition1.FaceEncodings(image).ToArray();
				
				}

from facerecognitiondotnet.

takuya-takeuchi avatar takuya-takeuchi commented on July 17, 2024

You can use DlibDotNeyt.Dlib.RotateImage. And you can get binary data from Array2d.
Then you can pass it to LoadImage.

from facerecognitiondotnet.

atabora1 avatar atabora1 commented on July 17, 2024

Thanks @takuya-takeuchi I'll give it a shot. On a different topic, could you suggest a model or algorithm for side face detection? Thanks, always appreciate the feedback.

from facerecognitiondotnet.

atabora1 avatar atabora1 commented on July 17, 2024

Thanks that worked. I was using the Dlib.RotateImage method however I was confused because I provided a 800x600 pixel image and when I attempted to rotate it 90 degrees by providing "DlibDotNet.Dlib.RotateImage(array2D, array2D_Output1, 90)" the Width and Height changed to 895x984.

from facerecognitiondotnet.

atabora1 avatar atabora1 commented on July 17, 2024

Hi @takuya-takeuchi I used "1.57" as suggested to rotate an image that was 800 Width by 600 Height and the image didn't rotate 90 degrees. So then I created a for loop and found that the value of 11 worked.

DlibDotNet.Dlib.RotateImage(array2D, array2D_Output1,1.57);
var win2 = new ImageWindow(array2D_Output1);

from facerecognitiondotnet.

takuya-takeuchi avatar takuya-takeuchi commented on July 17, 2024

@atabora1
please discuss about this issue in takuya-takeuchi/DlibDotNet#180

from facerecognitiondotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.