Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    Timelapse pictures & videos with Duet and webcam on layer change

    Scheduled Pinned Locked Moved
    General Discussion
    15
    43
    7.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T3P3Tonyundefined
      T3P3Tony administrators @resam
      last edited by

      @resam yeah I get that. I think the big opportunity is to add that complexity back in to compare commanded movement with what happens and what the model should look like so a failed print can be detected.

      www.duet3d.com

      1 Reply Last reply Reply Quote 0
      • garyd9undefined
        garyd9
        last edited by garyd9

        This thread can't be allowed to die... This tool is incredible, @resam

        I didn't bother with the "M400" or "G4 P500", and it's still perfect. If the snapshot isn't exactly on the layer change, it's okay. As long as I get a snapshot each layer, it's all good.

        It would be nice of the script had an option to automagically run ffmpeg and then (on success) remove the jpg directory. Perhaps if I ever get any free time, I'll add that functionality (and adjust the focus on my pi camera.)

        thank you!

        Edit: first time lapse using this code (camera is mounted in a temporary location, so haven't bothered with focus yet.) https://youtu.be/inLM1-AvhUo

        Gary

        "I'm not saying that you are wrong - I'm just trying to fit it into my real world simulated experience."

        1 Reply Last reply Reply Quote 1
        • bjoern85undefined
          bjoern85
          last edited by

          Can you make a small guide, how to set this up on an sbc?
          After cloning from github i don't know what to do... 😞

          I'm using another SBC with octoprint, webcam and octolapse. But the connection to the duet ethernet is not fast enough sometimes.

          I would love to make timelapses with my deltaprinter.

          Thank you for all your work 🙂

          resamundefined 1 Reply Last reply Reply Quote 0
          • resamundefined
            resam @bjoern85
            last edited by

            @bjoern85 did you try starting the script as documented in the README?
            From your SBC terminal (or SSH):
            ./timelapse.py <folder> <duet_host> <webcam_url>

            bjoern85undefined 1 Reply Last reply Reply Quote 0
            • bjoern85undefined
              bjoern85 @resam
              last edited by bjoern85

              @resam thank you! and sorry for my late reply. i'm testing it right now.
              it looks, like it works. somehow... i was able to download a single jpg file during the print, which has a size of 2gb 😵 but i could not open it.

              edit: ...achtion=snapshot instead of ...action=stream would help, i guess 🙃

              1 Reply Last reply Reply Quote 0
              • garyd9undefined
                garyd9
                last edited by

                I have to admit that my reply to this thread is, at least in part, a bump to keep it from dying... it's just too valuable.

                On the other hand, I do have updated information, @resam, in regards to using this script with RR3 on a Duet3 (in standalone mode.)

                For some reason, using the script from your github (pulled on 24th of Jan, 2020), the process would stop working after each print. It was almost as if the telnet session froze or locked up or something after the print finished and ffmpeg was run. I'd see the 'Print finished' message, the mp4 would be created, and then it wouldn't start again when a new print was started.

                I've modified my version of the script to deal with that by breaking from the "while true" loop after a print is finished and inserting the code below before the exception handler (at the same scope as the "while true"):

                conn = None
                sock.shutdown(socket.SHUT_RDWR)
                sock.close()
                

                This should break the loop, shutdown and close the socket, and then loop back up for another connection attempt (which usually works fine.)

                Take care
                Gary

                "I'm not saying that you are wrong - I'm just trying to fit it into my real world simulated experience."

                1 Reply Last reply Reply Quote 0
                • resamundefined
                  resam
                  last edited by

                  Thanks @garyd9 - I haven't tested it yet on RRF3 (still need to upgrade my printers).
                  I'm a bit surprised because we do have error handling that should auto-reconnect if any failure with the telnet socket occurs: https://github.com/Kriechi/DuetRRF-timelapse/blob/d2b472ceb26491f07812c030e00ee1005d69487b/timelapse.py#L136

                  I'm happy to add more error handling - but at this point I'm not sure what actually hangs/blocks. Or did anything in RRF3 change regarding the way telnet connections are handled @dc42?

                  1 Reply Last reply Reply Quote 0
                  • assasinscreed00undefined
                    assasinscreed00 @resam
                    last edited by

                    @resam So I'm a noob with python and rasperry pi's but I think I mostly understand the github and what i need to do, but you said you ditched mjpg streamer and instead use OpenCv, I can't find how to setup OpenCV to host the webcam image on a url. Can I still use mjpg streamer (seems easier for a noob to setup)

                    1 Reply Last reply Reply Quote 0
                    • resamundefined
                      resam
                      last edited by

                      @assasinscreed00 I don't remember saying I ditched OpenCV - I still use mjpg streamer, just like almost every tutorial on the internet.

                      assasinscreed00undefined 1 Reply Last reply Reply Quote 0
                      • mrehorstdmdundefined
                        mrehorstdmd
                        last edited by

                        I took a different approach. I had to replace my Droid Turbo phone because it was a few years old and I had cracked the screen and some critical apps would no longer work right, so I put it to use monitoring my printer.

                        My printer has clear PC front doors so I made a simple suction cup mounted holder for the phone that sticks to the door and provides a good view of the bed plate. I loaded the phone with an app called Open Camera that includes the ability to program it to automatically snap images at whatever interval you desire. I then set up Google Photos to back up the images snapped by the camera. The backup happens as soon as each image is snapped.

                        alt text

                        I power the phone with a USB wall wart and usually program it it to take pictures at 30 second intervals. The phone camera can produce 24 Mp images, so much better resolution than you can ever get from a RPi camera. Open Camera optionally labels each image with the time and date it was made. If I'm running a long print I can check status by opening Google Photos and viewing the most recently uploaded image.

                        When the print is done, if I want to make a video, I batch scale the images to whatever resolution I want in the video using irfanview and then convert the image sequence to an .avi file using ImageJ. All the software is free and has no advertising, and no subscription fees, and all of it works reliably.

                        Sample image:

                        alt text

                        More here: https://drmrehorst.blogspot.com/2019/08/putting-old-cell-phone-to-good-use.html

                        The camera doesn't sync with layer changes, and I can't use it to kill the printer if a print fails, but that's a pretty rare event.

                        I set it up to make a timelapse video of my corexy sand table recently.

                        https://vimeo.com/381844758

                        https://drmrehorst.blogspot.com/

                        1 Reply Last reply Reply Quote 0
                        • assasinscreed00undefined
                          assasinscreed00 @resam
                          last edited by

                          @resam

                          @resam said in Timelapse pictures & videos with Duet and webcam on layer change:

                          @T3P3Tony probably - but the idea behind using OpenCV and ditching mjpg-streamer was to REDUCE complexity 😄

                          For people who want to keep their DWC webcam, you should probably still use mjpg-streamer (unless somebody knows of a similar / better tool?)

                          this comment is where I thought you said it, I assume I am reading it wrong?

                          1 Reply Last reply Reply Quote 0
                          • anironundefined
                            aniron
                            last edited by aniron

                            Is there anything in principle preventing this from working on the older Duets, like the 0.6?

                            Danalundefined 1 Reply Last reply Reply Quote 0
                            • Danalundefined
                              Danal @aniron
                              last edited by

                              @aniron said in Timelapse pictures & videos with Duet and webcam on layer change:

                              Is there anything in principle preventing this from working on the older Duets, like the 0.6?

                              Could you restate what "this" is? Lots of things discussed above... 🙂

                              Delta / Kossel printer fanatic

                              anironundefined 1 Reply Last reply Reply Quote 0
                              • anironundefined
                                aniron @Danal
                                last edited by

                                @Danal sorry, I was referring to the OP. Didn't realise how old it was.

                                "Requirements
                                DuetWifi or Duet Ethernet or Duet 2 Maestro controlled printer
                                RepRapFirmware v1.21 or v2.0 or higher"

                                1 Reply Last reply Reply Quote 0
                                • Danalundefined
                                  Danal
                                  last edited by Danal

                                  Ah, got it. OP will need to answer.

                                  I've been intentionally not "stepping on toes" because both @resam and I have tools that do lapse-to-video. Each has its strengths and weaknesses.

                                  But I will mention mine... The one linked below "duetLapse" should be able to interact with any Firmware V2 or V3. It was developed to run on a Pi, but could potentially run anywhere that Python runs. It only needs to be able to open the camera, and to reach the printer via network.

                                  https://github.com/DanalEstes/DuetLapse

                                  Delta / Kossel printer fanatic

                                  1 Reply Last reply Reply Quote 0
                                  • resamundefined
                                    resam
                                    last edited by

                                    I don't see any specific reason why it should not work on a Duet 0.6 - as long as it runs RRF 1.21 or later and has Telnet active.

                                    1 Reply Last reply Reply Quote 0
                                    • Damienundefined
                                      Damien
                                      last edited by

                                      This post is deleted!
                                      1 Reply Last reply Reply Quote 0
                                      • Damienundefined
                                        Damien
                                        last edited by Damien

                                        Hi all,

                                        Finally got a Raspberry Pi 4B, have it setup sand installed and working with Duet RFF Timeplase. I've got the Pi taking pics of the print on layer change.

                                        My question is regarding the layer change script. How should I add a line to the script to tell the print head to move to a specified place before each pic, without messing up the core programming?

                                        Thanks in advance!!

                                        mrehorstdmdundefined 1 Reply Last reply Reply Quote 0
                                        • mrehorstdmdundefined
                                          mrehorstdmd @Damien
                                          last edited by

                                          @Damien I have modified my set up to sync with layer change- it requires no wiring or hacks other than adding a little custom g-code on layer change. I use a bluetooth button to trigger the cell phone camera.

                                          The custom g-code is in the printer profile tab of the slicer, so I made a layer sync specific printer profile. When I want to make layer synced video, I use that profile when I slice, otherwise I use a normal profile.

                                          layer synchronized time lapse in the making

                                          layer synchronized time lapse

                                          https://drmrehorst.blogspot.com/

                                          1 Reply Last reply Reply Quote 0
                                          • Hugo Hiaslundefined
                                            Hugo Hiasl
                                            last edited by Hugo Hiasl

                                            Hi everybody,

                                            is that solution able to do both? Stream a video to the DUET3D web front end to check if the print is still working as expected AND creating time lapse (time based or on layer change) at the same print in parallel?

                                            Or is it only for making time lapse?

                                            My plan ist to get a raspberry pi (3, 4 or zero) in combination with a logitech HD920 cam.

                                            wilrikerundefined 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Unless otherwise noted, all forum content is licensed under CC-BY-SA