From charlesreid1

Motivation

I'm done trying to get this cheap-o Pi camera, with the clumsy ribbon cable, to try and work. The whole design, all of it reeks of cheaply-manufactured hardware incapable of anything but the most inane projects. (Hence the plethora of "how to photograph your cat" videos, and nothing more interesting or heavy-duty.)

The Hardware

I ordered a USB camera (1080 P, 2 MP?) from Amazon:

USBCamera1.jpg

USBCamera2.jpg

Setup/Usage

The camera didn't come with instructions, but controlling it was insanely easy [1]:

$ apt-get install fswebcam
$ fswebcam image.jpg
$ python -m SimpleHTTPServer 8000

Then point browser to 192.168.0.111:8000, and voila, the image is there and ready:

MyFirstUSBWebcamPhoto.jpg

Better Pictures

For best quality, use:

fswebcam -r 1280x720 --no-banner image.jpg

this results in a better image resolution without the obnoxious timestamp banner:

USBWebcamPhoto2.jpg

Motion program for camera stream

You can also stream from your camera using the motion program. (Apparently. Haven't gotten it working yet.)

The problem: can't stream images using the motion program. I know the camera works with the Pi b/c I can capture still images, so it isn't a power issue. I can see motion dumping out still images, so it isn't a communication issue with the camera.

Installing motion

$ apt-get install motion

Configuring motion

Now modify the motion config file to allow for webcam streaming:

$ sudo vim /etc/motion/motion.conf

change these lines:

stream_localhost on
webcontrol_localhost on

to these lines:

stream_localhost off
webcontrol_localhost off

Start motion daemon

To start the motion daemon:

$ sudo motion
[0] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion/motion.conf
[0] [ALR] [ALL] conf_cmdparse: Unknown config option "sdl_threadnr"
[0] [NTC] [ALL] motion_startup: Motion 3.2.12+git20140228 Started
[0] [NTC] [ALL] motion_startup: Logging to syslog
[0] [NTC] [ALL] motion_startup: Using log type (ALL) log level (NTC)
[0] [NTC] [ALL] become_daemon: Motion going to daemon mode
$ 

Ensure it is running:

$ ps aux | grep motion
root      3239 10.5  1.2  55940 10692 ?        Sl   19:30   0:01 motion

Ensure it is listening for connections:

$ sudo netstat -apt
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 *:tproxy                *:*                     LISTEN      3239/motion

Monitoring stream

The monitoring stream is set in the configuration file to port 8080:

############################################################
# Live Stream Server
############################################################

# The mini-http server listens to this port for requests (default: 0 = disabled)
stream_port 8080

go to the IP address of the Pi and tack on a :8080 to view the camera stream:

File:MotionCameraStream.jpg

Control stream

To control the camera, visit port 8081.

Flags