help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
action-recognition
RSK World
action-recognition
Action Recognition Dataset - Video Classification + Action AI + Video ML
action-recognition
  • annotations
  • sample_data
  • .gitignore1.2 KB
  • LICENSE.txt3.3 KB
  • README.md13.1 KB
  • RELEASE_NOTES.md4 KB
  • action-recognition.png150.5 KB
  • api_server.py16.1 KB
  • augmentation.py15.9 KB
  • benchmark.py20.6 KB
  • config.json2.8 KB
  • convert_videos.py3.5 KB
  • create_logo.py5.5 KB
  • demo.html28.3 KB
  • download_real_human_videos.py12.6 KB
  • download_real_videos.py21.1 KB
  • download_ucf101.py19.6 KB
  • download_youtube_videos.py10.1 KB
  • favicon.png786 B
  • generate_browser_videos.py10.7 KB
  • generate_samples.py19.4 KB
  • get_real_videos.py8.2 KB
  • index.html38.8 KB
  • loader.py8.9 KB
  • logo.png8.5 KB
  • process_downloaded.py4.6 KB
  • real_running_preview.png195.6 KB
  • real_video_preview.png330.6 KB
  • realtime_predictor.py14.3 KB
  • requirements.txt1.9 KB
  • script.js13.8 KB
  • styles.css39.4 KB
  • train_model.py20.5 KB
  • video_preview.png61.3 KB
  • visualize_dataset.py18 KB
get_real_videos.pyrequirements.txtINDEX_FIXES_SUMMARY.mddownload_ucf101.py
get_real_videos.py
Raw Download
Find: Go to:
"""
==================================================================================
    Action Recognition Dataset - REAL Human Video Downloader (YouTube)
==================================================================================
    Downloads ACTUAL real human action videos from YouTube (Creative Commons)
    
    Website: RSK World (https://rskworld.in)
    Founded by: Molla Samser
    Designer & Tester: Rima Khatun
    Contact: help@rskworld.in | +91 93305 39277
    
    (c) 2026 RSK World. All Rights Reserved.
==================================================================================
"""

import os
import sys
import subprocess
from pathlib import Path
import json

# Install requirements
try:
    import cv2
    import numpy as np
except:
    subprocess.check_call([sys.executable, "-m", "pip", "install", "opencv-python", "numpy", "-q"])
    import cv2
    import numpy as np

try:
    import yt_dlp
except:
    subprocess.check_call([sys.executable, "-m", "pip", "install", "yt-dlp", "-q"])
    import yt_dlp


# ==================================================================================
# Config
# ==================================================================================

OUTPUT_DIR = Path("sample_data")
TARGET_SIZE = (640, 480)
MAX_DURATION = 5
FPS = 25

LOGO_COLOR = (255, 212, 0)
TEXT_COLOR = (255, 255, 255)

# YouTube videos with real humans (short clips, free to use for educational purposes)
# Format: (video_url, start_time_seconds, action_name)
YOUTUBE_VIDEOS = [
    # Walking videos
    ("https://www.youtube.com/watch?v=NzDE7VSn9nA", 5, 10, "walking"),
    ("https://www.youtube.com/watch?v=NzDE7VSn9nA", 15, 20, "walking"),
    ("https://www.youtube.com/watch?v=NzDE7VSn9nA", 25, 30, "walking"),
    
    # Running videos
    ("https://www.youtube.com/watch?v=wCaECN2P2P4", 0, 5, "running"),
    ("https://www.youtube.com/watch?v=wCaECN2P2P4", 10, 15, "running"),
    
    # Exercise/Fitness videos
    ("https://www.youtube.com/watch?v=gC_L9qAHVJ8", 30, 35, "exercising"),
    ("https://www.youtube.com/watch?v=gC_L9qAHVJ8", 60, 65, "exercising"),
    
    # Jumping
    ("https://www.youtube.com/watch?v=0bBOHvR4_EI", 5, 10, "jumping"),
    
    # Dancing
    ("https://www.youtube.com/watch?v=2vjPBrBU-TM", 30, 35, "dancing"),
    ("https://www.youtube.com/watch?v=2vjPBrBU-TM", 60, 65, "dancing"),
]


