Skip to content

Android app for HRI research: 7 pose types, 2 actions (reading/drinking), exercise counting, emotion analysis

License

Notifications You must be signed in to change notification settings

thkimKETI/android-hri-perception

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– AI-Powered Human Behavior Analysis for Android

Android API License

An Android application for Human-Robot Interaction research that provides comprehensive human behavior analysis through Pose Detection, Action Recognition, and Emotion Analysis using Google ML Kit and custom object detection models.

๐Ÿ“ธ Demo Screenshots

Emotion Recognition Demo
Real-time Emotion Recognition

Action and Pose Recognition Demo
Action and Pose Recognition

๐ŸŽฏ Core Features

๐Ÿคธ Pose Detection & Exercise Recognition

Real-time human pose estimation with exercise classification and repetition counting.

Supported Poses (7 types):

  • standing - Standing upright position
  • sit - Sitting position
  • lie - Lying down position
  • pushup_up - Push-up upper position
  • pushup_down - Push-up lower position
  • squat_up - Squat upper position
  • squat_down - Squat lower position

Exercise Recognition:

  • Push-ups: Automatic detection and repetition counting
  • Squats: Automatic detection and repetition counting
  • Real-time form analysis with confidence scoring
  • Audio feedback on successful repetitions

๐Ÿƒ Action Recognition

Object detection-based recognition of daily activities with high accuracy filtering.

Supported Actions (2 types):

  • reading - Reading books or documents
  • drinking - Drinking water or beverages

Recognition Features:

  • Confidence threshold: 80% for reliable detection
  • Sliding window processing (50 frames) for stability
  • 5-second cooldown to prevent duplicate detections
  • Background state handling with nothing classification

๐Ÿ˜Š Emotion Analysis

Real-time facial emotion recognition with continuous monitoring and event detection.

Emotion Detection:

  • Continuous emotion state tracking
  • Event-based emotion change alerts
  • Integration with facial landmark detection
  • Timestamp logging for emotion events

๐Ÿ—๏ธ Architecture

System Overview

Camera Input โ†’ Parallel Processing โ†’ HRI Analysis โ†’ Real-time Output
     โ†“              โ†“                    โ†“              โ†“
Live Stream โ†’ [Face Detection]    โ†’ [Emotion] โ†’ UI Display
     โ†“        [Pose Detection]    โ†’ [Exercise] โ†’ Event Triggers  
     โ†“        [Object Detection]  โ†’ [Action]   โ†’ Data Logging

Core Components

โ”œโ”€โ”€ LivePreviewActivity          # Main HRI interface
โ”œโ”€โ”€ viewmanager/
โ”‚   โ”œโ”€โ”€ KETIDetector            # Central processing coordinator
โ”‚   โ”œโ”€โ”€ CameraSource            # Camera stream management
โ”‚   โ”œโ”€โ”€ GraphicOverlay          # Visual overlay system
โ”‚   โ””โ”€โ”€ KETIDetectorConstants   # System constants and modes
โ”œโ”€โ”€ facedetector/
โ”‚   โ”œโ”€โ”€ FaceDetectorProcessor   # Face detection processing
โ”‚   โ””โ”€โ”€ FaceClassifierProcessor # Emotion classification
โ”œโ”€โ”€ posedetector/
โ”‚   โ”œโ”€โ”€ PoseDetectorProcessor   # Pose detection & analysis
โ”‚   โ””โ”€โ”€ PoseClassifierProcessor # Exercise classification
โ””โ”€โ”€ objectdetector/
    โ””โ”€โ”€ ObjectDetectorProcessor # Action recognition

Processing Pipeline

  1. Camera Input โ†’ Real-time video stream capture
  2. Parallel ML Processing โ†’ Simultaneous face, pose, and object detection
  3. HRI Analysis โ†’ KETIDetector coordinates and processes all detection results
  4. Sliding Window Filtering โ†’ Stabilizes recognition results over time
  5. Event Generation โ†’ Triggers for emotion changes, exercise reps, and actions
  6. Output โ†’ Real-time UI updates and data logging

๐Ÿš€ Getting Started

Prerequisites

  • Android Studio Arctic Fox or later
  • Android device with API 26+ (Android 8.0+)
  • Camera permission for real-time detection
  • Minimum 4GB RAM for optimal ML processing performance

Installation

  1. Clone the repository

    git clone https://github.com/your-username/keti-hri-android.git
    cd keti-hri-android
  2. Open in Android Studio

    • Import the project
    • Sync Gradle dependencies
    • Build and run on device

Key Dependencies

// ML Kit for core functionality
implementation 'com.google.mlkit:face-detection:16.1.5'
implementation 'com.google.mlkit:pose-detection:18.0.0-beta3'
implementation 'com.google.mlkit:pose-detection-accurate:18.0.0-beta3'
implementation 'com.google.mlkit:object-detection:17.0.0'
implementation 'com.google.mlkit:object-detection-custom:17.0.0'

// Camera framework
implementation "androidx.camera:camera-camera2:1.0.0-SNAPSHOT"
implementation "androidx.camera:camera-lifecycle:1.0.0-SNAPSHOT"

๐Ÿ“ฑ Usage

Interface Controls

Detection Mode Toggles

  • Emotion Regular: Continuous emotion monitoring (1-second intervals)
  • Emotion Event: Event-triggered emotion change alerts
  • Pose Regular: General pose classification (standing, sitting, lying)
  • Exercise Mode: Exercise recognition with repetition counting

