⇒ Navigation menu

README: About the Office Camera

Nov 18, 2022

There is a webcam in my office that I use to take photos of the whiteboard. This setup was inspired by Dror Bar Natan’s Blackboard Shots. If you know of anyone else with a similar setup, please let me know.

A photo showing a close-up of the camera mount holding the office camera

I setup the office camera because many students wanted to take photos of the board during office hours. If several students had the same question, then I could refer them to the photos on the website. The longer I’ve had the camera, the more uses I’ve found for it. It turns out that the most useful application of the office camera is for responding to mathematical questions via e-mail. If my response to an e-mail would require enough math that writing it in plain text would impractical, then I write it on the whiteboard and snap a photo.

A photo of Parker’s office showing the office camera pointed at a whiteboard

The script office-camera.sh handles taking a photo, previewing it, generating the markdown for the photo page, and then uploading everything. It requires feh (an image viewer), streamer (a video and audio capture tool), and hugo (a static site generator). This script is highly dependent on my setup, but you’re welcome to adapt it for your own purposes. Please let me know if you make something similar.

 shootImage () {
 	# set times based on image file
 	IsoTime=$(date --iso=second);
 	CurrentTime=$(date +%Y-%m-%d\ @\ %H:%M:%S)
 	echo -e "Shooting image and storing it: $TempDir$ImageFile\n";
 	# shoot a photo and silence all output
 	#streamer -c $WhiteBoardCamera -o $TempDir$ImageFile -j 100 -s 800x600 &> /dev/null ## lower-resolution
 	streamer -c $WhiteBoardCamera -o $TempDir$ImageFile -j 100 -s 960x720  &> /dev/null ## higher-resolution
 	# show a preview of the photo and return to script
 	feh --scale-down $TempDir$ImageFile &
 	# capture the PID of feh, so we can close it after preview
 	echo -e "PID of feh is: $FehPID\n";
 makeMarkdown () {
 	Title=${1:-$CurrentTime}; # if there is no title, default to the date
 	echo -e "Creating markdown with title: $Title\n";
 title: \"$Title\"
 date: $IsoTime
 tags: ['office camera']
 ![A photo of a whiteboard titled: $Title]($HugoImagePrefix$ImageFile \"$Title\")"
 	echo -e "Making Markdown file and storing it: $TempDir$MarkdownFile\n";
 	echo -e "$HugoMd" > $TempDir$MarkdownFile;
 while true
 	read -p "Does the preview look okay? [Yn]" answerPreview
 	case $answerPreview in
 	  [Yy]* ) 
 		  echo "Yes! The photo is good." ;
 		  makeMarkdown "$1"; # pass the first argument to makeMarkdown 
 		  kill $FehPID; 
 		  break ;;
 	  * ) 
 		  echo "No! Reshoot the photo." ;
 		  kill $FehPID;
 		  answerPreview="n" ;;
 while true
 	read -p "Do you want to edit the post [e], post [P], or cancel [c]?" answerEdit
 	case $answerEdit in
 	  [eE]* ) 
 		echo "Edit the markdown file." ;
 		vim $TempDir$MarkdownFile ;;
 	  [pP]* )
 		echo "Post the markdown and image." ;
 		cp $TempDir$ImageFile $HugoPhotoDir ;
 		cp $TempDir$MarkdownFile $HugoMarkdownDir ;
 		cd $HugoBaseDir ;
 		$HugoPostScript ;
 		break ;;
 	  [cC]* )
 		echo "Cancel! Burn all the evidence!" ;
 		rm $TempDir$ImageFile ;
 		rm $TempDir$MarkdownFile ;
 		break ;;

Related tags:

Navigation menu

⇑ Top of page ⇑