DuetLapse available for Alpha testing
-
@Danal said in DuetLapse available for Alpha testing:
Keep the ideas coming!
In my customised build of Raspbian with duetpi I created a timelapse.desktop entry so that I can access your program from my start menu.
By default I set it to take a picture upon Z movement.
So now, when I start a print and the printer is ready all I have to do is click on the program entry in the start menu.Thank you again danal for giving us this great program.
-
I've set it up and it works
I did get an error on a small print doing a quick test though
The error was "requests.exceptions.ConnectionError:('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))"
My guess (Although I'm not a Python expert) is that the pi couldn't keep up saving the images as the layers were only taking 20sec (And its an old V2 pi)
-
@kingfisher
I actually think it might be my Duet wifi board causing an error. I've also got a duet maestro and running the same python settings on the maestro IP address hasn't resulted in the "('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))" error -
Updates based on feedback:
-
Added -dontwait flag. This causes the script to not wait for a print to start; it captures images immediately. Of course, it will only capture things that happen... Example: If told only to capture on layer changes, well, that won't happen prior to a print...
-
Added 'camparms -parms' subsection to command line flags. Anything in that subsection is passed to the camera command (whichever for the appropriate camera type, fswebcam, raspistill, or wget)
-
Removed pallet from fswebcam (USB attached cameras, despite its name). It will automatically attempt to find the best, or you can specify one, example:
./DuetLapse.py -duet 192.168.7.101 -dontwait -seconds 3 camparms -parms -p YUYV -
Removed -q from fswebcam. Default is 35. You can override, same as above.
-
Slightly changed the loop timer, to beat on the printer a little less often.
*** IMPORTANT *** Found a bug in DuetWebAPI and fixed it, you must download this as well. Therefore, pull these two things into the same directory. One way to do this would be:
wget https://raw.githubusercontent.com/DanalEstes/DuetLapse/master/DuetLapse.py chmod 744 DuetLapse.py wget https://raw.githubusercontent.com/DanalEstes/DuetWebAPI/master/DuetWebAPI.py
-
-
Also, added quotes around the wget URL.
-
Still thinking about overlay of Z, print time, etc.
-
-
@Danal what ide / dev tools do you use for python development. I'm using Eclipse for c/c++ and Netbeans for Java. Is there a tool for python that will allow local (Ubuntu) testing and remote deployment to the pi?
-
For Python, I edit with Sublime on a PC. It could be any editor or IDE that you like that has syntax highlighting or whatever. I interface to the Pi by doing this on the Pi:
# If you want to be able to edit files on the Pi from windows, via a netshare (not a mapped drive): sudo apt-get install samba sudo smbpasswd -a pi sudo nano /etc/samba/smb.conf # and change 'read only = yes' to no. # Then use a UNC like '\\192.168.7.101\pi' in a file open in your favorite editor. # Quite often, you may have to start with just the "\\192.168.7.101" and no subdirectory to get # it to prompt you for userid and password. Use 'pi' and the password you set above. # You may have to try and retry several times to get connected. It's worth it. # BE SURE that your editor HONORS UNIX LINE ENDS and that you turn them on in any new files. # For windows users, I suggest notepad++ or atom or Sublime Text (that last one costs money. Worth every penny)
The big key is the UNC on Windows. \192.168.7.101\pi This is NOT a drive share... and doesn't behave like SMB shares behave. In sublime, if I do an "open folder" on that UNC, I can then click into \192.168.7.101\pi\DuetLapse (or whatever) and see all the files.
Note: This WILL cause your editor to hang if it has files/folders open and the Pi goes away. In sublime, I set it to NOT re-open whatever it had at close...
Testing? For python there is no "make" or "build" phase, so I just test directly on the Pi. Either VNC if I need graphics, or Winterm and ssh if not.
You can, in theory, test on your desktop distro, by building enough "context" around the thing you are testing. Directories, etc. However, many of the things that I'm testing (not necessarily the stuff you are seeing for Duet) is so tightly related to interfaces or other structures in Raspbian and/or the actual Pi hardware, it is just easier to test there.
For cross compile, like binaries for ESP32, or the Atmel chips, or similar, I still edit in Sublime, with the PlatformIO plugin. This makes it a cross-platform IDE. I've come to really like PlatformIO (as vs. the more 'Arduino' like environments). It runs a mini-RTOS and is very well documented and very flexible.
If I'm working with stuff developed by others for Atmel, then it is Atmel studio all the way.
That covers pretty much everything that fits a pattern. There are, of course, one-off environments for exceptional cases.
-
@Danal thanks - very interesting.
-
@tekkydave said in DuetLapse available for Alpha testing:
@Danal thanks - very interesting.
Just noticed the text handling, OUTSIDE the code block, make double backslashes into single. Use the double, as shown in the code block
-
Just FYI if you need streaming as well as time lapse. I set up ustreamer as the "owner" of the camera and pointed DuetLapse at its "/snapshot" URL. That way I have both a live stream and the time lapse at the same time.
-
"camparams" error
dunno if this helps[root@localdev LAPSE]# ./DuetLapse.py -duet http://ender5.local.lan Traceback (most recent call last): File "./DuetLapse.py", line 257, in <module> init() File "./DuetLapse.py", line 74, in init camparms = args['camparms'] KeyError: 'camparms' [root@localdev LAPSE]# ./DuetLapse.py -duet ender5.local.lan Traceback (most recent call last): File "./DuetLapse.py", line 257, in <module> init() File "./DuetLapse.py", line 74, in init camparms = args['camparms'] KeyError: 'camparms' [root@localdev LAPSE]# host ender5.local.lan ender5.local.lan has address 192.168.89.246 [root@localdev LAPSE]# ./DuetLapse.py -duet 192.168.89.246 Traceback (most recent call last): File "./DuetLapse.py", line 257, in <module> init() File "./DuetLapse.py", line 74, in init camparms = args['camparms'] KeyError: 'camparms' [root@localdev LAPSE]# python --version Python 3.7.6 [root@localdev LAPSE]# [root@localdev LAPSE]# fswebcam -d /dev/video0 -F 1 kkk --- Opening /dev/video0... Trying source module v4l2... /dev/video0 opened. No input was specified, using the first. Adjusting resolution from 384x288 to 352x288. --- Capturing frame... Captured frame in 0.00 seconds. --- Processing captured image... Unable to load font 'sans': Problem doing text layout Disabling the the banner. Writing JPEG image to 'kkk'.
and here you can see how non python developer try to follow up before giving up
[root@localdev LAPSE]# ./DuetLapse.py camparms -h usage: DuetLapse.py camparms [-h] [-- ...] camparm -parms xxx where xxx is passed to fswebcam, raspistill, or wget. optional arguments: -h, --help show this help message and exit -- ..., -parms ... Extra parms to pass to fswebcam, raspistill, or wget. [root@localdev LAPSE]# ./DuetLapse.py -duet 192.168.89.246 -camera usb -parms -d /dev/video0 usage: DuetLapse.py [-h] -duet DUET [-camera {usb,pi,web,dslr}] [-seconds SECONDS] [-detect {layer,pause,none}] [-pause {yes,no}] [-movehead MOVEHEAD MOVEHEAD] [-weburl WEBURL] [-dontwait] {camparms} ... DuetLapse.py: error: invalid choice: '/dev/video0' (choose from 'camparms') [root@localdev LAPSE]# ./DuetLapse.py -duet 192.168.89.246 -camera usb -parms "-d /dev/video0" usage: DuetLapse.py [-h] -duet DUET [-camera {usb,pi,web,dslr}] [-seconds SECONDS] [-detect {layer,pause,none}] [-pause {yes,no}] [-movehead MOVEHEAD MOVEHEAD] [-weburl WEBURL] [-dontwait] {camparms} ... DuetLapse.py: error: invalid choice: '-d /dev/video0' (choose from 'camparms') [root@localdev LAPSE]# ./DuetLapse.py -duet 192.168.89.246 -camera usb "-d /dev/video0" usage: DuetLapse.py [-h] -duet DUET [-camera {usb,pi,web,dslr}] [-seconds SECONDS] [-detect {layer,pause,none}] [-pause {yes,no}] [-movehead MOVEHEAD MOVEHEAD] [-weburl WEBURL] [-dontwait] {camparms} ... DuetLapse.py: error: invalid choice: '-d /dev/video0' (choose from 'camparms') [root@localdev LAPSE]#
-
Well, drat, I obviously have gaps in my test cases.
Will be fixed and upload in 20 min or so.
-
OK, now fixed.
While I was there, I added the ability to press Ctrl+C one time, while waiting for pre-start or print running, and it will move directly to making a video. In other words, if you wish to end it before the print ends, and still want the vid, press Ctrl-C once.
-
@Danal said in DuetLapse available for Alpha testing:
Well, drat, I obviously have gaps in my test cases.
I edited the code and removed the whole camparms thing and hardcoded the call to fswebcam to test it. Having some issues now of other kind (that's a fedora vm with usb camera connected trough vm-terminal as the camera with good view of the printer is on usb on my desktop so I can monitor during testing phase ) so don't have the test video yet but so far it seems to be working. Anyhow the device and resolution are hardcoded? Why? fswebcam will use -d /dev/video0 as default anyways so I don't see reason for you to hardcode it and if user want to use other one like i420:/dev/video1 you can't pass that parametar to fswebcam as you already hardcoded video0, also resolution, what if I want 1280x960 as that's native to C270, you hardcoded 800x600 ?
Maybe let fswebcam use default values (low res, video0 ..) and show in help example how to get some decent values (higher res etc..)
-
@Danal that's a nice feature (ctrlc once)
I'll test the new code asap -
@arhi said in DuetLapse available for Alpha testing:
@Danal said in DuetLapse available for Alpha testing:
Well, drat, I obviously have gaps in my test cases.
I edited the code and removed the whole camparms thing and hardcoded the call to fswebcam to test it. Having some issues now of other kind (that's a fedora vm with usb camera connected trough vm-terminal as the camera with good view of the printer is on usb on my desktop so I can monitor during testing phase ) so don't have the test video yet but so far it seems to be working. Anyhow the device and resolution are hardcoded? Why? fswebcam will use -d /dev/video0 as default anyways so I don't see reason for you to hardcode it and if user want to use other one like i420:/dev/video1 you can't pass that parametar to fswebcam as you already hardcoded video0, also resolution, what if I want 1280x960 as that's native to C270, you hardcoded 800x600 ?
Maybe let fswebcam use default values (low res, video0 ..) and show in help example how to get some decent values (higher res etc..)
Yeah, you have very valid points. I THOUGHT I did the minimum to get a usable image... but it really looks like I should have let more things default.
I can do it two ways:
- Remove everything I can and risk the auto stuff not working for a true "newbie" for some reason or another
(Probably going to do this... low risk...)
- Have camparms replace EVERYTHING, except the file name.
-
OK, I did a little of both. Removed quite a bit from the 'defaults', AND changed it so that if you specified 'camparms -parms' the only thing that is added is the filename.
And, introduced "vidparms -parms '. Works the exact same way, except it is passed to ffmpeg.
Ready for test right now.
-
pi@duet3:~/DuetLapse $ ./DuetLapse.py -h usage: DuetLapse.py [-h] -duet DUET [-camera {usb,pi,web,dslr}] [-seconds SECONDS] [-detect {layer,pause,none}] [-pause {yes,no}] [-movehead MOVEHEAD MOVEHEAD] [-weburl WEBURL] [-dontwait] {camparms,vidparms} ... Program to create time lapse video from camera pointed at Duet3D based printer. optional arguments: -h, --help show this help message and exit -duet DUET Name or IP address of Duet printer. -camera {usb,pi,web,dslr} -seconds SECONDS -detect {layer,pause,none} -pause {yes,no} -movehead MOVEHEAD MOVEHEAD -weburl WEBURL -dontwait Capture images immediately. subcommands: {camparms,vidparms} DuetLapse camparms -h or vidparms -h for more help pi@duet3:~/DuetLapse $ ./DuetLapse.py camparms -h usage: DuetLapse.py camparms [-h] [-- ...] camparm -parms xxx where xxx is passed to fswebcam, raspistill, or wget. pi@duet3:~/DuetLapse $ ./DuetLapse.py vidparms -h usage: DuetLapse.py vidparms [-h] [-- ...] vidparms -parms xxx where xxx is passed to ffmpeg. pi@duet3:~/DuetLapse $