Thursday, December 8, 2022

Aye Eye Bed-Time Story Generator

Machine Learning is used for various hard practical problems, such as the safe control of autonomous cars that have to navigate a cluttered and dynamic environment, without bumping off cyclists and running over old people trying to cross a village road.  

There are also other more entertaining uses for it, such as the creation of bed-time stories for your grand children.  (Yup, I'm that old.  I started learning programming FORTRAN on a Univac with punch cards, eh.  Now get of my pennisetum clandestinum... :).

Go to OpenAI ChatGPT and make yourself a free account: https://chat.openai.com/auth/login

Let the fun begin: 

Write a short story for ten year olds. Scary government people created a video of a moon landing and will catch you if you deny it.

NASA Artemis Moon Shot

Give the protagonist two buddies with distinctly different personalities.

Result:

Once upon a time, there was a young boy named Jack who loved watching the stars at night. He dreamed of one day becoming an astronaut and exploring the moon.
One day, Jack's teacher showed the class a video of a moon landing. It showed a group of astronauts walking on the moon's surface and collecting rocks and samples.
But Jack had his doubts. He didn't believe that the moon landing was real. He tried to tell his classmates, but they all thought he was crazy.
Luckily, Jack had two friends who believed him. One was a shy and timid girl named Alice, who was always afraid to speak up. The other was a bold and brave boy named Max, who was always ready for adventure.
Together, they decided to investigate the moon landing and find out the truth. They went to the library and did some research, and they discovered that the video was actually a cleverly made fake and that the government had been lying to the public for years.
They also learned that many people who questioned the moon landing had disappeared without a trace. They knew they had to be careful, or the government might catch them too.
Jack, Alice, and Max came up with a plan to expose the truth to the world. They made their own video and posted it online, showing the evidence of the fake moon landing.
The government was furious, but they couldn't stop the truth from spreading. Soon, the whole world knew that the moon landing was a hoax.
Jack, Alice, and Max were heroes for standing up for the truth, even though it was scary. And they all lived happily ever after.


Given the distinct lack of effort required to specify the story line, the result is quite entertaining and if the rug rats are not sleeping yet, then you can generate another one in seconds!


La Voila!

Herman

Wednesday, October 12, 2022

Let There Be Light

I made a ceiling light fixture for my workshop (it is supposed to be my garage) from scrap wood.  Since LED lights do not get hot, one can do that without danger of burning the house down, but it would be a good idea to incorporate a 250 mA polyfuse in there for peace of mind.

 

The light of my life.

To hide the ceiling house wires and chocolate block connector, I made a big hole in one block with a hole saw and glued it to another block.  The vertical stick is mortised into the ceiling block - rubbed some wax on it all and there we have a little Tinkertoy Chandelier.  I used bees wax, but good old boot polish will work as well and it comes in multiple shades.

Cantilever Desk Lamp

BTW, the easy/lazy way to make a rectangular mortise hole, is with a drill and a jigsaw.   You just slowly grind the wood away with the saw blade till you have a perfect fit.  A hammer and chisel does not work well on soft wood, no matter how sharp the chisel, while a jigsaw will happily chew up anything!

I made two of the ceiling lights and one desk lamp.  The lamp fixture is invisibly fastened to the end of the stick with a little screw and epoxy glue.  The counterweight more or less balances it, which makes it easier to adjust and stay in place.

Now I had enough of sandpaper and lamps for a while - if I can just stop sneezing!

La voila!

Herman

Wednesday, May 11, 2022

Wooden Post Thumper

We planted a new tree and wanted to stabilize it with three posts, so it won't blow over in a storm, while it is still young.  It turned out that planting the tree was the easy part.  Hammering the 2.5 meter support posts into the ground, was a whole 'nuther problem.

One cannot use a sledge hammer on a tall post, since climbing onto a ladder and swinging a heavy weight around, two meters above ground, is sure to cause a rapid, unplanned descent from the ladder.

The safe solution is a pile driver - a heavy pipe that is closed at one end.

I could not find a pile driver at the local hardware store and in any case it would cost around 65 Euro, so I took some scrap wood and a two hundred year old sledge hammer and there we go.  The only expense was a handful of screws.  

The thumper works remarkably well.  It took longer to make the thumper than to set the three posts, but now I can also use it to drive in a sand point shallow well for the garden.


 

Start with a 15 cm piece of a square fence post - larger than the diameter of the stake that you want to drive in.  Build a box around it such that you have a channel of at least 50 cm below the block.  Strap a heavy weight above the block and there you are.  It doesn't have to be ridiculously heavy.

Obviously a steel thumper will last forever, while a wooden one will eventually wear out/split, but a wooden one like this, will last long enough for use by ordinary mortals.

Do sand the wood down to avoid getting splinters in your hands while using it.


Make a mark 50 to 75 cm from the tip of the post so you can see when to stop!

Put the top of the post into the thumper, then stick the point into the ground and raise it up.  Bonk the post in by raising and dropping the thumper 30 cm or so.  Wedge the post with your foot to help it go vertical.

Removing the thumper from the post can be tricky, since it is unbalanced with the big weight at the top, so it will likely drop onto the ground as soon as you clear the top of the post - try not to drop it on someone's foot! 

 

 

 

For driving a Sand Point Well Pipe into the ground, I built a tripod gantry with two pulleys, to make it easier to lift the thumper.  

 Here is a picture of the pipes about 2 meters into the ground:


 

 

 

 Only 5 meters more to go...

 

 

I'm sure the neighbours will be happy when I reach the end of my pipe.

 


Wheelies

Speaking of heavy stuff. I built some heavy gates and needed to drag them about 20 meters from the garage to the corner of the yard and my back was getting sore.


So, I re-invented The Wheel!

Two wheels close together, roll better over bumpy paving stones, than a single wheel.

It only has to work twice.


 


The above wooden wheels turned out real good, so I made a couple more, to clamp on and drag random heavy things around, such as my work table - which is an old recycled kitchen table with strengthening around the legs.

Now I can tip it over and then just need to balance it a bit, when I drag it off to the storage area.  I may cut another pair of wheels and screw them to the table permanently.

For something that won't get hundreds of miles of use, scrap wood wheels are great and cost nothing - OK, you need a screw and two washers also, but that won't break the piggy bank.

 

 

A little wooden wheel, cut with a 50 mm hole saw, can make a nice low friction Garden Gate Support:


The roller and block (with a rounded corner) lifts the door a few mm, so that the sliding bolt lines up perfectly, making the gate easy to open/close.  Don't glue the block - use two screws instead.  When the system needs adjustment, unscrew the block and reposition it.

 

La voila!

Herman

Sunday, May 8, 2022

Sawz

Simple Table Saw

To me, much of the fun of woodworking is making my own tools and jigs and then using them in a project.  Jigs made of wood do not last very long, since they either wear out, or warp (or both!), so making new jigs is a constant process.  The trick is to keep it simple, so that any worn or damaged guide piece can be replaced quickly with whatever is in your scrap wood bin.

Table Saw With Guide

When machining large pieces of wood, it is best to keep the wood still and move the machine, so a hand circular saw is a must have.  However, when working small pieces of wood, it is best to keep the machine still and move the wood, so a table saw is also a must have.  A table saw can however be rather expensive and a cheap, inaccurate, wobbly one, costs 3 times more than a hand tool.

Table Saw Saw Guide

Making your own table saw with an upside down hand saw is not difficult and it also has some advantages, notably that cutting through the table results in a zero clearance blade slot, which helps to reduce tear-out.  I set the blade to 90 degrees and leaves it that way.  I never cut at an angle with a circular saw, since it much increases the danger of a jam and kickback, which can hurt very badly.  I rather use a jigsaw for fancy cuts.

When selecting a circular saw, compare the different models on display and select the one with the sturdiest guide plate chassis.  The biggest problem with DIY tools is wobble.  Makita saws are very sturdy, while my other cheap American saw is rather wobbly, so I learned from the experience.

I made an Ikea scrap wood MDF box with a top and no bottom, to house the saw.  To adjust the blade height, I tip the box up to get to the lever and since there is no bottom, saw dust falls out and doesn't build up in the box.  However, it is a good idea to cut a hole in the side for a vacuum cleaner nozzle, to reduce the dust flying up into the air.

 

Upside Down Table Saw

When using the table saw, I clamp a piece of wood to the back of my work table, to keep the saw box from sliding off.   That works well enough.

Simple Saw Guides

The top overhangs the sides of the box by 5 cm, to enable the use of simple guide blocks and clamps.

The saw rip guide (Yankees call it a fence) slides along the front side, wraps around the table edge and clamps in place.  The guide ends at the middle of the blade.  At that point, the wood is cut, a longer guide doesn't help anymore and could cause the wood to jam between the guide and the blade and get flung back at high speed, which will hurt badly, so I keep the guide short.  American table saws have guides that go all the way to the back of the table - that is not a good idea.   

When you make the rip guide, glue the pieces, then clamp them to the blade and the front edge of the table.  By doing that, the guide is guaranteed to be perfectly parallel to the blade, even if the table edge is not. Once the glue set, you can add a couple of screws if needed.

Yootoob is full of fancy saw guide designs.  If you make a fancy guide, then when it breaks and/or warps, you need to spend a lot of time making a new one.  So I keep it simple, don't make fancy sliding slots in the table top and use a G clamp to secure my saw guides to the table edges.  A saw guide could be as simple as a piece of junk wood that was lying around, or a plastic rafter square.

To use a saw rip guide, clamp it lightly with a G clamp to the table edge and adjust it with a rubber mallet, then tighten the clamp.

I cut with the blade set much higher than the wood thickness.  This directs the cutting force mostly into the table and not at me, which reduces splintering and also reduces dangerous fly-back of wood pieces. It is a good idea to use a smaller size circular saw (a 5 to 7 inch blade is enough) with less power.  You will never be sorry if your puny little 5 inch table saw jams and stalls - while you will be very sorry for yourself if your saw goes Whump! and throws the wood piece back to you at 100 miles an hour.   

A ten inch table saw is a killer - A bigger table saw isn't better! 

Table Saw Cross Cut / Mitre Jig

A table saw cross cut sled is very useful.  I made one from scrap wood, that fits over the table saw box, guided by the edges.  

Table Saw Cross Cut Jig

When you glue up such a jig, put two layers of masking tape on the edges, to ensure that after you glued it, it will not stick to the table and there will be enough clearance to slide smoothly when you remove the tape.  Some wax will also help to make it move and keep it from warping as soon as you want to use it.

For miter cuts, I clamp a triangle to it.  For multiple cut offs, I use a G clamp with a stop block.

Hand Saw Cross Cut Sled 

Another jig I use a lot, is a cross cut sled for my hand saw.  The guide rails are left over oak edging.  Put some wax on them.

Cross Cut Sled

If I need a 45 degree cut, I simply clamp a plastic rafter square to the base.  Don't ever use a steel square as a cutting guide.  I would not like to accidentally cut into a steel square - the result of tungsten saw teeth binding into a steel tool won't be fun at all.  This sled has seen heavy use over the past year.

The Simplest Jigsaw Guide Ever

There are many videos on Yootoob showing how to turn a jigsaw with a long flexible blade into something resembling a band saw, by using a wooden overhead arm and ball bearings.  You don't need any of that.   

Simply buy Professional quality blades. It is the same type of blade you always buy, but with a P at the end of the part number.  Those blades are thick and stiff.  They don't flex and they cut straight!

Jig Saw with Dust Port and Professional Blade

Here is a picture of my little jigsaw, with a professional blade and a conical PVC rubber adaptor for the little 21 mm dust port to fit a vacuum cleaner hose.  You can get the conical widgets on Amazon in packs of 2 to 5.  Do yourself a favour and buy a bunch of them.

La voila

Herman.

Tuesday, January 11, 2022

Linux Security Cameras

Security Camera Management Programs

There are two decent Linux programs for managing security cameras: Motion and ZoneMinder.

For test purposes, I set a camera up inside my living room.  Once working, I'll install two outside, to watch the driveway and backyard.

 Streaming Camera with Fish Eye Lens

Motion is the simpler one of the two programs, but with almost 300 configurable options, it can do anything worth doing.  It works just as well as ZoneMinder, but it simply doesn't do things that are not needed.  For example, Motion supports a database, but Linux filesystem storage is usually good enough.  It doesn't have a fancy GUI, since it is intended to run on a server, stashed on a shelf in a dark corner.  There is a GUI which can be accessed with a web browser locally, or over the LAN, but I never used it.  One can also view real-time streams with a web browser.  Notifications can be sent and files uploaded to another machine with external programs such as mutt, wput and others.

While one can watch a TP Link security camera with a cell phone App,  I want to monitor what is going on when not at home, without spending money on a subscription service.  The simplest way to do this, is to use a free email account as an archive. Wherever I travel, I can log into gmail with a web browser and look at the stored security videos, to confirm that my house hasn't burned down and that there isn't an old Baba Yaga with a black cat and a white goat staying there.

In this guide, I describe how to configure Motion to handle a TP-Link C100 RTSP streaming camera and email a short video clip whenever motion is detected, using mutt with a gmail account.

Install Motion and Mutt

Mutt is a simple command line mail client which is fully supported and updated by Ubuntu Linux.  It provides the ability to send attachments using a free mail account from gmail, yahoo or similar service.  The parameter syntax of mutt is a little wonky - do yourself a favour and read the man page at least 3 times.

  • $ sudo su -
  • password
  • # apt install motion mutt ffmpeg 

Streaming Cameras

First of all, get the TP-Link camera to work.  You need to install an App on your cell phone to do that.   Using this App, create a user account with a password to use for the RTSP stream login.  With the App, you can also find the camera IP address - or look in your router DHCP list for it.

Use ffplay to verify that you can log in and play the camera streams:

  • $ ffplay rtsp://USERNAME:PASSWORD@IP.ADD.RE.SS/stream1

The above is the EXACT string that you need to use later in the camera configuration.

Security Considerations

For improved security, I configured mutt and motion to run under my user account on an Ubuntu Linux server.

Configure Mutt

  • $ cd
  • $ mkdir .mutt

Create a new gmail account for the security system, then go to the account security settings and set Support for Less Secure Apps ON.  Otherwise mutt will be blocked by Google. Simply send the attachments to this gmail address and leave it all there. Don't clog up your regular email account with security cam spam.  When Google eventually complains that the mailbox is full (you get 15GB for free), you can simply select all and delete it, then let it fill up again.

Create a file called mutrc.

Replace USERNAME, REAL NAME and PASSWORD with the exact details used when creating the gmail account. Put SINGLE QUOTES around the password to prevent the expansion of any $ signs in the password.

set from = "USERNAME@gmail.com"
set realname = "REAL NAME"
set imap_user = "
USERNAME@gmail.com"
set imap_pass = 'PASSWORD'
set smtp_url = "smtps://
USERNAME@smtp.gmail.com"
set smtp_pass = '
PASSWORD'
set folder = "imaps://imap.gmail.com/"
set spoolfile = "+INBOX"
set postponed="+[Gmail]/Drafts"
set trash = "+[Gmail]/Trash"

Configure Motion

  • $ cd 
  • $ mkdir .motion
  • $ cd .motion
  • $ cp /etc/motion/motion.conf .
  • $ cp /etc/motion/camera* .

Motion.conf

Make a file called motion.conf.  In the below example change USERNAME to suit.

# Rename this distribution example file to motion.conf
#
# This config file was generated by motion 4.3.2
# Documentation:  /usr/share/doc/motion/motion_guide.html
#
# This file contains only the basic configuration options to get a
# system working.  There are many more options available.  Please
# consult the documentation for the complete list of all options.
#

############################################################
# System control configuration parameters
############################################################

# Start in daemon (background) mode and release terminal.
daemon off

# Start in Setup-Mode, daemon disabled.
setup_mode off

# File to store the process ID.
pid_file /home/USERNAME/.motion/pid

# File to write logs messages into.  If not defined stderr and syslog is used.
log_file /home/USERNAME/.motion/motion.log

# Level of log messages [1..9] (EMG, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL).
log_level 6

# Target directory for pictures, snapshots and movies
target_dir /home/USERNAME/Videos

# Video device (e.g. /dev/video0) to be used for capturing.
;videodevice /dev/video0

# Parameters to control video device.  See motion_guide.html
; vid_control_params value

# The full URL of the network camera stream.
; netcam_url value

# Name of mmal camera (e.g. vc.ril.camera for pi camera).
; mmalcam_name value

# Camera control parameters (see raspivid/raspistill tool documentation)
; mmalcam_control_params value

############################################################
# Image Processing configuration parameters
############################################################

# Image width in pixels.
width 1920

# Image height in pixels.
height 1080

# Maximum number of frames to be captured per second.
framerate 2

# Text to be overlayed in the lower left corner of images
text_left "CAM1"

# Text to be overlayed in the lower right corner of images.
text_right %Y-%m-%d\n%T-%q

############################################################
# Motion detection configuration parameters
############################################################

# Always save pictures and movies even if there was no motion.
emulate_motion off

# Threshold for number of changed pixels that triggers motion.
;threshold 1500 

threshold 10000

# Noise threshold for the motion detection.
noise_level 32

# Despeckle the image using (E/e)rode or (D/d)ilate or (l)abel.
despeckle_filter EedDl

# Number of images that must contain motion to trigger an event.
minimum_motion_frames 1
;minimum_motion_frames 5

# Gap in seconds of no motion detected that triggers the end of an event.
event_gap 10

# The number of pre-captured (buffered) pictures from before motion.
pre_capture 3

# Number of frames to capture after motion is no longer detected.
post_capture 0

############################################################
# Script execution configuration parameters
############################################################

# Command to be executed when an event starts.
; on_event_start value

# Command to be executed when an event ends.
; on_event_end value
 
# Command to be executed when a movie file is closed.
; on_movie_end value
on_movie_end "echo 'Security video'|mutt -i - -s 'Security Video' -a "/home/USERNAME/Videos/CAM1-%t-%v-%Y%m%d%H%M.mkv" -- USERNAME@gmail.com"

############################################################
# Picture output configuration parameters
############################################################

# Output pictures when motion is detected
picture_output off

# File name(without extension) for pictures relative to target directory
picture_filename %Y%m%d%H%M%S-%q
;picture_filename %Y%m%d%H%M-%q

############################################################
# Movie output configuration parameters
############################################################

# Create movies of motion events.
movie_output on

# Maximum length of movie in seconds.
movie_max_time 20

# The encoding quality of the movie. (0=use bitrate. 1=worst quality, 100=best)
movie_quality 45

# Container/Codec to used for the movie. See motion_guide.html
movie_codec mkv

# File name(without extension) for movies relative to target directory
movie_filename %t-%v-%Y%m%d%H%M%S
;movie_filename %t-%v-%Y%m%d%H%M

############################################################
# Webcontrol configuration parameters
############################################################

# Port number used for the webcontrol.
webcontrol_port 8080

# Restrict webcontrol connections to the localhost.
webcontrol_localhost on

# Type of configuration options to allow via the webcontrol.
webcontrol_parms 0

############################################################
# Live stream configuration parameters
############################################################

# The port number for the live stream.
stream_port 8081

# Restrict stream connections to the localhost.
stream_localhost on

##############################################################
# Camera config files - One for each camera.
##############################################################
camera /home/USERNAME/.motion/camera1.conf
; camera /usr/etc/motion/camera2.conf
; camera /usr/etc/motion/camera3.conf
; camera /usr/etc/motion/camera4.conf

##############################################################
# Directory to read '.conf' files for cameras.
##############################################################
; camera_dir /usr/etc/motion/conf.d

Camera1.conf

Make a file called camera1.conf.  Set the picture size according to your camera resolution.

Set the USERNAME and PASSWORD to the RTSP stream account that you created in the camera App.

# /usr/etc/motion/camera1.conf
#
# This config file was generated by motion 4.3.2

###########################################################
# Configuration options specific to camera 1
############################################################
# User defined name for the camera.
camera_name CAM1

# Numeric identifier for the camera.
camera_id 101

# The full URL of the network camera stream.
netcam_url rtsp://USERNAME:PASSWORD@10.10.10.78/stream1

# Image width in pixels.
;width 1280
width 1920

# Image height in pixels.
;height 720
height 1080

# Text to be overlayed in the lower left corner of images
text_left CAM1

# File name(without extension) for movies relative to target directory
;movie_filename CAM1_%t-%v-%Y%m%d%H%M%S
movie_filename CAM1-%t-%v-%Y%m%d%H%M 

Ditto for Camera 2.

Motion Configuration Tricks

Enable the Despeckle filter to reduce the amount of motion events. Set the maximum length of the movie clip to 20 seconds, to keep the file smallish and ensure that the email system will accept it.  

Remove the seconds parameter from the file names, since the system is already processing the next event when the current event is handled, which makes it impossible to attach the correct file down to the second.  Sometimes there will still be a problem when the minutes roll over, but most video files will get sent successfully.

Always specify the complete filename path.

Email Test

First test mutt interactively.  Run it from the console and play with it to ensure that you can send and receive email and that gmail is not blocking it.  

Motion Test

Run motion from the command line and play with it, to ensure that it works properly and will send emails with mutt.  If you get too many messages, increase the pixel change trigger level.

You need to find a happy medium where the system will not email a deluge of messages, since Google will block the account if you do. If you find that there is just too much movement in your situation, then you could also use the snapshot feature to email a picture once per hour or so and leave the movies on your home server.

Another option is to make the event gap much longer, so that it will detect motion, but not all motion.

You can view the real time video with a web browser on port 8081:

  • $ firefox http://localhost:8081/101 

Mailbox Cleanup

Deleting a few thousand messages manually using gmail with a webbrowser, would be extremely tedious.  When the mailbox gets full, it may be easier to delete the account and create a new one.

To clean the gmail box in one swell foop, you can try the following command with mutt:
  • mutt -e "push D~d>30d<enter>qy<enter>"
However - it may cause Google to disable your mail account for an hour, since this kind of mass mail delete with the IMAP protocol may look suspicious to their system.


La voila!

Herman