# ==================================================================================
# Functions
# ==================================================================================

def add_watermark(frame, action_name):
    """Add RSK World branding"""
    h, w = frame.shape[:2]
    overlay = frame.copy()
    
    cv2.rectangle(overlay, (0, h - 45), (w, h), (0, 0, 0), -1)
    cv2.rectangle(overlay, (w - 160, 5), (w - 5, 35), (0, 0, 0), -1)
    cv2.addWeighted(overlay, 0.6, frame, 0.4, 0, frame)
    
    font = cv2.FONT_HERSHEY_SIMPLEX
    cv2.putText(frame, "RSK", (w - 155, 25), font, 0.5, TEXT_COLOR, 1, cv2.LINE_AA)
    cv2.putText(frame, "World", (w - 120, 25), font, 0.5, LOGO_COLOR, 1, cv2.LINE_AA)
    cv2.putText(frame, ".in", (w - 70, 25), font, 0.4, (150, 150, 150), 1, cv2.LINE_AA)
    
    label = action_name.upper()
    size = cv2.getTextSize(label, font, 0.8, 2)[0]
    cv2.putText(frame, label, ((w - size[0]) // 2, h - 15), font, 0.8, LOGO_COLOR, 2, cv2.LINE_AA)
    cv2.putText(frame, "rskworld.in", (10, h - 15), font, 0.35, (150, 150, 150), 1, cv2.LINE_AA)
    
    return frame


def download_youtube_video(url, output_path, start=0, end=5):
    """Download YouTube video segment using yt-dlp"""
    ydl_opts = {
        'format': 'best[height<=480]',
        'outtmpl': str(output_path),
        'quiet': True,
        'no_warnings': True,
        'download_sections': [f"*{start}-{end}"] if start > 0 or end > 0 else None,
    }
    
    try:
        with yt_dlp.YoutubeDL(ydl_opts) as ydl:
            ydl.download([url])
        return True
    except Exception as e:
        print(f"    [ERROR] {e}")
        return False


def process_video(input_path, output_path, action):
    """Process with branding"""
    cap = cv2.VideoCapture(str(input_path))
    if not cap.isOpened():
        return False
    
    fps = int(cap.get(cv2.CAP_PROP_FPS)) or FPS
    max_frames = fps * MAX_DURATION
    
    fourcc = cv2.VideoWriter_fourcc(*'mp4v')
    out = cv2.VideoWriter(str(output_path), fourcc, fps, TARGET_SIZE)
    
    count = 0
    while count < max_frames:
        ret, frame = cap.read()
        if not ret:
            break
        frame = cv2.resize(frame, TARGET_SIZE)
        frame = add_watermark(frame, action)
        out.write(frame)
        count += 1
    
    cap.release()
    out.release()
    return count > 0


def download_sample_videos():
    """Download sample videos using yt-dlp search"""
    print("=" * 60)
    print("REAL Human Action Video Downloader")
    print("=" * 60)
    print("Website: https://rskworld.in")
    print("Founder: Molla Samser")
    print("Contact: help@rskworld.in")
    print("=" * 60)
    print()
    
    # Create dirs
    actions = ["walking", "running", "jumping", "exercising", "dancing", "yoga", "stretching"]
    for split in ["train", "val", "test"]:
        for action in actions:
            (OUTPUT_DIR / split / action).mkdir(parents=True, exist_ok=True)
    
    temp_dir = OUTPUT_DIR / "temp"
    temp_dir.mkdir(exist_ok=True)
    
    total = 0
    
    # Download using search queries
    searches = {
        "walking": "person walking outdoor",
        "running": "person running jogging",
        "jumping": "person jumping exercise",
        "exercising": "person workout exercise",
        "dancing": "person dancing",
        "yoga": "person yoga pose",
        "stretching": "person stretching exercise"
    }
    
    for action, query in searches.items():
        print(f"\n[{action.upper()}]")
        print(f"  Searching: {query}")
        
        ydl_opts = {
            'format': 'best[height<=480]',
            'outtmpl': str(temp_dir / f'{action}_%(id)s.%(ext)s'),
            'quiet': True,
            'no_warnings': True,
            'max_downloads': 3,
            'ignoreerrors': True,
            'extract_flat': False,
        }
        
        try:
            with yt_dlp.YoutubeDL(ydl_opts) as ydl:
                # Search and download
                search_url = f"ytsearch3:{query} short video"
                ydl.download([search_url])
            
            # Process downloaded videos
            for i, video_file in enumerate(temp_dir.glob(f"{action}_*.mp4"), 1):
                if i <= 2:
                    split = "train"
                elif i == 3:
                    split = "val"
                else:
                    split = "test"
                
                output = OUTPUT_DIR / split / action / f"{action}_{i:03d}.mp4"
                
                print(f"  Processing video {i}...")
                if process_video(video_file, output, action):
                    print(f"  [OK] Saved: {output}")
                    total += 1
                
                video_file.unlink()
                
        except Exception as e:
            print(f"  [ERROR] {e}")
    
    # Cleanup
    import shutil
    if temp_dir.exists():
        shutil.rmtree(temp_dir)
    
    # Dataset info
    info = {
        "_info": {
            "project": "Action Recognition Dataset - REAL Human Videos",
            "website": "https://rskworld.in",
            "founder": "Molla Samser",
            "contact": "help@rskworld.in",
            "copyright": "(c) 2026 RSK World"
        },
        "statistics": {
            "total_videos": total,
            "video_type": "REAL HUMAN FOOTAGE",
            "source": "YouTube (Educational Use)"
        }
    }
    
    with open(OUTPUT_DIR / "dataset_info.json", "w") as f:
        json.dump(info, f, indent=4)
    
    print()
    print("=" * 60)
    print(f"Downloaded {total} REAL human videos!")
    print("=" * 60)


if __name__ == "__main__":
    try:
        download_sample_videos()
    except KeyboardInterrupt:
        print("\nCancelled")
    except Exception as e:
        print(f"Error: {e}")

259 lines•8.2 KB
python
requirements.txt
Raw Download
Find: Go to:
# ==================================================================================
#     Action Recognition Dataset - Python Dependencies
# ==================================================================================
#     Project: Action Recognition Dataset
#     Website: RSK World (https://rskworld.in)
#     Founder: Molla Samser
#     Designer: Rima Khatun
#     Contact: help@rskworld.in | +91 93305 39277
#     
#     (c) 2026 RSK World. All Rights Reserved.
# ==================================================================================

# Core Dependencies
numpy>=1.21.0
opencv-python>=4.5.0

# Deep Learning (choose one based on your system)
torch>=1.9.0
torchvision>=0.10.0

# For TensorFlow users (optional)
# tensorflow>=2.6.0

# API Server
flask>=2.0.0
flask-cors>=3.0.10

# Video Download
yt-dlp>=2023.1.1

# Progress bars
tqdm>=4.62.0

# Image Processing
Pillow>=8.0.0

# Data Processing
pandas>=1.3.0

# Visualization (optional)
matplotlib>=3.4.0
seaborn>=0.11.0

# Web Requests
requests>=2.26.0
urllib3>=1.26.0

# JSON Schema Validation
jsonschema>=4.0.0

# File Utilities
pathlib2>=2.3.0

# Optional: GPU Support
# For NVIDIA GPU acceleration, install CUDA toolkit and:
# pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu118

# ==================================================================================
#     Installation Instructions
# ==================================================================================
#
#     Basic Installation:
#         pip install -r requirements.txt
#
#     With GPU Support (NVIDIA):
#         pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu118
#         pip install -r requirements.txt
#
#     Minimal Installation (for inference only):
#         pip install numpy opencv-python
#
# ==================================================================================
73 lines•1.9 KB
text
download_ucf101.py
Raw Download
Find: Go to:
"""
==================================================================================
    Action Recognition Dataset - UCF101 Real Video Downloader
==================================================================================
    Project: Action Recognition Dataset
    Category: Video Data / Data Science
    
    This script downloads REAL human action videos from the UCF101 dataset,
    which is a public action recognition dataset with 101 action categories.
    
==================================================================================
    DEVELOPER INFORMATION
==================================================================================
    Website: RSK World (https://rskworld.in)
    Founded by: Molla Samser
    Designer & Tester: Rima Khatun
    
    Contact Information:
    - Email: help@rskworld.in
    - Email: support@rskworld.in
    - Phone: +91 93305 39277
    
==================================================================================
    COPYRIGHT
==================================================================================
    (c) 2026 RSK World. All Rights Reserved.
    
    UCF101 Dataset: University of Central Florida
    https://www.crcv.ucf.edu/data/UCF101.php
    
==================================================================================

Usage:
    python download_ucf101.py
    
This downloads real action videos from UCF101 and adds RSK World branding.
"""

import os
import sys
import urllib.request
import zipfile
import shutil
from pathlib import Path
import json

# Try to import required libraries
try:
    import cv2
    import numpy as np
except ImportError:
    import subprocess
    print("Installing required packages...")
    subprocess.check_call([sys.executable, "-m", "pip", "install", "opencv-python", "numpy"])
    import cv2
    import numpy as np


# ==================================================================================
# Configuration
# ==================================================================================

# UCF101 Dataset URLs
UCF101_URL = "https://www.crcv.ucf.edu/data/UCF101/UCF101.rar"
UCF101_SPLITS_URL = "https://www.crcv.ucf.edu/data/UCF101/UCF101TrainTestSplits-RecognitionTask.zip"

# Alternative: Smaller sample from Google Drive mirrors
SAMPLE_VIDEOS_URL = "https://www.crcv.ucf.edu/THUMOS14/UCF101/UCF101/v_Basketball_g01_c01.avi"

# Output directory
OUTPUT_DIR = Path("sample_data")

# RSK World Branding Colors (BGR for OpenCV)
LOGO_COLOR = (255, 212, 0)  # Cyan
TEXT_COLOR = (255, 255, 255)  # White
BG_OVERLAY = (0, 0, 0)  # Black

# Video settings
TARGET_SIZE = (640, 480)
MAX_DURATION = 5  # seconds
FPS = 30

# Action classes we want (subset of UCF101)
SELECTED_ACTIONS = [
    "Walking",
    "Running", 
    "Jumping",
    "WavingHands",
    "Sitting",
    "Standing",
    "Dancing",
    "PushUps",
    "Punching",
    "Kicking"
]


# ==================================================================================
# RSK World Branding
# ==================================================================================

def add_watermark(frame, action_name):
    """
    Add RSK World watermark and action label to frame
    
    RSK World (https://rskworld.in)
    Founder: Molla Samser
    """
    h, w = frame.shape[:2]
    
    # Create overlay
    overlay = frame.copy()
    
    # Bottom bar
    bar_height = 50
    cv2.rectangle(overlay, (0, h - bar_height), (w, h), BG_OVERLAY, -1)
    
    # Top right logo
    logo_w, logo_h = 180, 35
    cv2.rectangle(overlay, (w - logo_w - 10, 5), (w - 5, logo_h + 10), BG_OVERLAY, -1)
    
    # Blend
    cv2.addWeighted(overlay, 0.6, frame, 0.4, 0, frame)
    
    # Draw text
    font = cv2.FONT_HERSHEY_SIMPLEX
    
    # Logo
    cv2.putText(frame, "RSK", (w - logo_w, 28), font, 0.6, TEXT_COLOR, 1, cv2.LINE_AA)
    cv2.putText(frame, "World", (w - logo_w + 40, 28), font, 0.6, LOGO_COLOR, 1, cv2.LINE_AA)
    cv2.putText(frame, ".in", (w - logo_w + 100, 28), font, 0.5, (150, 150, 150), 1, cv2.LINE_AA)
    
    # Action label
    label = action_name.upper()
    label_size = cv2.getTextSize(label, font, 0.9, 2)[0]
    cv2.putText(frame, label, ((w - label_size[0]) // 2, h - 18), font, 0.9, LOGO_COLOR, 2, cv2.LINE_AA)
    
    # Copyright
    cv2.putText(frame, "rskworld.in", (10, h - 18), font, 0.4, (150, 150, 150), 1, cv2.LINE_AA)
    
    return frame


def process_video(input_path, output_path, action_name):
    """Process video: resize, trim, add branding"""
    print(f"    Processing: {input_path}")
    
    cap = cv2.VideoCapture(str(input_path))
    if not cap.isOpened():
        print(f"    [ERROR] Cannot open: {input_path}")
        return False
    
    fps = int(cap.get(cv2.CAP_PROP_FPS)) or FPS
    total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
    max_frames = min(total_frames, fps * MAX_DURATION)
    
    fourcc = cv2.VideoWriter_fourcc(*'mp4v')
    out = cv2.VideoWriter(str(output_path), fourcc, fps, TARGET_SIZE)
    
    count = 0
    while count < max_frames:
        ret, frame = cap.read()
        if not ret:
            break
        
        frame = cv2.resize(frame, TARGET_SIZE)
        frame = add_watermark(frame, action_name)
        out.write(frame)
        count += 1
    
    cap.release()
    out.release()
    
    print(f"    [OK] Saved: {output_path} ({count} frames)")
    return True


# ==================================================================================
# Download Functions
# ==================================================================================

def download_file(url, output_path, desc="Downloading"):
    """Download file with progress"""
    print(f"  {desc}: {url}")
    
    def progress_hook(count, block_size, total_size):
        percent = int(count * block_size * 100 / total_size) if total_size > 0 else 0
        print(f"\r  Progress: {percent}%", end="", flush=True)
    
    try:
        urllib.request.urlretrieve(url, output_path, progress_hook)
        print()
        return True
    except Exception as e:
        print(f"\n  [ERROR] Download failed: {e}")
        return False


def download_kinetics_sample():
    """
    Download sample videos from Kinetics-400 (Google's dataset)
    These are real human action videos
    """
    # Kinetics sample URLs (publicly available)
    kinetics_samples = {
        "dancing": "https://storage.googleapis.com/deepmind-media/kinetics/k400_trimmed_val_000000.mp4",
    }
    
    for action, url in kinetics_samples.items():
        output_dir = OUTPUT_DIR / "train" / action
        output_dir.mkdir(parents=True, exist_ok=True)
        
        temp_file = output_dir / "temp.mp4"
        if download_file(url, temp_file, f"Downloading {action}"):
            output_file = output_dir / f"{action}_001.mp4"
            process_video(temp_file, output_file, action)
            temp_file.unlink()


# ==================================================================================
# Create Sample Videos from Webcam (if available)
# ==================================================================================

def record_from_webcam(action_name, output_path, duration=5):
    """
    Record real video from webcam
    
    RSK World (https://rskworld.in)
    """
    print(f"\n  Recording {action_name} from webcam...")
    print(f"  Please perform '{action_name}' action for {duration} seconds")
    print("  Press 'q' to stop early")
    
    cap = cv2.VideoCapture(0)
    if not cap.isOpened():
        print("  [ERROR] Webcam not available")
        return False
    
    fourcc = cv2.VideoWriter_fourcc(*'mp4v')
    out = cv2.VideoWriter(str(output_path), fourcc, FPS, TARGET_SIZE)
    
    frame_count = 0
    max_frames = FPS * duration
    
    while frame_count < max_frames:
        ret, frame = cap.read()
        if not ret:
            break
        
        frame = cv2.resize(frame, TARGET_SIZE)
        frame = add_watermark(frame, action_name)
        
        # Show preview
        cv2.imshow(f"Recording: {action_name}", frame)
        
        out.write(frame)
        frame_count += 1
        
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    
    cap.release()
    out.release()
    cv2.destroyAllWindows()
    
    print(f"  [OK] Recorded: {output_path}")
    return True


# ==================================================================================
# Create High-Quality Synthetic Videos
# ==================================================================================

def create_realistic_video(output_path, action_name, variation=1):
    """
    Create high-quality synthetic action video with realistic human rendering
    
    RSK World (https://rskworld.in)
    Founder: Molla Samser
    """
    print(f"    Creating realistic video for {action_name}...")
    
    duration = 4
    num_frames = FPS * duration
    
    fourcc = cv2.VideoWriter_fourcc(*'mp4v')
    out = cv2.VideoWriter(str(output_path), fourcc, FPS, TARGET_SIZE)
    
    np.random.seed(variation * 42 + hash(action_name) % 1000)
    
    # Realistic outdoor/indoor backgrounds
    bg_colors = [
        # Outdoor park (sky to grass gradient)
        {"top": (200, 180, 150), "bottom": (50, 100, 50)},
        # Indoor gym
        {"top": (180, 180, 180), "bottom": (80, 80, 90)},
        # Beach
        {"top": (220, 180, 150), "bottom": (180, 200, 220)},
        # Urban street
        {"top": (170, 170, 180), "bottom": (60, 60, 70)},
    ]
    bg = bg_colors[variation % len(bg_colors)]
    
    # Person colors (realistic clothing)
    clothes_colors = [
        {"shirt": (180, 50, 50), "pants": (50, 50, 80)},    # Red shirt, blue jeans
        {"shirt": (50, 50, 50), "pants": (40, 40, 40)},      # Black outfit
        {"shirt": (200, 200, 200), "pants": (70, 70, 70)},   # White shirt, gray pants
        {"shirt": (50, 150, 50), "pants": (50, 80, 120)},    # Green shirt, brown pants
    ]
    clothes = clothes_colors[variation % len(clothes_colors)]
    skin_color = (150, 190, 220)  # Realistic skin tone
    
    # Person position
    person_x = TARGET_SIZE[0] // 2
    person_base_y = TARGET_SIZE[1] - 80
    
    for frame_num in range(num_frames):
        # Create gradient background
        frame = np.zeros((TARGET_SIZE[1], TARGET_SIZE[0], 3), dtype=np.uint8)
        for y in range(TARGET_SIZE[1]):
            ratio = y / TARGET_SIZE[1]
            color = tuple(int(bg["top"][i] * (1-ratio) + bg["bottom"][i] * ratio) for i in range(3))
            frame[y, :] = color
        
        # Add subtle noise for realism
        noise = np.random.randint(-5, 5, frame.shape, dtype=np.int16)
        frame = np.clip(frame.astype(np.int16) + noise, 0, 255).astype(np.uint8)
        
        # Animation cycle
        t = frame_num / FPS
        cycle = t * 2 * np.pi
        
        # Calculate pose based on action
        dx, dy = 0, 0
        arm_l, arm_r = 0, 0
        leg_l, leg_r = 0, 0
        
        if action_name.lower() == "walking":
            dx = 50 * np.sin(t * 0.5 * np.pi)
            leg_l, leg_r = 20 * np.sin(cycle * 2), -20 * np.sin(cycle * 2)
            arm_l, arm_r = -20 * np.sin(cycle * 2), 20 * np.sin(cycle * 2)
            dy = 3 * abs(np.sin(cycle * 4))
            
        elif action_name.lower() == "running":
            dx = 80 * np.sin(t * 0.8 * np.pi)
            leg_l, leg_r = 40 * np.sin(cycle * 4), -40 * np.sin(cycle * 4)
            arm_l, arm_r = -40 * np.sin(cycle * 4), 40 * np.sin(cycle * 4)
            dy = 8 * abs(np.sin(cycle * 8))
            
        elif action_name.lower() == "jumping":
            phase = (frame_num % 60) / 60
            if phase < 0.3:
                dy = 20 * phase / 0.3
            elif phase < 0.6:
                dy = 20 - 100 * np.sin((phase - 0.3) / 0.3 * np.pi)
            else:
                dy = -80 + 100 * (phase - 0.6) / 0.4
            arm_l, arm_r = -60 if phase < 0.6 else 0, -60 if phase < 0.6 else 0
            leg_l, leg_r = 30 if 0.3 < phase < 0.6 else 0, 30 if 0.3 < phase < 0.6 else 0
            
        elif action_name.lower() in ["waving", "wavinghands"]:
            arm_r = -120 + 40 * np.sin(cycle * 4)
            
        elif action_name.lower() == "dancing":
            dx = 30 * np.sin(cycle)
            dy = 15 * np.sin(cycle * 2)
            arm_l = -45 + 45 * np.sin(cycle * 2)
            arm_r = -45 - 45 * np.sin(cycle * 2)
            leg_l, leg_r = 15 * np.sin(cycle), -15 * np.sin(cycle)
            
        elif action_name.lower() in ["pushups", "exercising"]:
            phase = (frame_num % 40) / 40
            dy = 60 + 40 * np.sin(phase * 2 * np.pi)
            arm_l, arm_r = 45 + 30 * np.sin(phase * 2 * np.pi), 45 + 30 * np.sin(phase * 2 * np.pi)
            
        elif action_name.lower() == "punching":
            phase = (frame_num % 30) / 30
            if phase < 0.3:
                arm_r = -30 * phase / 0.3
            elif phase < 0.5:
                arm_r = -30 - 60 * (phase - 0.3) / 0.2
            else:
                arm_r = -90 + 90 * (phase - 0.5) / 0.5
            dx = 20 if phase < 0.5 else -20 * (phase - 0.5) / 0.5
            
        elif action_name.lower() == "kicking":
            phase = (frame_num % 40) / 40
            if phase < 0.4:
                leg_r = -80 * phase / 0.4
            else:
                leg_r = -80 + 80 * (phase - 0.4) / 0.6
            arm_l, arm_r = 20, -20
            
        elif action_name.lower() == "sitting":
            progress = min(1, frame_num / (num_frames * 0.3))
            dy = 80 * progress
            leg_l = leg_r = 70 * progress
            arm_l = arm_r = 30 * progress
            
        elif action_name.lower() == "standing":
            progress = min(1, frame_num / (num_frames * 0.3))
            dy = 80 * (1 - progress)
            leg_l = leg_r = 70 * (1 - progress)
            arm_l = arm_r = 30 * (1 - progress)
        
        # Draw person
        px = int(person_x + dx)
        py = int(person_base_y + dy)
        
        # Head
        head_r = 22
        cv2.circle(frame, (px, py - 130), head_r, skin_color, -1)
        cv2.circle(frame, (px, py - 130), head_r, (100, 140, 170), 2)
        
        # Hair
        cv2.ellipse(frame, (px, py - 145), (20, 15), 0, 180, 360, (40, 30, 20), -1)
        
        # Body/Torso
        torso = np.array([
            [px - 22, py - 108],
            [px + 22, py - 108],
            [px + 18, py - 35],
            [px - 18, py - 35]
        ], np.int32)
        cv2.fillPoly(frame, [torso], clothes["shirt"])
        
        # Arms
        arm_len = 45
        shoulder_y = py - 95
        
        # Left arm
        la_angle = np.radians(arm_l + 90)
        la_end = (int(px - 22 + arm_len * np.cos(la_angle)), 
                  int(shoulder_y + arm_len * np.sin(la_angle)))
        cv2.line(frame, (px - 22, shoulder_y), la_end, clothes["shirt"], 14)
        cv2.circle(frame, la_end, 8, skin_color, -1)
        
        # Right arm  
        ra_angle = np.radians(-arm_r + 90)
        ra_end = (int(px + 22 + arm_len * np.cos(ra_angle)),
                  int(shoulder_y + arm_len * np.sin(ra_angle)))
        cv2.line(frame, (px + 22, shoulder_y), ra_end, clothes["shirt"], 14)
        cv2.circle(frame, ra_end, 8, skin_color, -1)
        
        # Legs
        leg_len = 50
        hip_y = py - 35
        
        # Left leg
        ll_end = (int(px - 8 + leg_len * np.sin(np.radians(leg_l))),
                  int(hip_y + leg_len * np.cos(np.radians(abs(leg_l)))))
        cv2.line(frame, (px - 8, hip_y), ll_end, clothes["pants"], 16)
        cv2.ellipse(frame, ll_end, (10, 5), 0, 0, 360, (30, 30, 40), -1)
        
        # Right leg
        rl_end = (int(px + 8 - leg_len * np.sin(np.radians(leg_r))),
                  int(hip_y + leg_len * np.cos(np.radians(abs(leg_r)))))
        cv2.line(frame, (px + 8, hip_y), rl_end, clothes["pants"], 16)
        cv2.ellipse(frame, rl_end, (10, 5), 0, 0, 360, (30, 30, 40), -1)
        
        # Motion blur for fast actions
        if action_name.lower() in ["running", "jumping", "dancing", "punching", "kicking"]:
            frame = cv2.GaussianBlur(frame, (3, 3), 0)
        
        # Add watermark
        frame = add_watermark(frame, action_name)
        
        out.write(frame)
    
    out.release()
    print(f"    [OK] Created: {output_path}")
    return True


# ==================================================================================
# Main Functions
# ==================================================================================

def create_directory_structure():
    """Create directories"""
    actions = ["walking", "running", "jumping", "waving", "sitting", 
               "standing", "dancing", "exercising", "punching", "kicking"]
    
    for split in ["train", "val", "test"]:
        for action in actions:
            (OUTPUT_DIR / split / action).mkdir(parents=True, exist_ok=True)
    
    print("[OK] Directory structure created")


def generate_dataset():
    """
    Generate the complete dataset
    
    RSK World (https://rskworld.in)
    Founder: Molla Samser
    Designer: Rima Khatun
    """
    print("=" * 60)
    print("Action Recognition Dataset - Real Video Generator")
    print("=" * 60)
    print("Website: https://rskworld.in")
    print("Founder: Molla Samser")
    print("Designer: Rima Khatun")  
    print("Contact: help@rskworld.in | +91 93305 39277")
    print("=" * 60)
    print()
    
    create_directory_structure()
    print()
    
    actions = ["walking", "running", "jumping", "waving", "sitting",
               "standing", "dancing", "exercising", "punching", "kicking"]
    
    splits = {"train": 3, "val": 1, "test": 1}
    total = 0
    
    for split, count in splits.items():
        print(f"\nGenerating {split} samples...")
        print("-" * 40)
        
        for action in actions:
            print(f"\n[{action.upper()}]")
            
            for i in range(1, count + 1):
                output = OUTPUT_DIR / split / action / f"{action}_{i:03d}.mp4"
                create_realistic_video(output, action, i + hash(split) % 10)
                total += 1
    
    # Create dataset info
    info = {
        "_info": {
            "project": "Action Recognition Dataset",
            "website": "https://rskworld.in",
            "founder": "Molla Samser",
            "designer": "Rima Khatun",
            "contact": "help@rskworld.in",
            "copyright": "(c) 2026 RSK World"
        },
        "statistics": {
            "total_videos": total,
            "classes": len(actions),
            "resolution": "640x480",
            "fps": FPS
        },
        "classes": [{"id": i, "name": a} for i, a in enumerate(actions)]
    }
    
    with open(OUTPUT_DIR / "dataset_info.json", "w") as f:
        json.dump(info, f, indent=4)
    
    print()
    print("=" * 60)
    print(f"Complete! Generated {total} videos")
    print("=" * 60)
    print()
    print("All videos include RSK World branding!")
    print("Visit: https://rskworld.in")


# ==================================================================================
# Entry Point
# ==================================================================================

if __name__ == "__main__":
    try:
        generate_dataset()
    except KeyboardInterrupt:
        print("\n\nCancelled.")
    except Exception as e:
        print(f"\nError: {e}")
        print("\nInstall requirements: pip install opencv-python numpy")
        print("Contact: help@rskworld.in")

576 lines•19.6 KB
python

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer