Monday, December 17, 2012

Webcam Auto-Exposure Problems Under Linux - Solved

Too much light on bright days
I have struggled to find a webcam program which could grab decent still images from a webcam running under Linux. I have tried the common suggestions found online, used gvucview, cheese, webcam and webcamd.

All of these programs worked for snapping still images but the auto-exposure never worked properly and the images were poor. Most of the day the picture was either dark or obliterated with glare.

It seems the problem is that most webcam software is designed for streaming video. They all do a decent job of this, but even those programs that build in a delay never worked consistently for single jpg images. Searching the web, it is obvious I am not the only one with this problem and I could find no real solution.

Too dark in low light
After fighting this problem for days, it occurred to
me that perhaps I was using the wrong tool for the
job. I needed to look for a program which was designed specifically to snap still images from a webcam, not capture streaming video.

After some searching, I found a program called uvccapture which does just that. It is a simple, light program  that accepts arguments for resolution, timing, save location, even brightness, saturation, contrast and other basic settings. It is available in the Ubuntu repositories or you can grab it from here: https://github.com/csete/uvccapture

Happily, the auto-exposure is now working and my webcam is finally producing clear and properly exposed images. Here's how I managed it:

Auto-Exposure working properly
After installing uvccapture, I created a folder called 'webcam' in my home directory to store image.jpg and scripts. I set up the program to load on the boot using the Startup Applications tool by entering this into the command field:
uvccapture -m -t600 -q75 -x640 -y480 -o/home/user/webcam/image.jpg
This string of commands loads the program and instructs it to refresh the image every 10 minutes (600 seconds), to use compression on the JPG file at 75% quality. It states the webcam resolution, which must be supported by your device. The last argument includes the location to save the image file.

More info and commands for uvccapture are located here: http://manpages.ubuntu.com/manpages/natty/man1/uvccapture.1.html

The next problem was finding a new program to send the files via ftp to a remote server. Most of the programs I had used included the ftp service with the image grabber. I wanted something light and stable which could run in the background.

I looked at several programs and scripts and finally decided on this simple script which runs every 10 minutes via cron. Copy and paste the following into a text editor. Edit lines 4, 5 & 6 in the top section and line 5 in the bottom section:
# vi ftp-run.sh
#! /bin/sh
#run this file with ./ftp-run.sh
REMOTE='your-remote-server.com'
USER='username'
PASSWORD='password'
FTPLOG='/tmp/ftplog'
date >> $FTPLOG

ftp -n $REMOTE <<_FTP>>$FTPLOG
quote USER $USER
quote PASS $PASSWORD
bin
/home/user/webcam
mput image.jpg
quit
_FTP
Save the file as ftp-run.sh in the webcam folder. Right click on the icon and under Permissions, click to 'Run this file as a program'. I set up a cron job to run this script every 10 minutes with this command:
crontab -e
    arrow down to bottom

Paste:
*/10 * * * * cd webcam && ./ftp-run.sh

Ctrl + x to exit
Y to save
Enter
I rebooted to load the program and settings. I finally have a working webcam and my images are clear, bright and upload reliably to my server. I hope this how-to will help someone else who is struggling with this problem.

Shameless Plug:
More fun with your webcam: PortalView Live Desktop Wallpaper for Linux

Saturday, September 29, 2012

Rented Computers Caught Spying on Customers

The Federal Trade Commission has reached a settlement with DesignerWare Corporation and numerous computer rental companies for installing software on rented computers which secretly snapped explicit webcam pictures, captured emails and a variety of other personal information, including Social Security Numbers, medical and bank account information from thousands of users.

The companies installed a surveillance program called 'PC Rental Agent' which according to the FTC, "can also cause a computer’s webcam to surreptitiously photograph not only the computer user, but also anyone else within view of the camera. In numerous instances, ... webcam activations have taken pictures of children, individuals not fully clothed, and couples engaged in sexual activities."

The software, which is undetectable and uninstallable by the user, has been installed on nearly half a million computers and has been distributed by 1,617 computer rental companies in the US, Canada and Australia.

According to the complaint, "PC Rental Agent, when installed on a rented computer, offers rent-to-own store licensees the ability to direct DesignerWare’s servers to disable a computer remotely when a consumer is late making payments, has stopped communicating with the rent-to-own store, or has otherwise violated the rental contract."

The software also contains an option for the rental company to turn on "Detective Mode" which, again quoting from the complaint, "Once installed and activated, Detective Mode can log the keystrokes of the computer user, take screen shots of the computer user’s activities on the computer, and photograph anyone within view of the computer’s webcam." DesignerWare collects this information and transmits it, unencrypted, to the computer rental company.

PC Rental Agent also secretly tracked users by logging public wifi networks the computer used to access the internet, which "employees of the rent-to-own stores ...can monitor their physical locations and the patterns of their movements."

The FTC settlement requires rent-to-own companies to stop using monitoring software or tracking users' locations without knowledge or consent. The companies cannot used illicitly gained information to collect customer debts and the FTC will monitor them for 20 years.

The following companies are named in the complaint:
DesignerWare, LLC; its principals, Timothy Kelly and Ronald P. Koller, individually and as officers of DesignerWare, LLC.; Aspen Way Enterprises, Inc.; Watershed Development Corp.; Showplace, Inc., d/b/a Showplace Rent-to-Own; J.A.G. Rents, LLC, d/b/a ColorTyme; Red Zone, Inc., d/b/a ColorTyme; B. Stamper Enterprises, Inc., d/b/a Premier Rental Purchase; and C.A.L.M. Ventures, Inc., d/b/a Premier Rental Purchase.

First published on Technorati as "Rented Computers Caught Spying on Customers"

Friday, January 20, 2012

Warning Signs from the Cascadia Subduction Zone?


