How to build a photobooth with Elixir+Nerves?

I’ve realised that we’ve a public version already. I recall it took a while to figure out but it’s actually super simple.

It uses a Cowboy (1) Websocket handler to serve the images over binary. It could do with a bit more of a tidy, tbh, but anyway:

The server is set up here: https://github.com/CultivateHQ/marty-nerves/blob/master/apps/image_server/lib/image_server/application.ex

The websocket handler is here: https://github.com/CultivateHQ/marty-nerves/blob/master/apps/image_server/lib/image_server/images_from_camera_websocket_handler.ex . It sends an image once very 50 milliseconds.

The Javasript on the other end is here: https://github.com/CultivateHQ/marty-nerves/blob/master/apps/marty_web/assets/js/camera.js

4 Likes