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
surveillance-video
RSK World
surveillance-video
Surveillance Video Dataset - Security Camera + Person Detection + Anomaly Detection + OpenCV + YOLO
surveillance-video
  • __pycache__
  • annotations
  • config
  • frames
  • models
  • output
  • videos
  • .gitignore713 B
  • GITHUB_DEPLOYMENT.md3.5 KB
  • LICENSE1.3 KB
  • README.md13 KB
  • RELEASE_NOTES.md5.6 KB
  • alert_system.py12 KB
  • analytics.js9.2 KB
  • analytics_dashboard.html9.3 KB
  • api_server.py10.7 KB
  • batch_processor.py8.3 KB
  • config.py1.2 KB
  • create_sample_video.py7.4 KB
  • create_zip.py2.6 KB
  • detect_anomalies.py7.2 KB
  • detect_persons.py6.3 KB
  • download_sample_videos.py2.5 KB
  • extract_frames.py4.5 KB
  • index.html62.2 KB
  • multi_camera_system.py12.5 KB
  • package.json1.2 KB
  • process_video.py4.4 KB
  • project_data.json1.3 KB
  • project_data.php1.6 KB
  • project_data.py1.7 KB
  • requirements.txt372 B
  • script.js6.6 KB
  • setup.py2 KB
  • styles.css13.4 KB
  • surveillance-video.zip1.2 MB
  • train_ml_model.py9 KB
  • verify_project.py5 KB
  • video_quality_analyzer.py9.5 KB
  • video_search.py10.7 KB
analytics.jsextract_frames.py
analytics.js
Raw Download
Find: Go to:
// Project: Surveillance Video Dataset
// Author: Molla Samser
// Website: https://rskworld.in/
// Contact: help@rskworld.in
// Phone: +91 93305 39277
// Address: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India, 713147

// Analytics Dashboard JavaScript

let detectionsChart, anomalyChart, activityChart, processingChart;

// Initialize dashboard
document.addEventListener('DOMContentLoaded', function() {
    loadAnalyticsData();
    initializeCharts();
    startRealTimeUpdates();
});

function loadAnalyticsData() {
    // Load data from API or local files
    fetch('api/analytics')
        .then(response => response.json())
        .then(data => {
            updateStatistics(data);
            updateCharts(data);
            updateTimeline(data.events);
        })
        .catch(() => {
            // Fallback to sample data
            const sampleData = getSampleAnalyticsData();
            updateStatistics(sampleData);
            updateCharts(sampleData);
            updateTimeline(sampleData.events);
        });
}

function getSampleAnalyticsData() {
    return {
        totalVideos: 2,
        totalDetections: 156,
        totalAnomalies: 2,
        totalHours: 0.5,
        detections: [45, 52, 38, 21],
        anomalies: { 'unusual_movement': 2, 'rapid_change': 0 },
        activities: { 'walking': 45, 'standing': 38, 'running': 12 },
        events: [
            { time: '10:30:15', type: 'detection', message: 'Person detected in frame', video: 'sample.mp4' },
            { time: '10:30:45', type: 'anomaly', message: 'Anomaly detected - rapid movement', video: 'sample2.mp4' },
            { time: '10:31:20', type: 'detection', message: 'Multiple persons detected', video: 'sample2.mp4' }
        ]
    };
}

function updateStatistics(data) {
    document.getElementById('totalVideos').textContent = data.totalVideos || 0;
    document.getElementById('totalDetections').textContent = data.totalDetections || 0;
    document.getElementById('totalAnomalies').textContent = data.totalAnomalies || 0;
    document.getElementById('totalHours').textContent = data.totalHours || 0;
}

function initializeCharts() {
    // Detections Chart
    const detectionsCtx = document.getElementById('detectionsChart').getContext('2d');
    detectionsChart = new Chart(detectionsCtx, {
        type: 'line',
        data: {
            labels: ['00:00', '00:05', '00:10', '00:15'],
            datasets: [{
                label: 'Person Detections',
                data: [45, 52, 38, 21],
                borderColor: '#667eea',
                backgroundColor: 'rgba(102, 126, 234, 0.1)',
                tension: 0.4
            }]
        },
        options: {
            responsive: true,
            maintainAspectRatio: true
        }
    });

    // Anomaly Chart
    const anomalyCtx = document.getElementById('anomalyChart').getContext('2d');
    anomalyChart = new Chart(anomalyCtx, {
        type: 'doughnut',
        data: {
            labels: ['Unusual Movement', 'Rapid Change', 'Normal'],
            datasets: [{
                data: [2, 0, 154],
                backgroundColor: ['#dc3545', '#ffc107', '#28a745']
            }]
        },
        options: {
            responsive: true,
            maintainAspectRatio: true
        }
    });

    // Activity Chart
    const activityCtx = document.getElementById('activityChart').getContext('2d');
    activityChart = new Chart(activityCtx, {
        type: 'bar',
        data: {
            labels: ['Walking', 'Standing', 'Running', 'Other'],
            datasets: [{
                label: 'Activities',
                data: [45, 38, 12, 8],
                backgroundColor: '#667eea'
            }]
        },
        options: {
            responsive: true,
            maintainAspectRatio: true
        }
    });

    // Processing Chart
    const processingCtx = document.getElementById('processingChart').getContext('2d');
    processingChart = new Chart(processingCtx, {
        type: 'bar',
        data: {
            labels: ['Processed', 'Pending', 'Failed'],
            datasets: [{
                label: 'Videos',
                data: [2, 0, 0],
                backgroundColor: ['#28a745', '#ffc107', '#dc3545']
            }]
        },
        options: {
            responsive: true,
            maintainAspectRatio: true
        }
    });
}

