# How I Use My Terminal as a Webcam

Te-We is a project which focuses on using a webcam just with a terminal. Powered by Python we will be creating a terminal stream of webcam.
One day I was going through my system to find a webcam application but was not able to find one because I use Debian Linux and I added each and every software manually, so I never downloaded anything for the webcam.
So I thought why not make something with a terminal for this, I came across a project which was an Image to Ascii Project and I thought why not combine the video stream with a similar project and hence TE-WE was developed

This whole thing is an Ascii Art of a video stream from the webcam.
If you find it interesting, you can find the whole unscripted programming video of it at

## Step 1

Create an Ascii Image using an actual image

## Step 2

Replace the Ascii Image with a video stream frame and print them one over the other to get the effect of a continuous frame.
Done!!

Let's Discuss everything in Detail, Our first aim would be to convert

to an Ascii Image like

Once it's Done all that's left is to create a video stream as a source for frames to the program.

Let's see the code first

Let me explain everything here. For now ignore the line 10–12, remaining part is simple, convert the whole RGB image to black and white image so that we can actually get the intensity of each pixel.
Then based on the intensity of each pixel we will find a suitable character for each pixel and create an image out of it.
But the problem is that its still black and white, so the next part would be to get the approx ANSI color for each pixel hence we will find the colored image printed.
Let's see the code to get RGB to ANSI, It was taken from a library

## torrycrass / image-to-ansi

### A Python based Image to ANSI converter

Here is the code, It's pretty simple and actually just based on some mathematical solution.
So with this, we will get the ANSI color code from RGB and them we just need to get the ANSI color for each pixel, and here the line 10–12 will come into action
We are using their RGB value for each pixel and saving the ANSI color code separately before converting the image to black and white.
And done, our first part is done.

## Step 2

Adding a video stream is simple and can be found anywhere, as it's just using opencv to get the frames from video and printing it on screen.
So here we are done.

## Feedback

Do leave feedback on the project, If you want to check out the source code. Here it is

## pr4k / Te-We

Posted on by:

### Prakhar Kaushik

Geek interested in learning new languages,