This project is a web application that captures video from the camera and converts it into ASCII art in real-time. The application is built using React and uses context for processing video frames.
The main entry point of the application. Here, the application is rendered into the DOM using React's StrictMode
. This file also includes the styles and the context for video frame processing.
The App
component is responsible for connecting the AsciiArt
and VideoStream
components. It receives the ProcessVideoFrameContext
through props and uses it to pass necessary functions and refs to the child components.
The export file for components. It exports AsciiArt
and VideoStream
components for use in other parts of the application.
The AsciiArt
component is responsible for displaying the ASCII art. It contains a hidden canvas for processing video frames and a <pre>
element for rendering the ASCII art.
The VideoStream
component captures video from the camera using the getUserMedia
API. The video is displayed in a mirrored format, and each frame is passed to the processVideoFrame
function for ASCII conversion.
The context component that provides the processVideoFrame
function along with refs for the canvas and ASCII art output. The processVideoFrame
function processes video frames, converts them to grayscale, and then to ASCII characters.
The stylesheet for the application, defining the basic styles.
- Ensure that you have Node.js installed.
- Clone the repository.
- Install the dependencies using
npm install
. - Start the application using
npm start
.
Component for displaying ASCII art.
- props:
canvasRef
: a reference to the hidden canvas element.outputRef
: a reference to the<pre>
element for rendering ASCII art.
Component for capturing video from the camera.
- props:
processVideoFrame
: function for processing each video frame.
Context provider that supplies functions and refs for video frame processing.
- children: child components that will be provided with the context.
- originalWidth: original width of the video.
- originalHeight: original height of the video.
- width: width of the canvas for video processing (half of the original width).
- height: height of the canvas for video processing (half of the original height).
- asciiCharacters: string of ASCII characters used for image conversion.