California Earthquake Map
CaliforniaEarthquake Map 01/20/2012
On January 17, 2012 a 4.3 magnitude earthquake occurred on the Cascadia Subduction Zone off the coast of Northern California. This relatively small quake could signal movement on this dangerous fault which has historically been silent between large events.

Lurking offshore of Northern California and running north toward Vancouver, Canada, lies the Cascadia Subduction Zone. This fault has the potential to produce an earthquake and tsunami as devastating as the March 11, 2011 quake that struck off Honshu, Japan. 

While the San Andres fault system has produced a long and obvious scar on the landscape of California and the frequency of small to moderate, non-damaging earthquakes has drawn the attention of the media and scientists, Cascadia remains locked quietly offshore for centuries, building stress until it suddenly releases in massive quakes.

Geological evidence shows seven great quakes have occurred along Cascadia in the last 3500 years. Intervals range from 200 to 900 years with most occurring around 300 years apart.


Cascadia Subduction Zone
Cascadia Subduction Zone
Cascadia last ruptured in January, 1700, producing an estimated 9.0 magnitude quake.  Recently researchers have shown the chances of a major quake occuring along Cascadia could be as high as 45 percent within the next 50 years.

Between these major quakes, Cascadia sits virtually silent. In fact, scientists were aware of its presence in the Pacific northwest, but it was not considered a threat as it appeared to never experience quakes.

Brian Atwater's 2005 study of drowned coastal forests lead to the discovery of Cascadia's hidden threat. It appears to remain virtually locked and silent for centuries, pressure and stress building until it is released in a giant quake.

According to Iris, Incorporated Research Institution for Seismology:
"...Just a quarter century ago, hardly anyone suspected that a giant underwater earthquake – or the fast-arriving tsunami that such an earthquake would spawn – could ever occur in the Pacific Northwest. The region’s written history, which begins a few decades before the arrival of Lewis and Clark, is devoid of such catastrophes. Yet today the Northwest has a widely acknowledged history, thousands of years long, of earthquakes as large as magnitude 9 and of associated tsunamis. "
Oregon Earthquake Map
Oregon Earthquakes1841 - 2002
Movement on the Cascadia has been virtually non-existent for more than a century. This map shows seismological history of Oregon for the time period from 1841 through 2002. Note the red line running north/south off the Pacific coast. This represents the Cascadia fault. Note the earthquakes occur near, but not on the fault itself.

Now look at this USGS map showing the Cascadia fault registering a 4.3 magnitude earthquake on January 17, 2011. This is a highly unusual place for movement to occur. The map also shows several small quakes in the days before the larger one.

Foreshocks, Aftershocks or Anomaly?

Large Earthquakes are often preceded by 'foreshocks' which can occur from minutes to even years before the main shock. They occur in about forty percent of moderate to large quakes and perhaps seventy percent of quakes greater than magnitude 7.0.

Studies show foreshocks may increase in intensity over time leading to the main quake:
    "The observation of foreshocks associated with many earthquakes suggests that they are part of a preparation process prior to nucleation. In one model of earthquake rupture, the process forms as a cascade, starting with a very small event that triggers a larger one, continuing until the main shock rupture is triggered. "
Cascadia quake
4.3 Cascadia quake 01/17/2012
Unfortunately it is not possible to know if a particular quake is part of a foreshock pattern until after a main event occurs.

Aftershocks are smaller quakes which occur as plates readjust following a larger event. They decrease in frequency as time passes.

Perhaps the small quakes in the preceding days were foreshocks to a main 4.3 quake on the 17th? This is certainly possible, however if the 4.3 was the culmination of this series, it should have been followed by decreasing aftershocks as the huge plates settled back into a locked position. There have been no such aftershocks.

Earthquake prediction is notoriously unreliable. Tantalizing hints of patterns give hope that someday we may be able to recognize the precursors to great quakes and evacuate populations before they strike.

The question arises: Is Cascadia stirring? The recent anomalous quake on the fault is noteworthy if only for its rarity.

There are great concerns that this area is not prepared for a quake of historical size. Cities from Eureka, California to Vancouver, Washington are potential targets.

Tsunami Evacuation Route, Oregon
According to Peter Yanev, an engineer and earthquake building consultant in this article:
    "... ...Pacific Northwest cities are full of buildings with slender structural frames and fewer and smaller shear walls. In a mega-quake, many of the region's iconic tall buildings would probably collapse. "
The Cascadia Region Earthquake Workgroup has prepared a hypothetical scenario of the effects of a rupture of Cascadia. Predictions include:
"...• Depending on location, strong shaking might be felt for several minutes.
• Injuries and fatalities could number in the thousands, and
hundreds of buildings could be destroyed.
• A destructive tsunami will quickly hit the Cascadia coast
and travel across the Pacific Ocean.
• Aftershocks up to M7 are common, creating the potential
for additional damage."
Without a doubt, the Cascadia Subduction Zone will someday unleash a great quake in the Pacific Northwest. The odds may be as high as 45% that it will strike during the lifetime of todays residents. Whether the quake that occurred on January 17 was a foreshock, aftershock or simply an anomaly, Cascadia will rupture someday. Perhaps it will happen tomorrow or a decade from now. Please prepare now. The clock is ticking.

Plan Ahead:
Disaster Preparedness Kits from Amazon
DIY Disaster Preparedness Kits


images: Oregon quake history: http://www.oregongeology.com/sub/earthquakes/eqepicentermap.htm
Cascadia Subduction Zone: http://en.wikipedia.org/wiki/Cascadia_subduction_zone
tsunami evac: http://www.flickr.com/photos/cornelii/2066817391/sizes/m/in/photostream/
Cascadia_subduction_zone: http://en.wikipedia.org/wiki/Cascadia_subduction_zone