Qqwy
How to build a photobooth with Elixir+Nerves?
So, I finally have a good reason to start tinkering with Nerves! ![]()
I’ve been asked by the student association to jamble together a Photobooth for an upcoming party. So, I want to take this opportunity to write a Nerves-application on top of a Raspberry Pi.
I already found the Picam elixir/nerves library to take pictures with the Raspi’s camera. What I am still looking for is a way to interact with a (touch?)screen from within Elixir/Nerves, because I’d really like to show the camera preview on there.
Should I just go ahead and use the Erlang Wx-bindings for that? Or is there a better way?
And is there already a way to read out touch screen presses from within Nerves?
Most Liked
GregMefford
Cool project! @mobileoverlord and @electricshaman have spent a lot more time on the Le Tote kiosk system than I have, but I’m surprised that it doesn’t load content from localhost. Is it possible that the Phoenix server you’re running is not listening on the localhost interface or is blocking the page due to other security constraints? If you’re not sure, I’ve found it really helpful to remotely attach to the Chrome Remote Debugger from my laptop, so I can see the embedded browser’s error console and such. We have an internal way that we do that at Le Tote, but I don’t fully understand how it works myself, so I’ll defer to the others to explain that process.
In my experience, using a Plug-based MJPEG video streamer with Picam is significantly more performant than passing frames individually over a Phoenix Channel connection. I suspect it’s mostly the overhead of re-encoding the frames as Base64 and wrapping them in the Channel payload, because it’s slow even when you’re viewing it on a modern laptop.
When using MJPEG streaming to a laptop, I’m able to get smooth video performance even at 1080p, but I haven’t tried doing it locally in a kiosk the way you’re describing. I think the “right” way to do that is probably to avoid sending it through JavaScript at all, as you mentioned, but I think we’d need to add some more features to Picam to support that.
outlog
the camera is easy to hookup and interface.. I did one with phoenix/nerves and after the Drab boilerplate it took like 5 minutes to have it working - press a button, base64 it and show it in the browser.. (accessed from a desktop browser pointed at the phoenix server)
so you could do that, and then interface it from an ipad/laptop or similar.
you can then progress it with GitHub - nerves-web-kiosk/kiosk_system_rpi3: Nerves QtWebEngine Kiosk system for Raspberry Pi 3 · GitHub and a screen/touch interface running on the rpi itself..
so probably what I would recommend, you quickly have a working solution, and then you can progress that to running on the pi itself..
Qqwy
It has been quite smooth sailing so far.
- Installing Phoenix on a Nerves system is a breeze.
- Working with the Raspberry Pi camera using Picam is quite easy.
- Using the Kiosk mode is okay, but you will really need the FTDI/UART to USB cable to debug it (since the screen will obv. only show the kiosk webpage).
Only (super minor) gotcha’s I’ve had are:
- My router does not seem to like Rpi’s, so connecting using WLAN is not possible over there (I now use my mobile phone as hotspot).
- The kiosk connects using the internet connection
:nerves_network, :ifacerather than whatever you’ve set up as default in your:nerves_network, :defaultconfiguration. - The kiosk will only load a local page (like the local phoenix) when using IP address
0.0.0.0. I don’t know why but127.0.0.1andlocalhostwill result in anERR_NETWORK_CHANGEerror page in the webkit kiosk browser. - The Picam library has a nice example of streaming camera images to the browser using an mjpg stream. This works fine when connecting to the Pi with an outside device (and using that device’s browser), but the kiosk webkit variant will only load the first frame of the stream.
Currently I’m investigating other ways to load the camera feed as a ‘stream’. Now fetching individual images in an interval, although I think that sending JPGs over a persistent websocket connection (a Phoenix channel) might be faster.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









