Things used in this project

Hardware components:
12994 02
Raspberry Pi 1 Model B+
×1
Software apps and online services:
SimpleCV in Python

Schematics

Raspberry Pi and a USB Camera
I used the SimpleCV library to drive the camera
20170310 120042 ldf272zonj

Code

Pi calculator using a camera to take images of a pie.Python
Need SimpleCV installed on Python 2.7.3
from time import sleep
from SimpleCV import *


cam = Camera()
files = []
j=1

#take 5 photos, 2 seconds apart, and same them as jpegs

while j <= 5:
    pie_image = cam.getImage()
    filename="pie_"+str(j)+".jpg"
    pie_image.save(filename)
    files.append(filename)
    j=j+1
    sleep(2)

#find the pie blob in each photo and calculate pi

k=1 
for i in files:        
    img = Image(i)
    segmented = img.hueDistance(Color.BLACK)
    pies = img.invert().findBlobs(minsize=20000)
    
    #Now we print the measurements back on the picture
    for pie in pies:
        pi=pie.area()/pie.radius()**2
        print(round(pi,5))
        text = "Pi:" + str(round(pi,4))
        img.drawText(text, pie.x, pie.y, fontsize=14)
                
    #img.show()
    img.save("pie_pi_w_picalcs_"+str(k)+".jpg")
    k=k+1
    time.sleep(.1)

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Solar Smart Greenhouse Using Vertical Aquaponic Towers
Intermediate
  • 3,034
  • 43

Work in progress

Feed your family with 22 sqm greenhousing by combining permaculture, aquaponic vertical towers and IoT.

Measure wind speed with Eltako windsensor and Win10 IoT Core
Intermediate
  • 591
  • 7

Full instructions

This Project will help you track wind Speeds using Windows 10 IoT Core and the Eltako Windsensor.

Raspberry Pi Facial Recognition
Intermediate
  • 5,323
  • 42

Work in progress

So you want to control entry to your secret lair, huh? This project will allow you to use facial recognition using a Pi and AWS.

Aquariumatic
Intermediate
  • 8,679
  • 17

Work in progress

Aquarium monitor with automation, Web GUI & IOT. Daisychain units can control multiple tanks all from the one master unit.

PiGlass
Intermediate
  • 2,777
  • 21

Full instructions

A device that can measure environmental conditions and relay to the user; in glasses form.

Creating a Raspberry Pi Universal Remote With LIRC
Intermediate
  • 601
  • 5

Full instructions

This project allows anyone to turn a Raspberry Pi into a universal remote using LIRC(LINUX Infrared Remote Control).

ProjectsCommunitiesContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback