Comments (5)
You tried to use FrontalFaceDetector.Detect method for RGBA image?
If so, this method does not support RGBA image due to ristricts of dlib.
However, I may misunderstand what you faces to.
Would you show your code to recognize faces?
from dlibdotnet.
No, (i've tried this idead but, yes, the error message is "RGBAlphaPixel can not converted to Uint8")
What i desire to do is to detect the faces on resources online from the webcam and not from the images stocked on the machine. So instead of using LoadImage function (like used in the exemple); i use LoadImageData from a byte array to get Array2D. This byte array, I convert from the Color32 array provided by Unity.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using UnityEngine;
using DlibDotNet;
using System.Runtime.InteropServices;
namespace TestDlibDotNet
{
public class Class1
{
public int UnityTest(Color32[] color_array)
{
int lengt = 0;
using (var detector = FrontalFaceDetector.GetFrontalFaceDetector())
using (var img = Dlib.LoadImageData(Color32ArrayToByteArray(color_array), (uint)640, (uint)480, (uint)4))
{
Dlib.PyramidUp(img);
var dets = detector.Detect(img);
try
{
lengt = dets.Length;
}
catch (InvalidCastException e)
{
}
}
return lengt;
}
public byte[] Color32ArrayToByteArray(Color32[] colors)
{
byte[] bytes = new byte[colors.Length * 4];
for (int i = 0; i < bytes.Length/4; i += 4)
{
bytes[i]= colors[i].r;
bytes[i+1] = colors[i].g;
bytes[i+2] = colors[i].b;
bytes[i+3] = colors[i].a;
}
return bytes;
}
}
}
from dlibdotnet.
ok.
LoadImageData does not suit for this case.
LoadImageData treats argments as T type image. It means that this function does not convert color format.
If you expect this function convert image to grayscale, it's wrong.
In addition, 4th argment of LoadImageData is not channels but srtide.
In this case, It could be 640 x 4.
Therefore, you should convert image to grayscale or RGB manually.
from dlibdotnet.
Thanks, so finally, i need to manually convert my image resources from webcam to grayscale and then convert the last one to byte array ? What it means The 4th parameter (uint step) in LoadImageData ? :D
from dlibdotnet.
Step is Stride. This parameter equals to last parameter of System.Windows.Media.Imaging.BitmapSource.Create.
Generally, stride is byte size per line and it equals to image width * channels. However, some image format; eg bmp does not equals to.
Please get further information from https://en.wikipedia.org/wiki/BMP_file_format.
from dlibdotnet.
Related Issues (20)
- How to dockerize an app that uses this library HOT 6
- create detector issue HOT 4
- Set minimum sensitivity for FrontalFaceDetector.Operator HOT 3
- Add CUDA 112 to document and publish script
- library does not depend on system libjpeg on OSX HOT 2
- How to using in .NET Core 6 HOT 1
- [Memory Leak] Disposing an Array2D<RgbPixel> does not dispose of contained RgbPixels HOT 11
- Extract face coordinates from upsampled image using Frontal Face Detector HOT 4
- BitmapExtensions.ToArray2D<RgbPixel>(image) throws always not supported exception HOT 4
- Rid of System.Drawing
- cuda HOT 4
- DlibDotNet.Xamarin is missing HOT 1
- ToBitmap() ambigous HOT 1
- Memory leak with Array2D HOT 2
- DlibDotNet with FaceRecognitionDotNet Not working HOT 1
- Face recognition in real time (using ar glass and unity and dlibdotnet)
- .NET 7.0 compatibility, Failed to find dll "DlibDotNetNative", for processor architecture AMD64 HOT 2
- Can't load DlibDotNetNativeDnn in Blazor WebAssembly project
- HeadPoseTraining with GPU Support possible ?
- Can't build DlibDotNet.Native.Dnn HOT 1
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 dlibdotnet.