Observe, Mon Cher Ami...
This month Marcel introduces Gqcam, xawtv and MASH, some simple and fun tools to use with webcams.
by Marcel Gagné
Mon Dieu! This is terrible. Why did you not tell me, François? Surely it must have been obvious to you when I was putting the menu together. I must come up with something and quick, before our guests arrive. Too late, François. They are here.
Bonjour, mes amis. Welcome to Chez Marcel, home of fine Linux cooking. François, please, show our friends to their table. Forgive me if I seem a bit distressed, but I have been caught off guard today. You see, when François told me that the theme of the issue would be SOHO, I thought, mais, c'est fantastique! An issue featuring the wonders of our solar system. Imagine my surprise when I learned that SOHO, in this case, was Small Office/Home Office rather than Solar and Heliospheric Observatory. Then, I started playing with the words, you see. Observatory made me think of the technology for observing the stars, like that wonderful telescope named after Monsieur Hubble. And then I thought, but the true stars are this restaurant's fine guests—you, mes amis.
This brings us to tonight's menu. But first, we must have du vin, non? François, please bring up the 1998 Picadilly Valley Chardonnay from the cellar for our guests.
In order to achieve the highest level of success with the following recipes, a recent kernel is recommended highly. This is particularly true because a number of inexpensive webcams that you will find at your local electronics warehouse are USB devices. The more recent the kernel, the more likely that device will be supported. While taste-testing these recipes, I used a 2.4.9 kernel and two different webcams, one based on the CPiA chipset, and the other using a ov511 module.
The prevalent use for the webcam is on a web site, providing glimpses into the life of the individual running the site. Some sites provide a camera to reassure us that they are indeed working. Others are there to let parents observe their children playing at day care. The software that captures these images is sometimes called a frame grabber.
Ah, François, you are back. Please pour for our guests. François? François, I am talking to you. What do you mean you did not hear me? Ah, I see. A beautiful and mysterious lady is sitting at table 22. Pour the wine and then you may introduce yourself. Vite!
Where was I? Mais oui, frame grabbers. Gqcam is just such a package. With it you can set up a camera, keep an eye on whatever needs watching and capture images at will. You even can set it up to grab an ongoing sequence of images automatically, at whatever interval you choose. To get started with Gqcam, visit Cory Lueninghoener's web site (cse.unl.edu/~cluening/gqcam) to pick up the latest source, then extract and build it:
tar -xzvf gqcam-0.9.tar.gz cd gqcam-0.9 make
You were waiting for something else, non? There is no make install for this one, mes amis. You can copy the final binary to /usr/local/bin manually, or wherever you want to save the executable. You also can execute the program directly from the build directory, if you wish, by typing ./gqcam &. You may find, as I did, that the program looks to /dev/video by default. With the USB device, my webcam was actually at /dev/video0 while /dev/video was a directory. To get around this, I used the -v flag:
gqcam -v /dev/video0What you choose to observe with Gqcam is entirely up to you, but as to what you can do with the program itself, allow me a few suggestions. If you look at Figure 1, you'll see a shot of Gqcam in action. While it is running, you can do some interesting things. For instance, you can, at any time, click on the Snap Picture button to capture a frame. You'll be given the option of saving it in either PNG, PPM or JPEG format. If you were to click a number of images quickly, you could assemble them into a movie of sorts.
Of course, it is tedious, is it not, to be snapping pictures of yourself continually. That's why Gqcam lets you set a timer. Click on Camera, then select Set timer. You can choose a directory where the image will be saved and an appropriate filename to save that image to, something like /somedir/mypic.jpg. Set the timer for one second and let it go. You'll end up with a number of images in /somedir that have the filename mypic followed by a period, a date and timestamp, and the .jpg extension. The fun part here is that you can run this little movie with a simple command that is part of the ImageMagick package (likely already installed on your machine):
Gqcam also can run directly from the command line, making it fairly simple to set up a cron job that will capture frames at some selected interval:
gqcam -v /dev/video0 -d /wwwdir/filename.pngThe -d option specifies a location to dump a captured image. The default format for the image is PNG, but you can also use the -t flag to specify JPEG as an override. Now, if I happen to be running a web server somewhere, I could, when the mood takes me, snap a current picture and, voilà, we are all stars of the Internet, non? All you need now is a simple web page to display the image, something like this:
<html> <head> <title>Cam Chez Marcel</title> </head> <body bgcolor="White"> <center> <h1>Bienvenue! You are watching Cam Chez Marcel</h1> <img src="camsnap.png"> </center> </body> </html>Another program that performs some of the same functions as Gqcam is Gerd Knorr's xawtv. As its name implies, this is meant to provide you with a means of viewing television programs (with the appropriate hardware), but it also handles input from webcams. When you feel that you've done something that warrants observation on a regular basis (a video sales presentation, for instance), you may decide that providing a video clip adds a certain something extra. xawtv can give you that capability. Start by visiting the web site at bytesex.org/xawtv and picking up the latest copy. From a work directory, extract the source and build it:
tar -xzvf xawtv_3.64.tar.gz cd xawtv-3.64 ./configure make make installYou run the program by typing xawtv & at the command line. The program automatically sensed the location of my camera in this case, so no additional settings were necessary. When you right-click on the image, an options menu will appear that lets you change the video settings, such as brightness and color. Like Gqcam, you also can grab an image and save it in PPM or JPEG format. What's more interesting to this discussion is the next menu item.
If you press R, a recording window appears. The default is to save multiple images that you would then assemble using an external program. You can, however, click on movie driver and choose raw video data or an AVI format file. Choose AVI, select a filename to save it to, then click on the start recording tab. When you have the footage you want, click the tab again. (It actually says start/stop.) If you have the xanim package loaded, you may choose to play back what you recorded by clicking the tab immediately below. Have a look at Figure 2 for a sample of a recording session dialogue.
Come closer, mes amis. Notice how François looks a little uncomfortable. He is somewhat taken with la dame mystérieuse at table 22. The poor boy is too shy to go talk to her in person. It is for my faithful waiter and others like him that I present you with our final recipe of the day.
When you want to be face to face, but distance (or other circumstances) makes it difficult, then video conferencing is the answer. This is where MASH comes into play. MASH is actually a collection of tools produced by the Open MASH Consortium (created by Larry Rowe and Steve McCanne). Their purpose was to create a public domain toolkit for developing collaboration and streaming applications. MASH stands for multimedia architecture that scales across heterogenous environments. No, really. It is all true.
If you feel so inclined, you can download the source and build the package from scratch:
tar -xzvf mash-src-5.1.5.tar.gz cd mash-code ./build
The easiest method is to download the precompiled binary package from the Open MASH web site at www.openmash.org. Once that is done, you merely extract the package and run the installation script. Observe, mes amis:
tar -xzvf mash-bin-5.1.5-linux-gnu.tar.gz cd mash-5.1.5 ./setup.shSo simple, non? As I mentioned, this is a collection of tools rather than a single program. The most interesting one however, particularly for François, is vic, the video-conferencing tool that allows for multiple users to participate in video communication:
vic hostname/port_noFor instance, if I wanted to connect to a machine called speedy on my network on port 2002, I would issue the command like this:
vic speedy/2002You should see a small window pop up at this point with a simple message, “Waiting for video...”, in the center of it. The video you are waiting for, of course, is the young lady at table 22. For the young ladies out there, it may well be François. Who knows? While we wait for the other side of the connection, click the Menu button. A control window will appear that gives you control over many aspects of the current session. Look at the top of that window and click on the Transmit button. Even without the other side of the connection, you will see a small image of yourself sitting behind your camera.
Now, click on the small image. A somewhat larger session image appears. When the person on the other end comes on-line, their image will appear, and you can follow the same procedure to detach a more appetizing view. Figure 3 shows François talking to the mysterious lady using vic. As you can see from the image, he even is afraid to let his own image be seen and has provided an avatar of sorts. Poor François.
Like the other applications we have seen today, vic's video control menu lets you modify a number of settings such as brightness, contrast and color. You even can change the size of the viewers by clicking on the Size button.
Once again, closing time approaches. Normally, I would ask my waiter to provide you with a final top-up, but I fear, mes amis, that it will be up to me to refill your glasses this evening. François seems somewhat preoccupied.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- The Italian Army Switches to LibreOffice
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Linux Mint 18
- Oracle vs. Google: Round 2
- The FBI and the Mozilla Foundation Lock Horns over Known Security Hole
- Devuan Beta Release
- Varnish Software's Varnish Massive Storage Engine
- Privacy and the New Math
- Ben Rady's Serverless Single Page Apps (The Pragmatic Programmers)
Until recently, IBM’s Power Platform was looked upon as being the system that hosted IBM’s flavor of UNIX and proprietary operating system called IBM i. These servers often are found in medium-size businesses running ERP, CRM and financials for on-premise customers. By enabling the Power platform to run the Linux OS, IBM now has positioned Power to be the platform of choice for those already running Linux that are facing scalability issues, especially customers looking at analytics, big data or cloud computing.
￼Running Linux on IBM’s Power hardware offers some obvious benefits, including improved processing speed and memory bandwidth, inherent security, and simpler deployment and management. But if you look beyond the impressive architecture, you’ll also find an open ecosystem that has given rise to a strong, innovative community, as well as an inventory of system and network management applications that really help leverage the benefits offered by running Linux on Power.Get the Guide