Raspberry PI IP webcam monitor

You can monitor a IP webcam with a RPI to a composite or HDMI screen pretty straight forwardly. This lets you decode a mjpeg stream which is a pretty common standard used by these IP cameras. The frame rate isn’t great for my setup but there are plenty of variables that might be causing that.

I setup the pi with some GPU fixes and the code which lets it dynamically manage it’s GPU ram. This appears to work pretty well. It also means I’ve plenty of ram for the other services. This stuff goes at the end of /boot/config.txt YMMV.



The following script is based on a number of sources. This is specifically designed to be robust for GPU/network/stream issues. OMX player can be a bit sensitive to poorly formed mjpeg streams.

while [ 1 ]
 tvservice -c 'PAL 4:3'
 echo deleting
 rm /tmp/stream.mjpeg -rf
 echo making
 mkfifo /tmp/stream.mjpeg
 echo getting
 timeout 14400 wget -c --timeout=1 -t 1 --http-user=xxxx --http-password=xxxx -O /tmp/stream.mjpeg 'http://xxx.xxx.xxx.xxx/videostream.cgi' &
 echo sleep
 echo startomx
 screen -dmS camera1 sh -c 'omxplayer --live --threshold 0 -r /tmp/stream.mjpeg; exec bash'
 screen -X -S camera1 kill
 echo deleting
 rm /tmp/stream.mjpeg -rf
 echo finito
  • First the script ensures the composite output is live using the tvservice command (this is important for composite as the pi often shows a blank screen and needs it resetting), this would need adjusting or omitting for an HDMI screen.
  • Then it clears the existing fifo (if there is one) and creates a new one. Then it uses wget to connect the fifo to the camera stream. The timeout command automaticaly kills the wget command after 4 hours, this clears freezing problems I had at the expense of a couple of seconds while it restarts. You would need to change the URL so it works for your camera, this is for a foscam.
  • Then omxplayer is started in a screen session, this is to give it a live console (which it likes) and allows you to kill it later when wget has failed/been killed.
  • The wait command waits for wget to finish.
  • When wget is finished it kills the omxplayer session, deletes the fifo and starts again. It will repeat indefinitely.

Hopefully this helps someone out. It’s been a bit of a faff fixing all the little bugs with this. This script does appear to be fairly robust now though and it is a light enough method to coexist with motion for at least one camera. I have this script start up with the pi with no X window environment.

Read More

Upload AVR Assembler to an Arduino UNO

ArduinoAVRUploader – I’ve bundled the command bellow into a useful utility. The Arduino IDE must be installed for this to work. It’s developed in VS2013 so you might need to install a runtime.

A lot of the internet will tell you that you can’t program an arduino uno in assembler. You can can, but you can’t use the default IDE (which is fairly limited anyway). I didn’t work this out unaided but unfortunately I’ve forgotten where I found the info. Xloader was certainly a step along the way but sadly it doesn’t work with the uno (or at least the version I have).

You just need to compile you code to a .hex file using AtmelStudio and then run the command:

C:\Program Files (x86)\arduino\hardware\tools\avr\bin\avrdude.exe -C"C:\program files (x86)\arduino\hardware/tools/avr/etc/avrdude.conf" -patmega328p -carduino -P\\.\COM3 -D -U flash:w:"{path to your file}":i

This is how the Arduino IDE uploads its programs so it preserves the bootloader.

Read More

Coordinates to grid cells in Vorpal

Download gridCoords.mac

I’ve written a macro with a few useful functions to convert between coordinates (in meters) and cells (in…cells). It makes it a bit neater for those blocks which insist on being defined on the grid.

So something horrible like:

lowerBounds = [$int(floor((-XSTART-WG_A/2.)/DX))$ $int(floor((InWGCoupleOffSetY-YSTART)/DY))$ $int(floor(OutWGOffsetZ/DZ))$]

upperBounds = [$int(ceil((-XSTART+WG_A/2.)/DX))$ $int(ceil((InWGCoupleOffSetY-YSTART)/DY))+1$ $int(ceil((OutWGOffsetZ+WG_B)/DZ))$]

turns into something vaguely readable like:

lowerBounds = toGridFloorA(-WG_A/2.,InWGCoupleOffSetY+YSTART,OutWGOffsetZ)

upperBounds = toGridCeilA(WG_A/2.,InWGCoupleOffSetY+YSTART,OutWGOffsetZ+WG_B)