function updateCharts(data) {
    if (detectionsChart && data.detections) {
        detectionsChart.data.datasets[0].data = data.detections;
        detectionsChart.update();
    }
    
    if (anomalyChart && data.anomalies) {
        const values = Object.values(data.anomalies);
        anomalyChart.data.datasets[0].data = [...values, data.totalDetections - values.reduce((a, b) => a + b, 0)];
        anomalyChart.update();
    }
    
    if (activityChart && data.activities) {
        activityChart.data.datasets[0].data = Object.values(data.activities);
        activityChart.update();
    }
}

function updateTimeline(events) {
    const timeline = document.getElementById('eventsTimeline');
    timeline.innerHTML = '';
    
    if (!events || events.length === 0) {
        timeline.innerHTML = '<p>No recent events</p>';
        return;
    }
    
    events.forEach(event => {
        const item = document.createElement('div');
        item.className = 'timeline-item';
        const icon = event.type === 'anomaly' ? 'fa-exclamation-triangle' : 'fa-user';
        const color = event.type === 'anomaly' ? '#dc3545' : '#667eea';
        item.innerHTML = `
            <div style="display: flex; justify-content: space-between; align-items: center;">
                <div>
                    <i class="fas ${icon}" style="color: ${color}; margin-right: 10px;"></i>
                    <strong>${event.message}</strong>
                    <span style="color: #666; margin-left: 10px;">${event.video}</span>
                </div>
                <span style="color: #666;">${event.time}</span>
            </div>
        `;
        timeline.appendChild(item);
    });
}

function applyFilters() {
    const dateFilter = document.getElementById('dateFilter').value;
    const videoFilter = document.getElementById('videoFilter').value;
    const anomalyFilter = document.getElementById('anomalyFilter').value;
    
    // Apply filters and reload data
    loadAnalyticsData();
    console.log('Filters applied:', { dateFilter, videoFilter, anomalyFilter });
}

function exportData(format) {
    const data = getSampleAnalyticsData();
    
    switch(format) {
        case 'json':
            downloadJSON(data, 'analytics_data.json');
            break;
        case 'csv':
            downloadCSV(data, 'analytics_data.csv');
            break;
        case 'pdf':
            window.print();
            break;
    }
}

function downloadJSON(data, filename) {
    const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
    const url = URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.href = url;
    a.download = filename;
    a.click();
    URL.revokeObjectURL(url);
}

function downloadCSV(data, filename) {
    let csv = 'Metric,Value\n';
    csv += `Total Videos,${data.totalVideos}\n`;
    csv += `Total Detections,${data.totalDetections}\n`;
    csv += `Total Anomalies,${data.totalAnomalies}\n`;
    csv += `Total Hours,${data.totalHours}\n`;
    
    const blob = new Blob([csv], { type: 'text/csv' });
    const url = URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.href = url;
    a.download = filename;
    a.click();
    URL.revokeObjectURL(url);
}

function startRealTimeUpdates() {
    // Simulate real-time updates every 5 seconds
    setInterval(() => {
        // In production, this would fetch from API
        const newEvent = {
            time: new Date().toLocaleTimeString(),
            type: Math.random() > 0.8 ? 'anomaly' : 'detection',
            message: 'New event detected',
            video: 'sample.mp4'
        };
        
        // Add to timeline
        const timeline = document.getElementById('eventsTimeline');
        const item = document.createElement('div');
        item.className = 'timeline-item';
        const icon = newEvent.type === 'anomaly' ? 'fa-exclamation-triangle' : 'fa-user';
        const color = newEvent.type === 'anomaly' ? '#dc3545' : '#667eea';
        item.innerHTML = `
            <div style="display: flex; justify-content: space-between; align-items: center;">
                <div>
                    <i class="fas ${icon}" style="color: ${color}; margin-right: 10px;"></i>
                    <strong>${newEvent.message}</strong>
                    <span style="color: #666; margin-left: 10px;">${newEvent.video}</span>
                </div>
                <span style="color: #666;">${newEvent.time}</span>
            </div>
        `;
        timeline.insertBefore(item, timeline.firstChild);
        
        // Keep only last 10 events
        while (timeline.children.length > 10) {
            timeline.removeChild(timeline.lastChild);
        }
    }, 5000);
}

