Adding a video camera to the enclosure is, to say the least, trivial from the hardware side: Just place a stock webcam such that it can observe the things happening at the print head. In my case I have chosen to attach it to the enclosure frame, not to the working platform.
The base of the camera holder fits into the enclosure’s grooves, the flexible arm has been obtained by sawing one of these fancy smartphone holders apart. The drawback of this fixture is that it does not keep the object being built in focus - for this one would have to attach the camera to the printing table.
However, since in case of 3D-Printing I am using Octoprint so supervise the process, I can use a nice feature of Octoprint. It may be configured such that a still picture (for producing a time lapse video) is created when the printhead starts a new layer - which in many cases means that the object being built is in roughly the same position. Octoprint then generates a time lapse video from these stills, and has nice possibilities for their administration. An example for this feature (rendered to low quality) is seen below
Here you also see the drawback of fixing the camera to the enclosure frame: “roughly the same position” is not an exact specification, and therefore the video is quite wobbly. Also, if the object is growing, it is indeed growing out of the space covered by the camera.
Note: Octoprint does not contain video streaming software, but only an interface to the popular video streaming solution mjpg_streamer. I run this with the command line
mjpg_streamer -i input_uvc.so -r 1600x1200 -y -d /dev/video0 -o output_http.so -p 9000 -w /usr/local/www
on the Linux machine coupled to the SnapMaker. The full video stream is then available in my home net, and by issueing the proper shell commands I can start or stop the stream also from my home automation system.
So far this is rather trivial, and I would not expect anybody to find it interesting. However, the important aspect comes into play when switching from 3D printing to Laser or CNC milling. Obviously, the basic streaming setup may be used also then, without using Octoprint. But how does one generate time lapse videos?
For this you may use a software called “motion” - freely available for Linux machines for quite some years. “motion” is actually a system that takes still images from a streaming system in definite time steps - and then checks these for movement. This feature may be ignored for our purpose, I rather use “motion” to produce a time lapse video. See the example below.
The configuration of “motion” is done in its config file, but most parameters can also be provided as command line options, allowing for remote control by a simple shell script.
In my case, I run it with a frame rate of 25 fps, and by default take a picture every 6 seconds, resulting in a speedup by a factor of 150.
The output file of motion is an MPEG sequence (file ending .mpg), which can be displayed by some (but not all) viewers. To convert this into an MPEG4 container format, I append
ffmpeg -y -i timelapse*mpg -acodec copy -vcodec copy -f mp4 timelapse.mp4