Skip to content

turanalmammadov/turanio-aws-rekognition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

38 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Turanio AWS Rekognition

Face recognition and comparison using AWS Rekognition API

AWS Rekognition Node.js License: MIT PRs Welcome

🎯 Features

  • Face Detection: Detect faces in images with detailed analysis
  • Face Comparison: Compare two faces and get similarity scores
  • AWS Integration: Powered by AWS Rekognition API
  • Real-time Analysis: Fast face recognition results
  • HTTPS Support: Secure communication with SSL/TLS
  • Image Upload: Direct image upload and analysis

πŸ“Έ Demo

AWSREKONGNITIONTURANIO

πŸš€ Quick Start

Prerequisites

  • Node.js 14+ installed
  • AWS Account with Rekognition enabled
  • AWS credentials (Access Key ID and Secret Access Key)

Installation

# Clone the repository
git clone https://github.com/turanalmammadov/turanio-aws-rekognition.git

# Navigate to project directory
cd turanio-aws-rekognition

# Install dependencies
npm install

Configuration

  1. AWS Credentials Setup

Create assets/aws-config.json with your AWS credentials:

{
  "accessKeyId": "YOUR_AWS_ACCESS_KEY_ID",
  "secretAccessKey": "YOUR_AWS_SECRET_ACCESS_KEY",
  "region": "us-east-2"
}

⚠️ Security Warning: Never commit real AWS credentials to version control!

  1. SSL Certificates (Optional)

For HTTPS support, place your SSL certificates in assets/:

  • assets/key.pem - Private key
  • assets/certificate.pem - SSL certificate

For development, you can generate self-signed certificates:

openssl req -x509 -newkey rsa:4096 -keyout assets/key.pem -out assets/certificate.pem -days 365 -nodes

Running the Application

# Start the server
npm start

# Server will run on:
# HTTP:  http://localhost:80
# HTTPS: https://localhost:5555

πŸ“‘ API Endpoints

POST /doFaceAnalysis

Analyze a single face in an image.

Request:

{
  "image": "data:image/png;base64,iVBORw0KGgoAAAANS..."
}

Response:

{
  "FaceDetails": [{
    "BoundingBox": { ... },
    "Confidence": 99.9,
    "Emotions": [...],
    "AgeRange": { ... },
    "Gender": { ... }
  }]
}

POST /doCompare

Compare two faces and get similarity score.

Request:

{
  "leftImage": "data:image/png;base64,...",
  "rightImage": "data:image/png;base64,..."
}

Response:

{
  "FaceMatches": [{
    "Similarity": 95.5,
    "Face": { ... }
  }],
  "UnmatchedFaces": []
}

POST /savePics

Save uploaded images to server (for testing).

Request:

{
  "leftImage": "data:image/png;base64,...",
  "rightImage": "data:image/png;base64,..."
}

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      HTTPS      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      AWS SDK      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Client    β”‚ ───────────────> β”‚ Express API  β”‚ ────────────────> β”‚ AWS Rekognition β”‚
β”‚  (Browser)  β”‚                  β”‚   (Node.js)  β”‚                   β”‚      API        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ <─────────────── β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ <──────────────── β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  JSON Response        Process                Result

πŸ› οΈ Technologies

  • Backend: Node.js, Express.js
  • Cloud: AWS Rekognition
  • Security: HTTPS with SSL/TLS
  • Image Processing: Base64 encoding/decoding
  • CORS: Cross-origin resource sharing enabled

πŸ”’ Security Considerations

  • ⚠️ Never commit AWS credentials to version control
  • βœ… Use environment variables or AWS IAM roles in production
  • βœ… Implement rate limiting for production use
  • βœ… Add authentication/authorization middleware
  • βœ… Validate and sanitize all inputs
  • βœ… Use HTTPS in production

πŸ“ Development

Project Structure

turanio-aws-rekognition/
β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ aws-config.json      # AWS credentials (gitignored)
β”‚   β”œβ”€β”€ key.pem              # SSL private key
β”‚   └── certificate.pem      # SSL certificate
β”œβ”€β”€ index.html               # Frontend interface
β”œβ”€β”€ server.js                # Express server + AWS integration
β”œβ”€β”€ package.json             # Dependencies
└── README.md                # This file

Environment Variables

You can use environment variables instead of config file:

export AWS_ACCESS_KEY_ID="your-access-key"
export AWS_SECRET_ACCESS_KEY="your-secret-key"
export AWS_REGION="us-east-2"
export PORT=3000

πŸ§ͺ Testing

# Start the server
npm start

# Open browser
open http://localhost:80

# Or test API directly
curl -X POST http://localhost:80/doFaceAnalysis \
  -H "Content-Type: application/json" \
  -d '{"image":"data:image/png;base64,..."}'

πŸ“š AWS Rekognition Features Used

  • DetectFaces: Detect faces and analyze attributes

    • Age range estimation
    • Gender detection
    • Emotion analysis
    • Face landmarks
    • Quality assessment
  • CompareFaces: Compare facial features between images

    • Similarity scoring (0-100%)
    • Bounding box coordinates
    • Confidence levels

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ”— Links

⚑ Performance

  • Face detection: ~1-2 seconds per image
  • Face comparison: ~1-2 seconds per pair
  • Depends on image size and AWS region latency

πŸ†˜ Troubleshooting

Common Issues

Error: "Missing credentials"

  • Ensure assets/aws-config.json exists and has valid credentials
  • Or set AWS environment variables

Error: "AccessDenied"

  • Check AWS IAM permissions for Rekognition
  • Required permissions: rekognition:DetectFaces, rekognition:CompareFaces

Error: "Region not configured"

  • Verify region in aws-config.json
  • Ensure region supports Rekognition

HTTPS not working

  • Generate SSL certificates (see Configuration section)
  • Check if port 5555 is available

🌟 Author

Turan Almammadov


⭐ If you find this project helpful, please give it a star!

About

Recognize and compare faces using AWS Rekognition API

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors