示例#1
0
 def on_image(self, data):
     print 'Image Received'
     imgstr = re.search(r'base64,(.*)', data).group(1) #This is a hack to clean up the encoding.
     tempimg = StringIO.StringIO(imgstr.decode('base64'))
     pilimg = PILImage.open(tempimg)
     img = Image(pilimg)
     img = img.edges()
     pimg = img.getPIL()
     output = StringIO.StringIO()
     pimg.save(output, format='JPEG')
     sendstr = 'data:image/jpeg;base64,' + output.getvalue().encode('base64')
     self.emit('update', sendstr)
示例#2
0
def edgify(in_full_path):
    (root, ext) = os.path.splitext(in_full_path)
    out_full_path = root + '_edgified' + ext

    img = Image(in_full_path)
    # create an edge image using the Canny edge detector
    # set the first threshold to 160
    output = img.edges(t1=50, t2=50)
    # invert white on black image
    output = output.invert()
    # save the output images. 
    output.save(out_full_path)
    return out_full_path
示例#3
0
 def on_image(self, data):
     print 'Image Received'
     imgstr = re.search(r'base64,(.*)', data).group(
         1)  #This is a hack to clean up the encoding.
     tempimg = StringIO.StringIO(imgstr.decode('base64'))
     pilimg = PILImage.open(tempimg)
     img = Image(pilimg)
     img = img.edges()
     pimg = img.getPIL()
     output = StringIO.StringIO()
     pimg.save(output, format='JPEG')
     sendstr = 'data:image/jpeg;base64,' + output.getvalue().encode(
         'base64')
     self.emit('update', sendstr)
示例#4
0
文件: l4.py 项目: nashoalfonso/PDI
from SimpleCV import Image, Camera, Display, Image, Color
import time
import matplotlib.pyplot as plt
import numpy as np


imagen=Image('/home/pi/lunar_con_pelos.png')
#imagen.show()

#se prueba distintos metodos para ver si detecta los bellos en la piel
ed=imagen.edges()
edg=imagen+ed
edg.save('bordes_edge.png')

grad = imagen.morphGradient()
grd = imagen+grad
grd.save('bordes_gradiente.png')

lineas=imagen.findLines()
lineas.draw(Color.RED,width=3)
#imagen.show()
imagen.save("linbeas.png")

resu = imagen.resize(320,240) #se redefine la imagen para que tenga un menor tiempo 
                             #de procesamiento
gray=resu.grayscale()
inv=gray.invert()
sumimg=resu+inv
res=(resu*1.5)-(gray/2)
res.save('muestras/imagen_tratada.png')
示例#5
0
    logger.debug("Serial initialised to port: %s \n" % (port,))

# The main loop
while True:
    try:
        width = 0
        if PI_CAM:
#            cam.capture(stream,'jpeg', use_video_port=True)
	    with parray.PiRGBArray(cam) as output:
                cam.capture(output, 'rgb', use_video_port=True)
                img = Image(output.array).rotate(angle = 90, fixed=False).toGray()
        else:
            img = cam.getImage()

        #edge detect
        output = img.edges(t1=pixel_threshold, t2=4*pixel_threshold)

        #split screen
        result = halfsies(img,output)

        #find the edges
        upper_edge = []
        lower_edge = []
        
        for x in range(0,img.width):
            xSection = output.getVertScanlineGray(x)
            edge_data = getEdges(xSection)
            
            if edge_data[0] and edge_data[1]:
                upper_edge.append(edge_data[0])
                lower_edge.append(edge_data[1])
示例#6
0
文件: Lab03.py 项目: jovicuna/PDI2016
 gr3 = int(input("Ingrese parametro t3 (inicial) a utilizar: "))
 gr4 = int(input("Ingrese parametro t4 (final) a utilizar: "))
 #Detectamos los bordes con la implementacion de SimpleCV
 #[Recordar que los parametros para la funcion edges de SimpleCV
 #los modificamos en funcion de los valores del histograma que tenemos anteriormente para cada canal]
 
 ir = Image('Captura_rojo.png')
 ig = Image('Captura_verde.png')
 ib = Image('Captura_azul.png')
 
 #(...)Para escala de grises
 b_gr = igr.edges(gr1,gr2)
 b_gr.save('Borde_gris.png')
 
 #(...) y para canales RGB
 b_r = ir.edges(r1,r2) #Rojo
 b_r.save('Borde_rojo.png')
 
 b_g1 = ig.edges(g1,g2) #Verde
 b_g1.save('Borde_verde_1.png')
 b_g2 = ig.edges(g3,g4)
 b_g2.save('Borde_verde_2.png')
 b_g = b_g1 + b_g2
 b_g.save('Borde_verde_T.png')
 
 b_b1 = ib.edges(b1,b2) #Azul
 b_b1.save('Borde_azul_1.png')
 b_b2 = ib.edges(b3,b4)
 b_b2.save('Borde_azul_2.png')
 b_b = b_b1 + b_b2
 b_b.save('Borde_azul_T.png')
示例#7
0
from SimpleCV import Image
import time
#using opencv captured image, but purpose is make by video
call(“raspistill -n -t 0 -w %s -h %s -o image.bmp” % 640 480, shell=True)

img = Image(“image.bmp”)

img.show()
time.sleep(5)

#--------
cam = Camera()
img = cam.getImage()

#-----
img = img.edges()
img.show()
time.sleep(5)


img = img.binarize()
img.show()
time.sleep(5) 


img = img.findBlobs()
for blob in blobs:
    blob.draw()  
img.show()
time.sleep(5) 
#연속적인 이미지 촬영으로 영상을 만들면 속도가 너무 느리다 한방으로 가자
#!/usr/bin/python

from SimpleCV import Camera, Display, Image

img = Image("img4.png")
imggray =  img.grayscale().save("img4gray.png")
imggray = Image("img4gray.png")
(red, green, blue) = img.splitChannels(False)

# Edge detection with diferents algorithms on SCV.

# "Edges" Command.
imggray_edge = imggray.edges().save("img4gray_edges.png")
red_edge = red.edges().save("img4red_edges.png")
green_edge = green.edges().save("img4green_edges.png")
blue_edge = blue.edges().save("img4blue_edges.png")

# "morphGradient" Command
imggray_edge = imggray.morphGradient().save("img4gray_edges_morphGradient.png")
red_edge = red.morphGradient().save("img4red_edges_morphGradient.png")
green_edge = green.morphGradient().save("img4green_edges_morphGradient.png")
blue_edge = blue.morphGradient().save("img4blue_edges_morphGradient.png")

# "sobel" Command
imggray_edge = imggray.sobel().save("img4gray_edges_sobel.png")
red_edge = red.sobel().save("img4red_edges_sobel.png")
green_edge = green.sobel().save("img4green_edges_sobel.png")
blue_edge = blue.sobel().save("img4blue_edges_sobel.png")
示例#9
0
from SimpleCV import Image, Color, Display
from time import sleep
img = Image('http://i.imgur.com/lfAeZ4n.png')
# create an edge image using the Canny edge detector
# set the first threshold to 160
output = img.edges(t1=160)
# generate the side by side image.
result = output
# show the results.
# save the output images.
result.save('juniperedges.png')

while 1:

    result.show()
    sleep(11111111111)
示例#10
0
# Numbers of pixels counted
pixcount = 0
# Nombres d'examples counted
samplecount = 0


camera = picamera.PiCamera ()
camera.start-preview()
camera.start_recording("foo.h264")

while (True) :
    # Capture une image à partir de la caméra
    camera.capture("img.png", use_video_port=True)

    img =CVImage("img.jpg") #
    edgeimg =img.edges (t1=0) #
    edgeimg =save ("/tmp/edgeimg.jpg")
    pilimg = PILImage.open("/tmp/edgeimg.jpg.jpg")
    samplepixcount = 0 
    for pixel in pilimg.getdata();
        if pixel[0]==255;
            samplepixcount+=1
    print ("nombre de pixels blanc : %s" % samplepixcount)

    pixcount += samplepixcount
    samplecount+=1

    if samplecount is samples : 
        pixcount = pixcount / samples
        if pixcount < minedges :
            print("objectif sale détectée)
from SimpleCV import Color, Image
import time

img = Image("sportsballs.jpg")
circles = img.findCircle(canny=200, thresh=250, distance=15)
circles.sortArea()
circles.draw(width=4)
circles[0].draw(color=Color.RED, width=4)
img_with_circles = img.applyLayers()
edges_in_image = img.edges(t2=200)
final = img.sideBySide(edges_in_image.sideBySide(img_with_circles)).scale(0.5)
final.show()
time.sleep(15)
示例#12
0

invertidos=green.invert()#se invierte la imagen para obtener manchas negras en la foto
blob=invertidos.findBlobs()#se ve si se encuentrasn las mannchas en la foto invertida
blob.show(width=2)
pruebalunar.addDrawingLayer(invertidos.dl())
pruebalunar.show()
pruebalunar.save("porfavorguardate2.png") #guardamos la imagen 


#enncontrar manchas por color especifico para el cual tenemos:
brown_distance=green.colorDistance(Color.BLACK).invert()##cmo buscamos de color negro , le pknemos black 
blobs2_=brown_distance.findBlobs()
blobs2_.draw(color=Color.PUCE ,width=3)#se va  hacer el mismo ejemplo de la guia
brown_distance.show()
green.addDrawingLayer(brown_distance.dl())
green.show()
green.save("Porfavorguaradte5.png")

#lineas=pruebalunar.findLines()
#lineas.draw(width=3)
#pruebalunar.show()
circles=pruebalunar.findCircle(canny=100,thresh=350,distance=15)
circles=circles.sortArea()
circles.draw(width=4)
img_with_circles= pruebalunar.applyLayers()
edges_in_image= pruebalunar.edges(t2=200)
final=pruebalunar.sideBySide(edges_in_image.sideBySide(img_with_circles)).scale(0.5)
final.show()
final.save("porfavorguardate.png")