Visual Indicators

  • Human Detection: Icon changes color when human is detected
  • Real-time Results: Live display of current pose, emotion, and action
  • Timestamps: When each detection/event occurs
  • Camera Toggle: Switch between front/rear camera

Detection Outputs

Pose & Exercise Recognition

// Pose classification results
"standing : 0.95 confidence"
"sit : 0.87 confidence"

// Exercise repetition counting
"pushup_down : 5 reps"
"squat_down : 12 reps"

Action Recognition

// Action detection with high confidence
"reading : 0.85 confidence"
"drinking : 0.92 confidence"

Emotion Analysis

// Emotion states with timestamps
"happy : 14:30:25"
"surprised : 14:30:47"

โš™๏ธ Configuration

ML Kit Settings

// Pose detection configuration
PoseDetectorOptions poseOptions = new PoseDetectorOptions.Builder()
    .setDetectorMode(PoseDetectorOptions.STREAM_MODE)
    .build();

// Face detection for emotion analysis
FaceDetectorOptions faceOptions = new FaceDetectorOptions.Builder()
    .setPerformanceMode(FaceDetectorOptions.PERFORMANCE_MODE_FAST)
    .setClassificationMode(FaceDetectorOptions.CLASSIFICATION_MODE_ALL)
    .build();

// Object detection for actions
ObjectDetectorOptions objectOptions = new ObjectDetectorOptions.Builder()
    .setDetectorMode(ObjectDetectorOptions.STREAM_MODE)
    .enableClassification()
    .build();

Recognition Parameters

// Sliding window sizes for stability
FACE_DETECTOR_SLIDING_WINDOW_SIZE = 50;
ACTION_DETECTOR_SLIDING_WINDOW_SIZE = 50;
POSE_DETECTOR_SLIDING_WINDOW_SIZE = 20;

// Confidence thresholds
ACTION_CONFIDENCE_THRESHOLD = 0.8f;
POSE_CONFIDENCE_THRESHOLD = 0.5f;

// Event cooldown timers
ACTION_EVENT_COOLDOWN = 5; // seconds

๐Ÿ“Š Technical Specifications

Supported Platforms

  • Android API 26+ (Android 8.0 and above)
  • Target SDK: API 31 (Android 12)
  • Architecture: ARM64, ARMv7

Performance Metrics

  • Detection Latency: <100ms for real-time processing
  • Frame Rate: 30 FPS camera input
  • Memory Usage: Optimized for mobile devices with 4GB+ RAM

ML Models & Data

  • Face Detection: ML Kit lightweight model
  • Pose Detection: 33-point BlazePose model
  • Action Recognition: Custom trained object detection model
  • Training Data:
    • Pose samples: pose_all.csv (7 pose types)
    • Exercise samples: exercise_pose.csv (push-up/squat variations)

๐Ÿ› ๏ธ Development

Key Implementation Details

KETIDetector Class

Central processing coordinator that handles:

  • Multi-modal detection result integration
  • Sliding window filtering for stability
  • Event generation and timing control
  • Real-time data processing and output

Detection Processors

  • FaceDetectorProcessor: Emotion analysis from facial features
  • PoseDetectorProcessor: Pose classification and exercise recognition
  • ObjectDetectorProcessor: Action recognition from object detection

Data Models

// Pose exercise result structure
class PoseExercise {
    String exercise;     // Exercise type (pushup/squat)
    int repetition;      // Current repetition count
    String pose;         // Current pose classification
    float score;         // Confidence score
}

Customization Options

  • Adjust confidence thresholds for different accuracy requirements
  • Modify sliding window sizes for responsiveness vs. stability
  • Add new pose classifications by updating CSV training data
  • Extend action recognition with additional object classes

๐Ÿ”ง Training Data Format

Pose Classification Data

# Format: image_name, pose_class, landmark_coordinates...
image1.jpg,standing,x1,y1,z1,x2,y2,z2,...
image2.jpg,sit,x1,y1,z1,x2,y2,z2,...

Supported Pose Classes

  • Basic Poses: standing, sit, lie
  • Exercise Poses: pushup_up, pushup_down, squat_up, squat_down

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-feature)
  3. Follow existing code style and architecture patterns
  4. Test thoroughly on physical devices
  5. Submit a pull request with detailed description

Development Guidelines

  • Maintain real-time performance requirements
  • Follow Android development best practices
  • Ensure proper camera resource management
  • Add appropriate error handling and logging
  • Update training data when adding new recognition classes

๐Ÿ“œ License

This project is released under a custom license inspired by the MIT License. See LICENSE file for details.

โš ๏ธ Important Notice
Use of this codeโ€”commercial or non-commercial, including academic research, model training, product integration, and distributionโ€”requires prior written permission from the author. Unauthorized usage will be treated as a license violation.

๐Ÿ“ž Maintainer

Taehyeon Kim, Ph.D.
Senior Researcher, Korea Electronics Technology Institute (KETI)
๐Ÿ“ง [email protected] ๐ŸŒ Homepage

๐Ÿ™ Acknowledgments

This work was supported by Korea Evaluation Institute of Industrial Technology(KEIT) grant funded by the Korea government(MOTIE). (No 20009760. Development of human friendly multipurpose service robot and new market creation by applying human robot interaction design)


Comprehensive Human Behavior Analysis
Pose Detection โ€ข Action Recognition โ€ข Emotion Analysis
Developed by KETI for Advanced Human-Robot Interaction Research

About

Android app for HRI research: 7 pose types, 2 actions (reading/drinking), exercise counting, emotion analysis

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages