uccwiki

This page describes how labels are generated and displayed on top of webcam images on the UCC web site.

How it works

There are two programs at work here.

make-labels.zsh

TODO: describe make-labels.zsh

label.c

This program reads a configuration file to determine which labels it should check for and where to display them, then constructs a composite image from the webcam and labels generated earlier by make-labels.zsh. The source is available here. The binaries of this file reside in /home/other/webcam/public-html/cgi-bin/.

label.c determines which webcam to read from based on the name of its executable, so for each webcam there is a hard link in this directory eg webcam1.cgi and uvc1.cgi. After determining its name, the whole program is protected from concurrent execution by a named semaphore /dev/shm/sem.$WEBCAM where $WEBCAM is the webcam name.

label.c determines which labels to draw and where to draw them based on information in a configuration file named $WEBCAM.autolabel in /home/other/webcam/, eg webcam1.autolabel. The format of this file is machine-name x y, each line describes a machine and where to draw the label. For example, webcam1 currently has the following in webcam1.autolabel:

combtail 145 104
cephalopod 173 85
cichlid 33 153
canevas 75 130
chanopsis 108 110
humpback 297 159
sidderrog 295 193
persephone 293 221
curdane 290 267

Most of the time, label.c does not generate a new image and simply retransmits the previously generated image. Any of the following conditions will cause it to generate a new image.

If an update is necessary, label.c invokes imagemagick programs convert or composite for each label it finds and builds up a composite image stored in /home/other/webcam/cgi-bin/out/ which it finally transmits.

Potential problems and how to fix them

Nobody is logged to a Windows machine but the label is still being drawn

musundo might still think that a user is logged in to that machine, it will go away eventually. To confirm this run

smbstat -b

on musundo, if the user is listed as being logged in then just wait a little while or kill the session and the label will soon disappear.

Alternatively this may be the problem described below.

The wrong user or no user is being drawn for a Linux machine

make-labels.zsh only checks for users logged in to tty7 on Linux machines, if a user has a console session or an X11 session on another tty then make-labels.zsh will not generate a label for that user. Try running

finger @some-linux-machine

to confirm this is the case.

Labels are not being updated

If musundo is on and the network is not broken, this probably indicates a problem with make-labels.zsh. Try running

/home/other/webcam/make-labels.zsh

on musundo and see if any errors indicate the cause of the problem.

Labels are in the wrong place

Modify $WEBCAM.autolabel according to the section label.c above to correct the position of the label.

CGI script times out or produces empty output

This usually means that the semaphore protecting the generation of an image from concurrent requests did not receive a sem_post when it should have. You can fix this by unlinking the named semaphore which will cause it to be recreated next time the CGI script is invoked. On mussel, named semaphores reside in /dev/shm/. The CGI script creates a semaphore with the name of the webcam it is consuming images from, so webcam.cgi's semaphore will be /dev/shm/sem.webcam.

Eg: If webcam1.cgi is timing out, then on mussel run

rm /dev/shm/sem.webcam1

Adding a machine

To add a machine you must:

Adding a webcam

Assuming you have followed the naming conventions of previous webcams, adding another webcam is simply a matter of adding a hard-link in /home/other/webcam/public-html/cgi-bin/ and a configuration file in /home/other/webcam/, and then directing the webcam page towards the CGI script. Eg, to add a webcam called pretty-cool-webcam, run

cd /home/other/webcam/public-html/cgi-bin/
ln webcam.cgi pretty-cool-webcam.cgi
vim ../../pretty-cool-webcam.autolabel
# Add entries here as described in the label.c section above

Potential Improvements

uccwiki: WebcamLabels (last edited 2010-03-21 20:47:44 by RufusGartonSmith)