DuetLapse available for Alpha testing
-
-
@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 $
-
@Danal I have been using your tool for a week now and there is one thing which would be nice.
I have to log into the Pi to send the DuetLapse.py -camera pi - detect layer -duet 192.168.0.7
All this Pi does is run the TimeLapse software.When it has finished I have to log back in again and do it all again.
Is there a way that it can run all of the time as a service and maybe send a telnet command from the Duet to say,
I am about to print, get ready!!
i.e. M118 P4 S"Print Starting"Which in turn enables DuetLapse with the users setting.
Just a thought
Regards,
Paul. -
I will think about a way to do this... while minimally banging on the printer between prints.
-
Had a Malloc error, used all default settings.
Capturing frame 522 at X10.00 Y280.00 Z120.00 Now making 523 frames into a video at 10 frames per second. This can take a while... x264 [error]: malloc of size 25549312 failed Video encoding failed Killed Video processing complete. Video file is in home directory, named ~/DuetLapse0413200101.mp4
Was looking forward to this TimeLapse
-
As long as you have NOT started the overall script again, or rebooted, the images are still there and you can try to make the video over and over.
The actual command issued is:
ffmpeg -r 10 -i /tmp/DuetLapse/IMG%08d.jpeg -vcodec libx264 -y -v 8 ~/DuetLapse0413200101.mp4
You could try other ffmpeg options (I am not an expert), try making two videos out of half the images, and stitch the vids together later, etc, etc.
To be clear, the images are in /tmp and are named
IMG00000001.jpeg
IMG00000002.jpegEtc.
-
Awesome program. One issue I've always had is that my wifi and or duet do not like each other and disconnect constantly, but will always reconnect eventually. Is it possible to automatically 'skip' a frame if there is no connection to the printer at that time and not to throw an error?
Also would be nice if it looked at the file name it was printing and made subfolders with the name of the print
-
@mrwulff said in DuetLapse available for Alpha testing:
Awesome program. One issue I've always had is that my wifi and or duet do not like each other and disconnect constantly, but will always reconnect eventually. Is it possible to automatically 'skip' a frame if there is no connection to the printer at that time and not to throw an error?
Yes, I will add some error handling to the key spots.
Also would be nice if it looked at the file name it was printing and made subfolders with the name of the print
Hey, great idea!