RaspberryPi/USB Camera: Difference between revisions
From charlesreid1
(→Flags) |
|||
| Line 142: | Line 142: | ||
[[Image:MotionCameraControl.png|500px]] | [[Image:MotionCameraControl.png|500px]] | ||
=Projects= | |||
Now that we have the camera up and operational, and we're happy with the preliminary results... what next? | |||
==Timelapse 4== | |||
See [[RaspberryPi/Timelapse 4]] | |||
=Flags= | =Flags= | ||
Revision as of 03:06, 18 August 2016
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:
Fswebcam (Success)
The camera didn't come with instructions, but controlling it was insanely easy [1]:
$ apt-get install fswebcam $ fswebcam image.jpg
aaaaand, now you have your first picture. To serve it up with a lightweight Python web server,
$ python -m SimpleHTTPServer 8000
Then point browser to 192.168.0.111:8000, and voila, the image is there and ready:
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:
Wow! That's good enough to use for computer vision to detect cat faces.
Motion program for camera stream (Success)
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:
Control stream
Control of the camera can be done via the web interface as well (including pan and tilt controls, if you have that set up). That's also set in the configuration file:
############################################################ # HTTP Based Control ############################################################ # TCP/IP port for the http server to listen on (default: 0 = disabled) webcontrol_port 8081
This isn't terribly interesting, but it is useful:
Projects
Now that we have the camera up and operational, and we're happy with the preliminary results... what next?
Timelapse 4
Flags
