From charlesreid1

 
(32 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Overview=
=Third Timelapse=


Attempt number 3: accomplish a few improvements in the timelapse process.
Timelapse number 3: accomplish a few improvements in the timelapse process.


What's working:
What's working:
* The camera is working and is able to capture images. There was a problem initially, but after trying to re-enable the camera several times, and rebooting several times, the camera started working.
* The camera is working and is able to capture images. There was a problem initially, but after trying to re-enable the camera several times, and rebooting several times, the camera started working.
* The script to dump images into a directory works great in concept. Easy to keep everything segregated.
* The script to dump images into a directory works great in concept. Easy to keep everything segregated.
*


What to do differently for this timelapse:
What to do differently for this timelapse:
* LED off
* 64 gb thumbdrive for space
* 64 gb thumbdrive for space
* camera angles - better control mechanism
* camera angles - better control mechanism
* case: improved housing for Pi and for Pi camera (integrated?)
* case: improved housing for Pi and for Pi camera (integrated?)


==Note on Weatherproof Case==


Weatherproof Pelican case is on order, but it's going to take two more days. In the meantime, we need to make some progress on this camera stuff. Move on with it.


Putting off the weatherproof case for Timelapse number 4 or number 5.


==Camera Attachment==


==In Progress==
My goal was to house the camera and get better stability/control than the terrible botched christmas-present wrapping of scotch tape that I did last time in [[RaspberryPi/Timelapse2]]. Shouldn't be too hard.


===Weatherproof Case===
The big improvement will come when the weatherproof Pelican case arrives, and I'll attach a weatherproof port for the camera on the outer housing of the Pelican. But in the meantime, here are some short-term improvements.


To make my own weatherproof case: rather than designing a 3D printed case with the proper knobs and buttons and things for USB and etc., get a larger plastic weatherproof case. Obtain the proper screws, washers, o-rings, etc. to mount the Raspberry Pi into the case, then obtain the proper glass disks, screws, washers, o-rings, etc. to mount the Pi camera on the inside of the case.
I went to the craft store to get a a big stick, and I laid everything out in a natural way and taped it all into place. One of the big mistakes I made last time was trying to bend the ribbon cable attaching the camera to the RPi out of a natural position, which led to it popping loose inside of the camera housing. With this configuration, things have the space they need.


Drill a hole through the case for the camera:
It is nowhere near weatherproof... but the weather has been nice lately.
 
If you love the Rasperry Pi... You're gonna love the Raspberry Pi on a stick!!!
 
[[Image:RPi_Camera_Stick.jpg|400px]]
 
===Outfitting for a Tripod===
 
I was able to drill a hole in the center of the wood to create a hole that could be attached to a tripod-mountable screw I had. This enabled me to attach the camera to a tripod, and adjust the angle of the camera. I even tied a piece of cord around a hole at the end of the plank to tie to the balcony, in case of massive failure of the tripod.
 
[[Image:PiCamera_Tripod_Mount.jpg|500px]]
 
===Ooooops.===
 
The only part I forgot to secure was the back of the camera. Upon completing my brilliant tripod design, I promptly attached the tripod, tilted the camera, and spilled the back of the camera overboard and onto a second-story roof awning.
 
So much for being a hardware hacker.
 
==Running the Camera==
 
===Camera LED (No Success)===
 
I tried unsuccessfully to set the camera LED state from Python script:
 
<pre>
import picamera
camera = picamera.PiCamera()
print camera.led
camera.led = False
</pre>
 
According to the help page for the camera object, <code>help(camera)</code>, this attribute is supposed to control the camera. I also read you had to be root, so I also tried doing this as root by running Python via sudo:
 
<pre>
$ sudo python
>>> import picamera
[...]
</pre>
 
No success there. The LED light would come on once I had created the camera object, and would not turn off by setting the led attribute to False.
 
===Camera LED (Success)===
 
To turn off the camera LED, you can edit the file <code>/boot/config.txt</code> and add a directive to turn off the camera board's LED. Add the following to the top of the file:
 
<pre>
# disable the camera led
disable_camera_led=1
</pre>
 
Reboot will be necessary, but once you do that, there will no longer be an annoying glaring red LED every time the camera is on and talking to the computer!
 
===USB Flash Drive===
 
Plug in 64 GB flash drive.
 
To mount and make readable/writable by default Pi user, start without the jump drive plugged in. Run this command to monitor hardware that is plugged in:


<pre>
<pre>
    |    o-ring    |    glass disk  |  o-ring  |  plastic surface of case  |
tail -f /var/log/messages
</pre>
 
Plug in your USB drive. It should probably be called <code>/dev/sda1</code>. Once you know the name of the device, you can mount it to a folder (which must exist ahead of time):


???
<pre>
sudo mount -t vfat -o uid=pi,gid=pi /dev/sda1 /home/pi/timelapse
</pre>
</pre>


This design is a little confusing.
Test that you can indeed make stuff in the new jumpdrive:
* Does the O-ring rest directly on the camera? If so, there is not much field of vision and the size has to be matched perfectly with the camera. If not, the camera protrudes at least 1/8 of an inch, so you'd need a really fat o-ring, and one that wouldn't compress too much, and that just seems like a bad design.
* Does the glass disk rest directly on the camera? If so, would that affect field of vision? If not, what configuration?
* I think the glass disk rests directly on the camera.


Additional tripod mount screw hole would have to be added to the case - but again, much easier to do that with a larger case, than with a fitted-perfectly-for-the-Pi case.
<pre>
cd /home/pi/timelapse
touch file
</pre>


Additional hole and rubber gasket for power cord would have to be added to the case.
Hooray! Now move all the scripts there:


<pre>
cp /somewhere/else/lapse.py .
</pre>


===Run Timelapse Script===


Here's that lapse.py script again:


<pre>
import picamera
from datetime import datetime
import time
import os


==Failed Designs and Idea Bucket==
camera = picamera.PiCamera()


===Rainberry (Nope)===
lapse_dir = datetime.strftime(datetime.now(),"timelapse_%Y%m%d-%H%M%S")
os.system('mkdir '+lapse_dir)


Sorry folks. This is for Raspberry Pi Model A+. But it does give a good idea of how to go about assembling a well-designed weatherproof case.
###print "Don't forget - to turn off the LED - run this as root!"
###camera.led = False


The Rainberry weatherproof case consists of a 3D printed weatherproof case, with a hole for a camera and for screws to mount the camera and the pi to the case. Detailed description of this case and how it was designed is here: https://tinkererblog.wordpress.com/2015/07/28/how-i-designed-a-compact-weatherproof-raspberry-pi-case/
while True:


This case consists of a 3D printed weatherproof case, plus some additional parts to mount the camera lens and make it weatherproof. The 3D printer files and parts list are given below.
    prefix = datetime.strftime(datetime.now(),"%Y%m%d-%H%M%S")
    filename = lapse_dir+"/"+prefix+".jpg"


3D printed case files:
    camera.capture(filename)
* has two sides and a seal component; the key is the integration of a case for the camera with a case for the pi
    print "Saving photo to %s"%(filename)
* https://pinshape.com/items/7876-3d-printed-rainberry-weatherproof-case-for-raspberry-pi-a-and-pi-camera?open-buy-form=true
* [[File:RainberryBottomPlate.stl]]
* [[File:RainberrySeal.stl]]
* [[File:RainberryTopBox.stl]]


Screws to hold case externally in place:
    time.sleep(2)
* 4-40 Thread, 3/4″ Phillips flat head, total 4 (91771A113) for case
</pre>


Screws to hold Pi internally to case:
==Serving Up Photos==
*  4-40 Thread, 3/16″, total 4 (91772A105) for Pi


Screws to hold Pi camera:
To serve up the photos, SSH into the Pi, and cd to the directory where the photos are located. Start a screen session by running the <code>screen</code> command. Now run a Python simple HTTP server by running the command:
*  M2 Size, 5MM, total 4 (92000A012) for Pi camera


Camera-case seal:
<pre>
*  M1.6 Size, 4MM, total 4 (92000A002) for seal
$ python -m SimpleHTTPServer 8080
*  O-Ring, 13mm id, 1.5mm (5233T39) for seal
</pre>


Glass lens for camera seal
Now the directory of photos from the Pi camera should be accessible at the Pi's IP address, port 8080. For example, if the Pi is at the IP 192.168.0.111, then the photos can be viewed by pointing a browser (also on the local network, of course, along with the Pi) to the address:
* same size as e.g. flashlight covers, like Maglite lens covers
* http://www.dx.com/p/glass-lens-for-flashlights-10-pack-17-9mm-x-1-2mm-10640#.V7CmVLWbfTk


External power cable:
<pre>
* O-Ring, 1.5mm, 1ft length (1187N11) for case and Shrink wrap (6855K14) for USB cable
192.168.0.111:8080
</pre>


Case Mount:
This is typed into the browser, and the files in the directory are served up by the Python simple HTTP server.
* Swivel mount from Videosecu with 1/4 inch threads
 
* https://www.amazon.com/gp/product/B000IDCDZY?ref_=pe_1196280_123950170
=Idea Bucket=
 
[[RaspberryPi/Weatherproof Camera Case]]
 
[[RaspberryPi/Rainberry]]
 
Inspiration: OpenCV to identify (and target) squirrels: https://www.youtube.com/watch?v=QPgqfnKG_T4


=Flags=
=Flags=


{{PiFlag}}
{{PiFlag}}
[[Category:August 2016]]

Latest revision as of 05:10, 16 August 2016

Third Timelapse

Timelapse number 3: accomplish a few improvements in the timelapse process.

What's working:

  • The camera is working and is able to capture images. There was a problem initially, but after trying to re-enable the camera several times, and rebooting several times, the camera started working.
  • The script to dump images into a directory works great in concept. Easy to keep everything segregated.

What to do differently for this timelapse:

  • LED off
  • 64 gb thumbdrive for space
  • camera angles - better control mechanism
  • case: improved housing for Pi and for Pi camera (integrated?)

Note on Weatherproof Case

Weatherproof Pelican case is on order, but it's going to take two more days. In the meantime, we need to make some progress on this camera stuff. Move on with it.

Putting off the weatherproof case for Timelapse number 4 or number 5.

Camera Attachment

My goal was to house the camera and get better stability/control than the terrible botched christmas-present wrapping of scotch tape that I did last time in RaspberryPi/Timelapse2. Shouldn't be too hard.

The big improvement will come when the weatherproof Pelican case arrives, and I'll attach a weatherproof port for the camera on the outer housing of the Pelican. But in the meantime, here are some short-term improvements.

I went to the craft store to get a a big stick, and I laid everything out in a natural way and taped it all into place. One of the big mistakes I made last time was trying to bend the ribbon cable attaching the camera to the RPi out of a natural position, which led to it popping loose inside of the camera housing. With this configuration, things have the space they need.

It is nowhere near weatherproof... but the weather has been nice lately.

If you love the Rasperry Pi... You're gonna love the Raspberry Pi on a stick!!!

RPi Camera Stick.jpg

Outfitting for a Tripod

I was able to drill a hole in the center of the wood to create a hole that could be attached to a tripod-mountable screw I had. This enabled me to attach the camera to a tripod, and adjust the angle of the camera. I even tied a piece of cord around a hole at the end of the plank to tie to the balcony, in case of massive failure of the tripod.

PiCamera Tripod Mount.jpg

Ooooops.

The only part I forgot to secure was the back of the camera. Upon completing my brilliant tripod design, I promptly attached the tripod, tilted the camera, and spilled the back of the camera overboard and onto a second-story roof awning.

So much for being a hardware hacker.

Running the Camera

Camera LED (No Success)

I tried unsuccessfully to set the camera LED state from Python script:

import picamera
camera = picamera.PiCamera()
print camera.led
camera.led = False

According to the help page for the camera object, help(camera), this attribute is supposed to control the camera. I also read you had to be root, so I also tried doing this as root by running Python via sudo:

$ sudo python
>>> import picamera
[...]

No success there. The LED light would come on once I had created the camera object, and would not turn off by setting the led attribute to False.

Camera LED (Success)

To turn off the camera LED, you can edit the file /boot/config.txt and add a directive to turn off the camera board's LED. Add the following to the top of the file:

# disable the camera led
disable_camera_led=1

Reboot will be necessary, but once you do that, there will no longer be an annoying glaring red LED every time the camera is on and talking to the computer!

USB Flash Drive

Plug in 64 GB flash drive.

To mount and make readable/writable by default Pi user, start without the jump drive plugged in. Run this command to monitor hardware that is plugged in:

tail -f /var/log/messages

Plug in your USB drive. It should probably be called /dev/sda1. Once you know the name of the device, you can mount it to a folder (which must exist ahead of time):

sudo mount -t vfat -o uid=pi,gid=pi /dev/sda1 /home/pi/timelapse

Test that you can indeed make stuff in the new jumpdrive:

cd /home/pi/timelapse
touch file

Hooray! Now move all the scripts there:

cp /somewhere/else/lapse.py .

Run Timelapse Script

Here's that lapse.py script again:

import picamera
from datetime import datetime
import time
import os

camera = picamera.PiCamera()

lapse_dir = datetime.strftime(datetime.now(),"timelapse_%Y%m%d-%H%M%S")
os.system('mkdir '+lapse_dir)

###print "Don't forget - to turn off the LED - run this as root!"
###camera.led = False

while True:

    prefix = datetime.strftime(datetime.now(),"%Y%m%d-%H%M%S")
    filename = lapse_dir+"/"+prefix+".jpg"

    camera.capture(filename)
    print "Saving photo to %s"%(filename)

    time.sleep(2)

Serving Up Photos

To serve up the photos, SSH into the Pi, and cd to the directory where the photos are located. Start a screen session by running the screen command. Now run a Python simple HTTP server by running the command:

$ python -m SimpleHTTPServer 8080

Now the directory of photos from the Pi camera should be accessible at the Pi's IP address, port 8080. For example, if the Pi is at the IP 192.168.0.111, then the photos can be viewed by pointing a browser (also on the local network, of course, along with the Pi) to the address:

192.168.0.111:8080

This is typed into the browser, and the files in the directory are served up by the Python simple HTTP server.

Idea Bucket

RaspberryPi/Weatherproof Camera Case

RaspberryPi/Rainberry

Inspiration: OpenCV to identify (and target) squirrels: https://www.youtube.com/watch?v=QPgqfnKG_T4

Flags