npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

openproctor

v0.0.2

Published

A open source proctoring SDK with face detection and media stream uploading

Downloads

3

Readme

Here’s a README.md file for your project, covering all the steps and guidelines for getting started with your proctoring SDK, implementing face detection, and handling contributions.


OpenProctor is an open-source Proctoring SDK with Face Detection and Media Stream Uploading

This repository contains a Proctoring SDK that allows:

  • Capturing camera, microphone, and screen share streams.
  • Real-time face detection using TensorFlow.js BlazeFace.
  • Streaming and uploading media streams to a server for analysis and storage.

Features

  • Camera, Microphone, and Screen Sharing: Capture video, audio, and screen streams.
  • Real-time Face Detection: Detect faces from the camera stream using BlazeFace.
  • Proctoring Setup: Control when to start and stop media streams and face detection.
  • Stream Uploading: Send media streams (video, audio, screen) to a server for storage and analysis.

Table of Contents

  1. Get Started
  2. Using the SDK
  3. Face Detection
  4. Uploading Streams to Server
  5. Contribution Guidelines

Get Started

Prerequisites

  • Node.js (version 14 or later)
  • npm or yarn

Clone the Repository

git clone https://github.com/your-username/proctoring-sdk.git
cd proctoring-sdk

Install Dependencies

Install the dependencies using npm or yarn:

npm install

or

yarn install

Start the Development Server

npm run dev

This will start the Next.js development server. Visit http://localhost:3000 in your browser to view the application.


Using the SDK

Importing the Proctoring SDK

The SDK provides functions to set up the camera, microphone, screen sharing, and face detection. Use the alias @/lib to import the SDK components in your project.

import { Proctor } from '@/lib';

Starting Proctoring

To start capturing the camera, microphone, and screen sharing, and run face detection:

Proctor.setup({
  onVideoFrame: (cameraStream: MediaStream) => {
    // Handle the camera stream (e.g., attach to a video element)
  },
  videoElement: videoRef.current,  // The video element for face detection
  canvasElement: canvasRef.current,  // The canvas element to draw face boxes
  onAudioStream: (audioStream: MediaStream) => {
    // Handle the audio stream
  },
  onScreenStream: (screenStream: MediaStream) => {
    // Handle the screen sharing stream
  },
  onTabSwitch: () => {
    // Handle tab switch detection
    alert('You switched tabs! Please return to the test.');
  }
});

Stopping Proctoring

To stop all active streams and face detection:

Proctor.stopCamera();
Proctor.stopMicrophone();
Proctor.stopScreenShare();

Face Detection

This SDK uses TensorFlow.js BlazeFace for real-time face detection. The face detection model is loaded automatically when the camera stream starts. The results (face bounding boxes) are drawn on a canvas overlay.

How It Works

  1. The BlazeFace model is loaded and used to detect faces in real-time from the camera feed.
  2. Face bounding boxes are drawn on a canvas overlaid on the video stream.

Key Code for Face Detection

Face detection is set up when the camera stream is initialized:

import { FaceDetection } from '@/lib/faceDetection';

Proctor.setup({
  onVideoFrame: (cameraStream: MediaStream) => {
    // Attach the camera stream to the video element and start face detection
    FaceDetection.detectFaces(videoRef.current, canvasRef.current);
  },
  videoElement: videoRef.current,  // The video element for face detection
  canvasElement: canvasRef.current  // The canvas element to draw face boxes
});

Uploading Streams to Server

The SDK includes a StreamUploader class that allows you to capture and upload the media streams (camera, microphone, and screen) to a server for analysis and storage.

How to Use the StreamUploader

import { StreamUploader } from '@/lib/streamUploader';

// Initialize the uploader
const uploader = new StreamUploader({
  videoStream: cameraStream,
  audioStream: audioStream,
  screenStream: screenStream,
  serverUrl: 'https://your-server-url/upload'  // Server endpoint to upload streams
});

// Start uploading the streams
uploader.start();

Server-Side Example (Express.js)

The following is an example of an Express.js server to handle media uploads:

const express = require('express');
const multer = require('multer');
const path = require('path');
const fs = require('fs');

const app = express();
const port = 3000;

const storage = multer.diskStorage({
  destination: (req, file, cb) => {
    const uploadDir = path.join(__dirname, 'uploads');
    if (!fs.existsSync(uploadDir)) {
      fs.mkdirSync(uploadDir);
    }
    cb(null, uploadDir);
  },
  filename: (req, file, cb) => {
    cb(null, file.originalname);
  }
});

const upload = multer({ storage });

app.post('/upload', upload.single('file'), (req, res) => {
  console.log(`File uploaded: ${req.file.originalname}`);
  res.status(200).send('File uploaded successfully.');
});

app.listen(port, () => {
  console.log(`Server listening at http://localhost:${port}`);
});

Contribution Guidelines

We welcome contributions to this project. Here’s how you can contribute:

1. Fork the Repository

Fork the project repository to your own GitHub account by clicking the Fork button at the top right of the repository page.

2. Clone Your Fork

Clone your fork to your local machine:

git clone https://github.com/your-username/proctoring-sdk.git

3. Create a Branch

Create a new branch for your feature or bug fix:

git checkout -b feature/new-feature

4. Make Your Changes

Make your changes in the codebase, and be sure to write unit tests for any new functionality.

5. Run Tests

Ensure that all tests pass before submitting your changes:

npm run test

6. Commit and Push

Commit your changes and push the branch to your fork:

git add .
git commit -m "Add new feature"
git push origin feature/new-feature

7. Submit a Pull Request

Submit a pull request to the main repository, and provide a detailed description of your changes.


License

This project is licensed under the GNU License 3.0.


Let me know if you need any further clarifications or additions to the README.md!

Contact

👋 [email protected]