From charlesreid1

(Created page with "=Installing= ==Raspberry Pi== Start by installing things SimpleCV will need, namely, Scipy and OpenCV: <pre> $ sudo apt-get install python-scipy $ sudo apt-get install pyth...")
 
 
(3 intermediate revisions by the same user not shown)
Line 15: Line 15:
$ sudo pip install simplecv
$ sudo pip install simplecv
</pre>
</pre>
=Using=
Here are some sample scripts that show you how to use various functions within SimpleCV.
==Capturing images==
You can capture images with SimpleCV with the following simple script:
<pre>
from SimpleCV import Camera
import time
cam = Camera()
time.sleep(3) # wait for the camera to warm up
img = cam.getImage()
img.save("myimage.png")
</pre>
You can create a timelapse loop, with a photo every 2 seconds, using a script like this:
<pre>
from SimpleCV import Camera
import os
import time
from datetime import datetime
cam = Camera()
time.sleep(0.1)
lapse_dir = datetime.strftime(datetime.now(),"timelapse_%Y%m%d-%H%M%S")
os.system('mkdir '+lapse_dir)
while True:
    prefix = datetime.strftime(datetime.now(),"%Y%m%d-%H%M%S")
    filename = lapse_dir+"/"+prefix+".jpg"
    img = cam.getImage()
    img.save(filename)
    print "Saving photo to %s"%(filename)
    time.sleep(2)
</pre>
=Flags=
{{PiFlag}}
[[Category:August 2016]]

Latest revision as of 06:17, 19 August 2016

Installing

Raspberry Pi

Start by installing things SimpleCV will need, namely, Scipy and OpenCV:

$ sudo apt-get install python-scipy
$ sudo apt-get install python-opencv

Now install simplecv using pip:

$ sudo pip install simplecv

Using

Here are some sample scripts that show you how to use various functions within SimpleCV.

Capturing images

You can capture images with SimpleCV with the following simple script:

from SimpleCV import Camera
import time
cam = Camera()
time.sleep(3) # wait for the camera to warm up
img = cam.getImage()
img.save("myimage.png")

You can create a timelapse loop, with a photo every 2 seconds, using a script like this:

from SimpleCV import Camera
import os
import time
from datetime import datetime

cam = Camera()
time.sleep(0.1)

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

while True:

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

    img = cam.getImage()
    img.save(filename)
    print "Saving photo to %s"%(filename)

    time.sleep(2)

Flags