Qqwy
TypeCheck Core Team
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?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
alexfilatov
I believe this would be a better way as far as this become available:
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.
Only (super minor) gotcha’s I’ve had are:
:nerves_network, :ifacerather than whatever you’ve set up as default in your:nerves_network, :defaultconfiguration.0.0.0.0. I don’t know why but127.0.0.1andlocalhostwill result in anERR_NETWORK_CHANGEerror page in the webkit kiosk browser.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.
Qqwy
The current progress can be tracked over here on GitHub. Do note that this is rushed late-evening code because it is for a party I will be hosting with a couple of friends in less than a week from now; first make it work, then make it clean
.
New developments:
Sending PiCam images between the server and the Kiosk-Browser is slow
Currently there’s less than five frames per second with a delay of one or two seconds. This is not strange, because the Picam is currently read out from the actual camera inside Phoenix (using the Picam library that wraps a C library using a port), and then each of these images is sent to the front-end over a local socket connection.
At first I thought it was the rendering that was slow, but I actually think that it is mostly the copying over from the backend to the frontend, which of course increases cubically once you try to increase the (width, height, frames per second).
A better approach would be to use the Picam as a ‘user webcam’ using modern browser’s
getUserMediafunctionality. The Qt-Webengine supports this. However: For user safety, this is only allowed on anhttpsdomain or on localhost.But I currently host the app on
http://0.0.0.0because even when enteringhttp://localhostas the page to connect to, the kiosk browser shows anERR_NETWORK_CHANGEDerror page. If anyone knows how to resolve this problem, I would be very grateful!outlog
fyi, repo gives 404 - so can’t comment on code.. I assume you push the image, and have played with Picam.set_fps and Picam — Picam v0.4.1
which rpi is it? the original is dogslow compared to the rpi3.. also try pointing the kiosk to a static page and access the nerves/phoenix server from a desktop browser to check performance..
one idea would be to use http://jsmpeg.com - but I think you have to mux to ts, which I’m not sure how easy it is to do..
another idea would be to add a thermal printer, so it prints 4 monochrome images out like a classic photobooth..
Qqwy
Ah! Good catch; I still had the repository set to
private. Fixed nowI am using a Raspberry Pi 3, and vist a static Phoenix page using its Kiosk. This page contains a canvas (At first I tried using an image tag with an
mjpgsource like the Picam example uses, but theqt-webengine-kioskwill only show the first image of the stream.), and will periodically load a new image by calling another Phoenix endpoint.outlog
random thoughts:
think Picam.set_size is a resize op (so not totally free).. try Picam.set_sensor_mode(4) as well to ensure the raw image isn’t 3k+ px wide (binning should also improve quality) - and set_size as full, half or quarter size of the raw image size (depends on which camera v1/v2 you have) for optimal resize qual/speed - and Picam.set_fps to something reasonable like 5 to begin with.. see if that stream thing can be made to work..
I would also try to slow down the stream example, but ymmv eg:
another thing that caught my eye is that you are taking two images and IO.inspect()ing what I assume is a sizable jpg in the take_picture function.. so maybe stick to one image and no logging out a big binary..
if you are adventurous you can try and bump the qt build from 5.6 to 5.10 and get a much more recent chrome/webengine with BR2_PACKAGE_QT5_VERSION_LATEST=y in nerves_defconfig - I do assume breakage though.
I did it with Drab, pushing the image base64 encoded.. I don’t remember specific latency (as it was turning on leds to illuminate first, waiting for camera adjust and then snapping the photo) - but if you haven’t tried Drab, maybe a good time to do so, should give you tighter control of the updating/loop, and avoid writing client js..
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 thelocalhostinterface 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 withPicamis 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
Picamto support that.Qqwy
Yes, this is definitely true, and Picam has an example of how to set it up where it streams directly into an
<img />tag. This works on Chrome and FireFox on my laptop. However, the QtWebkit that the Le Tote kiosk uses will for some reason (old version of Webkit?) only render the first frame of the MJPEG stream, which means that this option is not possible.Attaching the remote debugger to there is a very smart idea
.
paulanthonywilson
Hi,
Sorry for coming to this thread late.
Yes, Base64 encoding and sending over Phoenix channels gets pretty juddery. I’ve had pretty good success with raw websockets and sending the individual JPEGs as binary messages.
I’ll look into opening the projects if anyone’s interested.