prusa3d / Prusa-Firmware-ESP32-Cam

Firmware for ESP32 Cam modules to be used in Prusa Connect
GNU General Public License v3.0
97 stars 10 forks source link

Camera Snapshots Based on Printer Activity #27

Open der-eine opened 1 month ago

der-eine commented 1 month ago

Hello and thank you for this great project.

I noticed that the camera always takes snapshots as soon as it is turned on. Is it possible to link this to the state of the printer so that pictures are only taken when the printer is actually working? Or have I overlooked a relevant setting?

Best regards, der-eine

johnyHV commented 1 month ago

Hello @der-eine . Currently, Prusa Connect does not have an API to allow the camera to determine the state of the printer. So camera continuously sends photos...

But the idea of connecting a printer with a camera is interesting. I will try to analyze this problem and find another solution.

der-eine commented 1 month ago

@johnyHV All right. Thanks for the info. I was hoping, since you are working very closely with Prusa, that this would be an option to query the status via the API.

Another question regarding snapshots: will there ever be a direct snapshot URL? To be able to send a snap via Telegram, for example? I already know the option of „calling http://ip/action_capture and then downloading it from http://ip/saved-photo.jpg.“

johnyHV commented 1 month ago

@der-eine I will open this topic at the next meeting with people from Prusa. It would be best to have an API from Prusa Connect. I believe that the API for the Prusa Connect about printer status will be added in the near future. It would also be good for them, so that they don't have such a big photo traffic.

You mean sending photo from the camera to telegram ? Prusa Connect have added this feature for printer status. But it is just text message without photo.

der-eine commented 1 month ago

@johnyHV That's a great idea. I also think that an API would be helpful for many things.

Thanks for the information. Correct, unfortunately, it currently only supports starting, stopping, and error messages. An option to send a photo via Telegram every x percent or at layer X would certainly be useful.

Anheledir commented 1 month ago

Just sharing my thoughts on this feature from an architectural perspective:

  1. Webhooks with Custom Endpoint:

    • Pros: Can start/stop camera updates based on printer activity.
    • Cons: Requires internet access, raises security concerns.
  2. Regular API Calls:

    • Pros: Reduces image traffic.
    • Cons: Impacts server resources due to frequent status checks.
  3. WebRPC Connection:

    • Pros: Offers direct control over the camera.
    • Cons: Requires additional implementation in Prusa Connect.
  4. Serial Connection Control:

    • Pros: Uses existing hardware connections.
    • Cons: Needs hardware/firmware modifications.
  5. Hardware Switch/Sensor:

    • Pros: Automatically triggers camera based on printer movements.
    • Cons: Involves hardware modifications, adds G-code complexity.
  6. Local Image Analysis:

    • Pros: No extra API or hardware required.
    • Cons: Could be unreliable in low light, requires initial setup.

Just a few ideas to consider, feel free to add more :)

VibroAxe commented 2 weeks ago

Given the camera is likely on the same network as the printer, it could query the prusalink API running locally on the printer for this instead of going via prusa connect.

The best option I can think of here would be to have different refresh rates based on printer state. So if the printer isn't moving it sends an image once every X minutes, once printing starts it sends every y seconds

mikromcz commented 2 weeks ago

Given the camera is likely on the same network as the printer, it could query the prusalink API running locally on the printer for this instead of going via prusa connect.

The best option I can think of here would be to have different refresh rates based on printer state. So if the printer isn't moving it sends an image once every X minutes, once printing starts it sends every y seconds

Connecting to the printer API sounds like a good idea to me. I already did my research and here you can see what is available on the API. (I'm using it for Homepage dashboard) https://github.com/mikromcz/homepage/blob/main/widget_prusalink.yaml widget_prusalink