Build a Cartoon Camera

Application to transform camera photo into cartoon image.

Cartoon Camera

Overview

In previous articles I developed a web based object detection system using YOLO and a text recognition application using Tesseract. In this article let’s build a fun cartoon camera which transforms camera photo into cartoon image.

The Application

The is a web based application built using React and FastAPI. The frontend application uses the web camera to capture photo and send to the backend through web socket. The backend application transforms it into a cartoon image, and sends the cartoon image back to the web application.

There are different styles that you can apply to the image. Below is a snapshot of a transformed photo.

Cartoon Image

Backend APIs

The backend is built using FastAPI. It hosts APIs to serve CartooGAN: Generative Adversarial Networks for Photo Cartoonization using HTTP and web socket.

You can access the APIs using FastAPI built-in Swagger UI at http://localhost:8088/docs.

Below is the image used to test the API, using the Swagger UI.

Photo by Jay Mantri on Unsplash

And below are the images with different cartoon styles.

Hayao Style
Hosoda Style
Paprika Style
Shinkai Style

For details on how the backend is built and debugged, you can refer to the following articles.

Frontend Web Application

Frontend is a web application built using React. It uses the web camera to take photo and send captured image to the backend through web socket. For technical implementation you can refer to the articles mentioned above.

Summary

With the provided pre-trained models, it is relatively easy to host them using FastAPI and React. You can find the source code for this application from this repository.

Do check out the following articles!

References

Programmer and occasional blogger.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store