Comments (11)
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.
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.
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.
it's my pleasure
from facerecognitiondotnet.
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.
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.
You can use DlibDotNeyt.Dlib.RotateImage. And you can get binary data from Array2d.
Then you can pass it to LoadImage.
from facerecognitiondotnet.
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.
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.
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.
@atabora1
please discuss about this issue in takuya-takeuchi/DlibDotNet#180
from facerecognitiondotnet.
Related Issues (20)
- Getting Started guide
- Use Cases supported
- Performance Matrix
- UnhandledException: System.TypeInitializationException: The type initializer for 'DlibDotNet.NativeMethods' threw an exception. HOT 3
- Refactor System.Drawing out of the project HOT 6
- Getting started on GPU is few
- System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception. HOT 4
- GOOD
- Dlib.LoadImage is unable to read images from image library (even when capabity granted) HOT 4
- Will this run faster than the python version? HOT 1
- Provide an overload with SkiaSharp Bitmap to use it on Net7/Linux? HOT 1
- Unexpected version found while deserializing dlib::add_skip_layer when load Emotion Estimator Model
- Could you please provide FaceRecognitionDotNet that supports x86?
- Training Duration HeadPose HOT 1
- Bug: HeadPose.Equals throws NullReferenceException
- Can you merge LoadImage for SkiaSharp in main?
- how to know face size from FaceEncoding Object?
- Not Find ProjectDlibDotNet
- building the tools dll
- Illegal Instruction em computadores windows
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from facerecognitiondotnet.