import SimpleCV as scv
from SimpleCV import Image
import cv2
import time
from start_camera import start_camera
import threading

def take_50_pictures():
  camera_thread = threading.Thread(target=start_camera)
  camera_thread.start()
  from get_images_from_pi import get_image, valid_image
  time.sleep(2)
  count = 0
  while (count < 50):
    get_image(count)
    count += 1

def detect_stop_sign(image):
  reds = image.hueDistance(color=scv.Color.RED)
  stretch = reds.stretch(20,21)
  invert = stretch.invert()
  blobs = invert.findBlobs(minsize=2000)
  if blobs:
    for blob in blobs:
      print blob.area()
      blob.draw(color=(0, 128, 0))
  invert.show()
  invert.show()
  time.sleep(3)

image = Image('images/0.jpg')
x = 0
while (x < 40):
  image = Image('images/'+ str(x) + '.jpg')
  detect_stop_sign(image)
  print x
  x +=1

exit()






@@ -455,16 +455,24 @@
  stretch
+ed_image
  = reds.
@@ -494,16 +494,24 @@
   invert
+ed_image
  = stret
@@ -512,16 +512,24 @@
  stretch
+ed_image
 .invert(
@@ -546,16 +546,24 @@
 = invert
+ed_image
 .findBlo
@@ -573,18 +573,18 @@
 minsize=
-20
+35
 00)%0A  if
@@ -599,133 +599,65 @@
     
-for blob in blobs:%0A      print blob.area()%0A      blob.draw(color=(0, 128, 0))%0A  invert.show()%0A  invert.show()%0A  time.sleep(3)
+return True #means there is an obstruction%0A  return False
 %0A%0Aim
@@ -688,17 +688,17 @@
 g')%0Ax = 
-0
+5
 %0Awhile (
@@ -705,13 +705,22 @@
 x %3C 
-40
+7
 ):%0A
+  print x%0A
   im
@@ -739,16 +739,20 @@
 'images/
+stop
 '+ str(x
@@ -789,26 +789,16 @@
 (image)%0A
-  print x%0A
   x +=1%0A

Make detect stop sign function for Henry to add into class