toCoords(x,dx,xstart) should convert the other way from cells to coordinates.

Read More



  • Uses VorpalDom
  • Extracts all or some blocks which can be plotted
  • Creates a Visit friendly .h5 file
  • There must be a .in file
  • VorpalComposer/VisIt can’t plot meshs with 0 or 1 cells in any dimension (at least on windows). As a workaround these are set to have 2 cells for plotting. It’s better than nothing for now.

With VorpalComposer you can integrate block plotting with the inbuilt visualisation. As the blocks are saved to an .h5 file as a mesh VorpalComposer lists the blocks as mesh’s and is able to plot them.

Plot the blocks as well as the fields in VorpalComposer

If you “Enable VisIt Context Menu” under “Visualisation Options” in Tools/Settings you can right click on the visualization pane and open the visit GUI. This lets you edit the colours and opacity of the plot.
Read More

Vorpal Blocks in VisIt

VorpalVisIt 0.11

  • Uses VorpalDom
  • Extracts all or some blocks which can be plotted
  • Creates a Visit friendly .h5 file
  • There must be a .in file and “”*_Globals_1.h5″.

Having become frustrated with Matlab’s inability to draw more than about 10,000 electrons without becoming unusable slow I thought I’d have a look at VisIt. It’s always nice to be able to plot the blocks from your .pre file so I thought I’d write something like VorpalPlotter to work with VisIt.


pmlSlab example with blocks plotted

Read More

Vorpal In File to XML tree structure

VorpalDOM 0.1

  • Parses Vorpal .in files to a XML DOM structure using xml.etree.ElementTree
  • Block finding functions (by type and by name)
  • Scale class to convert between grid and length coordinate systems

With a little fiddling about, python’s built in XML packages can be used to parse the vorpal .in file. xml.etree.ElementTree only needs the block titles (“” for instance) to be altered to “” and a wrapping tag added (the equivalent of an “” tag) for it to be able to parse the file.

Read More

SolidLink (CST Studio to Solidworks interface)

CST View

CST View

Sometimes the CAD features in CST Studio can be limiting especially with complex rounding. SolidWorks allows you to draw much more intricate geometries but exporting and importing .SAT files can be irritating, and parameter sweeps become very time consuming.

SolidWorks View

SolidWorks View

This macro links the parameters in CST to equations in SolidWorks and automates the .SAT link between the two programs. With the link established a parameter change in CST (and a history update from the History List diaglogue box) updates the SolidWorks model and imports the new version into CST. This allows parameter sweeps to be performed on models with imported geometries.

Read More

Condor password authentication (with windows nodes)

This guide doesn’t let you submit jobs. I’ll get back to you when I’ve sorted that problem.
For simplicity I’m using condor password authentication. It’s reasonably simple to setup once you’ve worked out what’s going on.

Just as a bit of background I have a Linux central server and windows nodes. I’m using condor 7.6.0 installed with the .deb package. I recommend you attempt this on a test pool of at least 2 as you will most likely kill it repeatedly. Make sure condor is running on both machines with debugging turned on.

Read More

Turn on condor debugging

It’s easy to turn on debugging. Remember to do this on both the central manager and at least one test node. Then you can see what you are doing and the logs say MUCH more useful things.

In condor_config set this flag (it’s around line 595)

##  Settings that control the daemon's debugging output:

## The flags given in ALL_DEBUG are shared between all daemons.

If you want to you can always set this just for a single daemon.  You do of course need to have some idea of which daemon you think is wrong.

Read More

Build master document from child in LyX

When you’ve got a large document with lots of children it’s nice to be able to build the whole document from a child document with one click. You can add some buttons to the standard toolbar to let you do this.

First find this bit of code in $LyX$\Resources\ui\stdtoolbars.inc:

Toolbar "view/update" "View/Update"
   Item "View DVI" "buffer-view dvi"
   Item "Update DVI" "buffer-update dvi"
   Item "View PDF (pdflatex)" "buffer-view pdf2"
   Item "Update PDF (pdflatex)" "buffer-update pdf2"
   Item "View PostScript" "buffer-view ps"
   Item "Update PostScript" "buffer-update ps"

Then add these two lines:

  Item "View PDF (pdflatex)" "master-buffer-view pdf2"
  Item "Update PDF (pdflatex)" "master-buffer-update pdf2"

If you want image buttons rather than text, save the two images below to $LyX$\Resources\ui\Resources\images\ (it’s the file name that is important).


Read More