Time lapse video with node-red and esp32 camera (via esphome)
 
Notifications
Clear all

Time lapse video with node-red and esp32 camera (via esphome)  

  RSS
_KaszpiR_
(@_kaszpir_)
Reputable Member
Time lapse video with node-red and esp32 camera (via esphome)

I've got a working setup with node-red and esp32 camera running esphome to make capturing images if the printer is working.
It is not published anywhere yet, so I wanted to gather some info if someone would be interested in this.
Thinking about uplaoding it into github.

Initial idea:
- making time lapse videos without any special software which controls printer itself, that is I wanted to avoid any software that alters gcode or requires access printer via USB. The fact that Prusa Mini has basic web API makes possible.
- taking photos would depend on if the printer is up and printing, there is no point in capturing images if printer is off or not printing.
- taking photos does not have to be realitme or fast, we usually need image once per 10 seconds.
- I know  I can add printer to HomeAssistant, but my experience with HomeAssistant is a bit problematic, mainly because development phase - so let's try something I always wanted to use but never had a urge to implement, and that is node-RED.

Current setup:
- printer - Prusa Mini+ connected via ethernet to the LAN, exposing its API, we need only reading capability.
- camera - esp32 (to be precise esp32-wrover-e) with camera OV2640, with installed esphome camera + web components - this allows to fetch current camera image via web or even stream (but it is slow). Frankly speaking if you have any camera that allows to fetch image via web (non-stream right now) then it would work.
- logic - node-RED with the flows which holds and executes the logic if the photo should be taken and stored
- additional hardware - any computer, which used to host some extra apps:
  - MQTT server (via mosquitto) which is required for node-RED to operate
  - node-RED
  - extra app to process images into a move sing ffmpeg

What works:
- node-RED + mqtt in containers (docker), could be run directly on host
- logic flow - capturing images to directory if printer is printing
- rendering images into a movie using ffmpeg

Known limitations:
- due to the fact I run it in container which does not have ffmpeg I need to manually execute script to merge images into a video, I bet that can be fixed by just installing ffmpeg within container but for now I wanted to avoid it
- all images are dumped into one directory, I'm planning to add variable to detect if the print is happening and when it started to create directory and store images there -  easier to manage if printing more than one thing in a sequence
- only one printer/one camera is supported - would require better modularization
- basic web ui dashboard, it's crap but provides core info 🙂

Any questions, ideas, comments welcome.

See my GitHub and printables.com for some 3d stuff that you may like.

Posted : 27/05/2023 8:43 am
John Doe
(@john-doe-3)
Estimable Member
RE: Time lapse video with node-red and esp32 camera (via esphome)

I looked on many timelapse kind of applications and there are a lot of more information that is necessary. For example, how long the extruder should wait for the camera to take s photo and continue and also how long to wait for the "service" to make a photo.  Should a retraction be called, to not affect the printed object and so on... I think Octolapse is here the best choice for you, as it can trigger a script (instead of making a photo), that can contact your home asisstant to make a photo. Basically time is there the issue.

 

In octoprint, you can setup a trigger to run a linux/windows command, when a layer is changed.

I made a python script, that is called by Octolapse, that in parallel matter makes a photo on all connected cameras(as soon as poccible) and after all are done, merge them together. And saving the photo with name and location as octolapse expect.

Posted : 28/05/2023 4:42 pm
_KaszpiR_
(@_kaszpir_)
Reputable Member
Topic starter answered:
RE:

As I stated in first post I just not need extra software which would interfere with my current printing setup - PrusaSlicer and original Prusa firmware are just working perfectly well in my case.

For now the only issue that I am experiencing is sometimes slightly blurry image due to camera wobbling ( I really have to fix camera better in place so the whole mount is more rigid.

Multi camera capture is interesting but for now I do not feel that I need it but may be worth a try in the future.

Right now I'm thinking about integrating maybe image recognition to detect failed print - I know this can be done locally with some machine learning tools ( did something related to it previously), but haven't looked around at what is already done in 3D printing area in that matter.

But first I guess I should focus on publishing the source code of what I have maybe this week.

See my GitHub and printables.com for some 3d stuff that you may like.

Posted : 29/05/2023 10:30 pm
_KaszpiR_
(@_kaszpir_)
Reputable Member
Topic starter answered:
RE:

Code + docs, if someone finds problems please make issue on Github or write in this thread. (it's not fully tested because I have a bit different setup right now, but overall the node-red flows are copy/paste with removed sensitive data)

https://github.com/nvtkaszpir/prusa-esp32-node-red-time-lapse

See my GitHub and printables.com for some 3d stuff that you may like.

Posted : 04/06/2023 8:53 pm
_KaszpiR_
(@_kaszpir_)
Reputable Member
Topic starter answered:
RE: Time lapse video with node-red and esp32 camera (via esphome)

I have updated the code under https://github.com/nvtkaszpir/prusa-esp32-node-red-time-lapse

major changes:

- all in one flow - easier to add more printers/cams
- configuration in one node (see above)
- docker-compose has it all and works end to end, so you can adjust it to your needs, especialy if you have custom printer.

See READMe.md and docs/ for more details,

See my GitHub and printables.com for some 3d stuff that you may like.

Posted : 15/08/2023 8:31 pm
_KaszpiR_
(@_kaszpir_)
Reputable Member
Topic starter answered:
RE:

Small update:
- I think  with current code I reached what I wanted in the first place. There are some limitations how it works but that's ok. This is v1.0 as is and I don't thing more is needed to update.

- I'm thinking about making better quality timelapses, and indeed the only way to do it is to use custom gcode to move print head out of the image to have a clean view and also to reduce blurred images due to the fact that bed/print-head is moving or moving parts cause camera to wobble.
The best option would be to add some button to the side of the printer - thinking about possible ways to make it resilient to errors and I guess Reed switch + small neodymium magnet would be sufficient to trigger initial message to mqtt so that the flow would be triggered and photo taken.
Other ideas - take multiple photos and stitch them together (like from multiple cameras), but I guess I would use some cli script to merge them using ImageMagick pack via some shell script, or python exec.
I guess that's for v2.0 of the flow for the future. When? Not sure, maybe mid November?
Thoughts?

See my GitHub and printables.com for some 3d stuff that you may like.

Posted : 30/08/2023 9:24 pm
_KaszpiR_
(@_kaszpir_)
Reputable Member
Topic starter answered:
RE: Time lapse video with node-red and esp32 camera (via esphome)

I'm finalizing version 2 with using custom gcode, most of it is ready and tested for over a month now, expect some repo pushed this weekend.

Preview (direct url, looks like forums video embed is still broken):

https://storage.googleapis.com/prusa3d-content-prod-14e8-wordpress-forum-prod/2023/11/85f73ade-2023-11-10_2.mp4

See my GitHub and printables.com for some 3d stuff that you may like.

Posted : 15/11/2023 8:49 pm
_KaszpiR_
(@_kaszpir_)
Reputable Member
Topic starter answered:
RE: Time lapse video with node-red and esp32 camera (via esphome)

Updated repo, more details in the readmes and docs subdirectory.

See my GitHub and printables.com for some 3d stuff that you may like.

Posted : 19/11/2023 9:48 pm
Share: