def take_background(): log("take_background()") # get background snapshot if DEBUG: img = Image(TEMP_FOLDER_PATH + STATIC_BACKGROUND_NAME) else: img = capture_camera_image() # get mean_color mean_color = img.meanColor() # save it db = db_open() db_backgrounds_write(db, db_background(date_created=datetime.now(), mean_color=mean_color)) db_close(db)
from __future__ import print_function from SimpleCV import Image, Color, VirtualCamera, Display import SimpleCV as scv # # video = VirtualCamera('', 'video') # display = Display() # while display.isNotDone(): # img = video.getImage() # try: # dist = img - img.colorDistance(Color.RED) # dist.show() # except KeyboardInterrupt: # display.done = True # if display.mouseRight: # display.done = True # display.quit() img = Image('img/curb.JPG') img = img.crop(0, 2*img.height/3, img.width, 5*img.height/6) print(img.meanColor()) # img = img.binarize() # img.findBlobs().draw() # ls = img.findLines() # for l in ls: # l.draw() # img.findBlobs().draw() # img = img.colorDistance(Color.RED) img.save('img/curb_processed.jpg')
from SimpleCV import Color, Image import curses import time import MySQLdb #Image blocking--block processing while True: img = Image("/var/www/html/cam.jpg") width, height = img.size() print(str(int(width)) + ' h: ' + str(int(height))) color = img.meanColor() blue, green, red = img.meanColor() red = int(red) green = int(green) blue = int(blue) #Server Connection to MySQL: datetime = (time.strftime("%Y-%m-%d ") + time.strftime("%H:%M:%S")) conn = MySQLdb.connect(host="localhost", user="******", passwd="raspberry", db="sensor_database") x = conn.cursor() #Get last color value: try: x.execute("SELECT * FROM color_log ORDER BY DATE DESC LIMIT 1;") conn.commit() row = x.fetchone()