270 lines•9.2 KB
javascript
extract_frames.py
Raw Download
Find: Go to:
# Project: Surveillance Video Dataset
# Author: Molla Samser
# Website: https://rskworld.in/
# Contact: help@rskworld.in
# Phone: +91 93305 39277
# Address: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India, 713147

"""
Frame extraction script for surveillance video dataset.
This script extracts frames from video files at specified intervals.
"""

import cv2
import os
import argparse
from pathlib import Path


def extract_frames(video_path, output_dir='frames/extracted_frames', interval=30, start_frame=0, end_frame=None):
    """
    Extract frames from video at specified intervals.
    
    Args:
        video_path: Path to the input video file
        output_dir: Directory to save extracted frames
        interval: Extract every Nth frame
        start_frame: Starting frame number
        end_frame: Ending frame number (None for all frames)
    """
    # Create output directory
    os.makedirs(output_dir, exist_ok=True)
    
    # Open video
    cap = cv2.VideoCapture(video_path)
    if not cap.isOpened():
        print(f"Error: Could not open video file {video_path}")
        return
    
    # Get video properties
    fps = cap.get(cv2.CAP_PROP_FPS)
    total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
    
    if end_frame is None:
        end_frame = total_frames
    
    print(f"Video: {video_path}")
    print(f"Total frames: {total_frames}")
    print(f"FPS: {fps}")
    print(f"Extracting frames {start_frame} to {end_frame} (interval: {interval})")
    
    frame_count = 0
    saved_count = 0
    
    # Seek to start frame
    cap.set(cv2.CAP_PROP_POS_FRAMES, start_frame)
    
    while cap.isOpened() and frame_count < end_frame:
        ret, frame = cap.read()
        if not ret:
            break
        
        current_frame = start_frame + frame_count
        
        # Save frame at specified interval
        if current_frame % interval == 0:
            frame_filename = os.path.join(output_dir, f"frame_{current_frame:06d}.jpg")
            cv2.imwrite(frame_filename, frame)
            saved_count += 1
            
            if saved_count % 10 == 0:
                print(f"Extracted {saved_count} frames...")
        
        frame_count += 1
    
    cap.release()
    print(f"Extraction complete. Saved {saved_count} frames to {output_dir}")


def extract_all_frames(video_path, output_dir='frames/extracted_frames'):
    """
    Extract all frames from video.
    
    Args:
        video_path: Path to the input video file
        output_dir: Directory to save extracted frames
    """
    extract_frames(video_path, output_dir, interval=1)


def extract_by_time_interval(video_path, output_dir='frames/extracted_frames', time_interval=1.0):
    """
    Extract frames at specified time intervals.
    
    Args:
        video_path: Path to the input video file
        output_dir: Directory to save extracted frames
        time_interval: Extract frame every N seconds
    """
    cap = cv2.VideoCapture(video_path)
    if not cap.isOpened():
        print(f"Error: Could not open video file {video_path}")
        return
    
    fps = cap.get(cv2.CAP_PROP_FPS)
    frame_interval = int(fps * time_interval)
    
    print(f"Extracting frames every {time_interval} seconds (every {frame_interval} frames)")
    extract_frames(video_path, output_dir, interval=frame_interval)


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Extract frames from surveillance video')
    parser.add_argument('--video', type=str, default='videos/sample.mp4', help='Path to video file')
    parser.add_argument('--output', type=str, default='frames/extracted_frames', help='Output directory')
    parser.add_argument('--interval', type=int, default=30, help='Extract every Nth frame')
    parser.add_argument('--start', type=int, default=0, help='Starting frame number')
    parser.add_argument('--end', type=int, default=None, help='Ending frame number')
    parser.add_argument('--time-interval', type=float, default=None, help='Extract every N seconds')
    
    args = parser.parse_args()
    
    if os.path.exists(args.video):
        if args.time_interval:
            extract_by_time_interval(args.video, args.output, args.time_interval)
        else:
            extract_frames(args.video, args.output, args.interval, args.start, args.end)
    else:
        print(f"Video file not found: {args.video}")
        print("Usage: python extract_frames.py --video <video_path> [options]")

131 lines•4.5 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