User Tools

Site Tools


Text WebCam Support


This functionality is especially of interest for monitoring invisible spots on the layout, for example shadow stations.
USB WebCams can be used and are low priced; High Definition WebCams are not needed for this purpose. For testing purpose a Logitech C170 has been used which comes for about €20,-.
Rocview will not show the WebCam as a movie but as still pictures with a definable refresh interval which is OK to see what is happening.
An external capturing program is needed to provide the still pictures to make this functionality for Rocrail Operating System independent; See the Script paragraph.

Text Setup

The content of the text object must point to the WebCam picture.
The Refresh time in ms must have a value of at least 100. A good value is 500.
Resizing of the text object can be done with the cx and cy grid values on the General tab.

Capturing Script

Replace <username> with your username.


The tool WACAW is used on a Mac to capture a still picture of a WebCam.

while :
  if [ ! -f /Users/<username>/webcam1/picture.png ]; then
    echo "Snapping a new picture of the webcam..."  
    ./wacaw -d 2 --png /Users/<username>/webcam1/_picture
    mv /Users/<username>/webcam1/_picture.png /Users/<username>/webcam1/picture.png
  sleep 0.25

(Do not forget to make this new script executable with chmod +x

If the color of the captured pictures is bad the -n parameter must be used:

    ./wacaw -d 2 -n 5 --png /Users/rob/webcam1/picture

Detecting the device number

With the -L command line option the device list ist shown:

./wacaw -L
There are 3 devices in the list.
The current selection is 2.
 0 - DV Video [is available] [has no inputs]
 1 - IIDC FireWire Video [is available] [has no inputs]
 2 - USB Video Class Video [is available] [has inputs]
    There are 1 inputs for this device (2).
    The current selection is 0.
   0 - Webcam C170 [is available]

In this example the device number to use is 2: -d 2.


Under Linux the ffmpeg tool can be used to capture pictures:

sudo apt install ffmpeg
while :
  if [ ! -f /home/<username>/webcam1/picture.png ]; then
    echo "Snapping a new picture of the webcam..."  
    ffmpeg -f video4linux2 -i /dev/video1 -frames 1 /home/<username>/webcam1/_picture.png
    mv /home/<username>/webcam1/_picture.png /home/<username>/webcam1/picture.png
  sleep 0.25



ls /dev/video*

a list of video devices will be shown.
If the PC/Laptop ha a build-in camera this will show up as /dev/video0.
The first external WebCam will be in this case /dev/video1.


This script has not been tested and uses Irfanview as capture tool.

IF NOT exist "C:\webcam1\picture.png"\ (
  REM Change the Twain Source
  REM  cscript.exe SetTwainSource.vbs driver
  i_view32.exe /scanhidden /dpi=(150,150) /convert="C:\webcam1\picture.png"
ping -n 1 > NULL
GOTO startallover

The folowing Batch script used commandcam.exe for grabbing and bmp2png.exe for picture converting and was successful tested.

This files require less resources than IrfanView.

echo off
if exist picture.png goto start
commandcam.exe /quiet /filename picture.bmp /delay 10
bmp2png.exe -Q picture.bmp 
goto start
Remark: The code above need that all files are placed in the same folder.
Otherwise, the path information corresponding to the different directories have to be supplemented.

Informations to the installed video hardware may so be requested:

commandcam.exe /devlistdetail

If multiple video devices are installed, an additional option can select the device.
In this example the device number "2":

commandcam.exe /quiet /filename picture.bmp /delay 10 /devnum 2

File Handshake

Only one at a time of both programs, wacaw (or any other capturing program) and Rocview, should access the picture file to avoid invalid images.

  1. The script will capture a picture and store it in the picture.png file.
  2. Rocview will read and show it.
  3. Rocview deletes the picture.png.
  4. The script detect that the picture.png is deleted and will capture the next picture of the WebCam.
  5. Goto step 2…
text/text-webcam-en.txt · Last modified: 2023/01/15 07:46 by rjversluis