Giter VIP home page Giter VIP logo

instacam's Introduction

Instacam

Filters for your webcam

This is a pet project motivated mostly by my desire to learn both Rust and FFmpeg

It grabs an input video feed (most likely your original webcam, but any video source should work, in theory), and outputs a transformed video feed.

Prerequisites

You need to create a virtual camera device on your system. Currently, I only know how to do this on Linux (instructions below).

If an equivalent tool exists for other systems, there should be no other major blockers to getting this to work (both FFmpeg and Rust are widely available in most systems).

Linux

Setup v4l2loopback, and create a virtual webcam, such as:

sudo modprobe v4l2loopback devices=1 video_nr=2 card_label="Instacam" exclusive_caps=1

On my machine, this creates a /dev/video2 device. Depending on how many you already have, yours might be named differently.

Setup

  1. Clone the repo
# clone the repo
git clone https://github.com/naps62/instacam.git
cd instacam
  1. Create a configuration file under ~/.config/instacam/config.json (changing each value acording to your system):
{
  "input": "/dev/video0",
  "output": "/dev/video2",
  "width": 1280,
  "height": 720,
  "fps": 30,
  "pipeline": [
    {
      "name": "preview"
    }
  ]
}
  1. Start the program:
cargo run

Using filters

After the initial setup, filters are configured mostly through the pipeline of the config file. You can compose the multiple existing filters, and the final image will be output to your output device.

For instance, the following pipeline:

"pipeline": [
  {
    "name": "pixelate",
    "k": 64
  },
  {
    "name": "sharpen"
  },
  {
    "name": "preview"
  }
]

Sample

Available filters

Preview

Does not alter the image, but renders the current frame in a window, allow you to see the result in different stages of the pipeline.

"pipeline": [
  {
    "name": "preview",
  }
]

Preview

Blur

Blurs the image by a given factor

"pipeline": [
  {
    "name": "blur",
    "k": 32
  }
]

Blur

Pixelate

Pixelates the image. k here is maximum desired number of pixels per line.

"pipeline": [
  {
    "name": "pixelate",
    "k": 128
  }
]

Pixelate

Sepia

"pipeline": [
  {
    "name": "sepia"
  }
]

Sepia

Sharpen

"pipeline": [
  {
    "name": "sharpen"
  }
]

Sharpen

Edge Detection

Mostly an experimental filter I was playing with, while learning more about the OpenCV API

"pipeline": [
  {
    "name": "edges",
    "t1": 100,
    "t2": 200
  }
]

Edges

Background Subtraction

Also an experimental filter, with a background subtractor algorithm. This sample image is hurt by my low-quality webcam, as well as the lack of a more prominent foreground in this picture.

"pipeline": [
  {
    "name": "bgsub"
  }
]

BgSub

About

Instacam was authored by Miguel Palhas.

The project is fully open-source. Use it as you wish.

instacam's People

Contributors

naps62 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.