DEV Community

Cover image for πŸ˜ƒ AI.Facial.Emotion – A .NET Library for Facial Emotion Analysis
Duc Nguyen Thanh
Duc Nguyen Thanh

Posted on β€’ Edited on

1 1 1 1 1

πŸ˜ƒ AI.Facial.Emotion – A .NET Library for Facial Emotion Analysis

Ever wondered how AI can detect emotions from faces? πŸ€–πŸ’‘

Meet AI.Facial.Emotion – a lightweight and powerful .NET library that can analyze facial emotions in real-time. Whether you're building chatbots, customer analytics, security systems, or healthcare apps, this tool makes it easy to integrate AI-powered facial analysis into your projects.

Happiness


🎯 What Can It Do?

βœ… Detect Emotions – Identify happiness, sadness, anger, surprise, and more.
βœ… Optimized for .NET – Works with .NET 6, 7, 8, and 9.
βœ… Multiple Input Formats – Accepts image URLs, Base64 strings, and file streams.


πŸš€ Why Use It?

βœ… Fast & Efficient – AI models optimized for real-time processing.
βœ… Easy Integration – Works seamlessly with ASP.NET Web API, Windows App.
βœ… Privacy First – No external API calls, all processing happens locally.


πŸ“¦ Installation (Super Easy!)

Just install it via NuGet:

dotnet add package AI.Facial.Emotion

Enter fullscreen mode Exit fullscreen mode

πŸ“¦ Mandatory ingredients

  • If your server runs windows operating system
dotnet add package Emgu.CV.runtime.windows
Enter fullscreen mode Exit fullscreen mode
  • If your server runs ubuntu operating system
dotnet add package Emgu.CV.runtime.ubuntu-x64
Enter fullscreen mode Exit fullscreen mode

⚑ Quick Start

1️⃣ Detect Emotion from an Image URL

var analyzer = new EmotionAnalyzer();
var result = await analyzer.AnalyzeEmotionFromUrlAsync("https://example.com/image.jpg");

Console.WriteLine($"Emotion: {result.Emotion}");
Enter fullscreen mode Exit fullscreen mode

2️⃣ Detect Emotion from a Base64 Image

var base64Image = "iVBORw0KGgoAAAANSUhEUgAA...";
var result = await analyzer.AnalyzeEmotionFromBase64Async(base64Image);

Console.WriteLine($"Emotion: {result.Emotion}");
Enter fullscreen mode Exit fullscreen mode

3️⃣ Detect Emotion from a File Stream

using var fileStream = File.OpenRead("image.jpg");
var result = await analyzer.AnalyzeEmotionFromStreamAsync(fileStream);

Console.WriteLine($"Emotion: {result.Emotion}");
Enter fullscreen mode Exit fullscreen mode

⚑That is some results

Anger

Surprise

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (1)

Collapse
 
ngtduc693 profile image
Duc Nguyen Thanh β€’

Let me know if you have any dout

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free β†’

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay