当前位置: 首页>>代码示例>>Python>>正文


Python Image.save方法代码示例

本文整理汇总了Python中SimpleCV.Image.save方法的典型用法代码示例。如果您正苦于以下问题:Python Image.save方法的具体用法?Python Image.save怎么用?Python Image.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleCV.Image的用法示例。


在下文中一共展示了Image.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send_email

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import save [as 别名]
def send_email(percentage):
            import smtplib
	    from email.MIMEMultipart import MIMEMultipart
	    from email.MIMEImage import MIMEImage
	    from email.MIMEText import MIMEText
		

            # Prepare actual message
	    msg = MIMEMultipart()
	    msg['From'] = "[email protected]" # change to your mail
	    msg['To'] = "[email protected]" # change to your mail
	    msg['Subject'] = "RPi Camera Alarm!"

	    imgcv = Image("image.jpg")
	    imgcv.save("imagesend.jpg", quality=50) # reducing quality of the image for smaller size

	    img1 = MIMEImage(open("imagesend.jpg","rb").read(), _subtype="jpg")
	    img1.add_header('Content-Disposition', 'attachment; filename="image.jpg"')
	    msg.attach(img1)

	    part = MIMEText('text', "plain")
	    part.set_payload(("Raspberry Pi camera alarm activated with level {:f}").format(percentage))
	    msg.attach(part)

            try:
                server = smtplib.SMTP("mail.htnet.hr", 25) #change to your SMTP provider
		server.ehlo()
                server.starttls()
                server.sendmail(msg['From'], msg['To'], msg.as_string())
                server.quit()
                print 'Successfully sent the mail'
            except smtplib.SMTPException as e:
    		print(e)
开发者ID:akesegic,项目名称:raspberry_pi_camera_alarm,代码行数:35,代码来源:camera_alarm.py

示例2: rotate

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import save [as 别名]
	def rotate(self, img_path, shoe_measurements):
		img = Image(img_path)
		new_file_path = self.nfn('rotated')
		img = img.rotate(shoe_measurements.toe_heel_angle(), point=shoe_measurements.cleat_length_intersection())
		self.transformations.append(new_file_path)
		img.save(new_file_path)
		return new_file_path
开发者ID:jenglert,项目名称:cleat-align,代码行数:9,代码来源:shoe.py

示例3: scale

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import save [as 别名]
	def scale(self, img_path, scale):
		new_file_path = self.nfn('resized')
		img = Image(img_path)
		img = img.scale(scale)
		img.save(new_file_path)
		self.transformations.append(new_file_path)
		return new_file_path
开发者ID:jenglert,项目名称:cleat-align,代码行数:9,代码来源:shoe.py

示例4: encuentraYFiltraBlobs

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import save [as 别名]
	def encuentraYFiltraBlobs(self,areaMin, areaMax, 
								   toleranciaWH, desviacionD,
								   toleranciaLP, tipoDibujo):
		
		imagenBlobs = Image(self.rutaImagenTratada_Fase2).copy()
		blobs = imagenBlobs.findBlobs()
		self.todosLosCandidatos = blobs
		
		if blobs:	
			
			blobs.image = imagenBlobs
			
			self.areaBlobs = blobs.area()
			blobs = self.filtroPorArea(blobs, areaMin, areaMax)
			self.numBlobsCandidatosPorArea = len(blobs)
			
			# Busca los blobs de forma circular , los blobs que pasan el filtro
			# se guardan en la lista self.articulaciones
			blobs = self.filtroPorForma(blobs, toleranciaWH, desviacionD, toleranciaLP)
			
			if tipoDibujo == 'blobs':
				self.dibujaBlobs(blobs)
			elif tipoDibujo == 'estructura':
				self.dibujaEstructura(imagenBlobs)
		
		# La imagen tratada tiene que ser guardada porque sino no funciona
		# la integracion con Tkinter
		imagenBlobs.save(self.rutaImagenBlobs)
		return Image(self.rutaImagenBlobs)
开发者ID:vencejo,项目名称:GUI-para-el-tratamiento-de-imagenes,代码行数:31,代码来源:tratamientoImagen.py

示例5: addText

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import save [as 别名]
def addText(fileName, text):
    image = Image(fileName)
    draw = DrawingLayer((IMAGE_WIDTH, IMAGE_HEIGHT))
    draw.rectangle((8, 8), (121, 18), filled=True, color=Color.YELLOW)
    draw.setFontSize(20)
    draw.text(text, (10, 9), color=Color.BLUE)
    image.addDrawingLayer(draw)
    image.save(fileName)
开发者ID:moonrise,项目名称:raspberrywater,代码行数:10,代码来源:hydroid_device.py

示例6: correct_alignment

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import save [as 别名]
	def correct_alignment(self, img_path):
		new_file_path = self.nfn('correct-alignment')
		img = Image(img_path)
		if (img.width > img.height):
			img.rotate(-90, fixed=False).save(new_file_path)
		else:
			img.save(new_file_path)
		self.transformations.append(new_file_path)
		return new_file_path
开发者ID:jenglert,项目名称:cleat-align,代码行数:11,代码来源:shoe.py

示例7: correct_alignment

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import save [as 别名]
def correct_alignment(si, image_path):
	new_file_path = step_file_path(si, 'correct-alignment')
	img = Image(image_path)
	if (img.width > img.height):
		img.rotate(-90, fixed=False).save(new_file_path)
	else:
		img.save(new_file_path)
	si.step_outputs.append(new_file_path)
	return new_file_path
开发者ID:jenglert,项目名称:cleat-align,代码行数:11,代码来源:align.py

示例8: run

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import save [as 别名]
    def run(self):
        cam_mode=self.cam_mode
        wsh = self.wsh
        js = self.js
        wsh2 = self.wsh2
        d = "n"
        c2 = self.c2
        c = self.c
        sqx = self.sqx
        sqy = self.sqy
        x = 0
        y = 0
        stat="live cam"
        if cam_mode == 3:
            img1 = c2.getImage()
        if cam_mode==1:
            img1 = c.getImage()
            time.sleep(1)
	    with picamera.PiCamera() as camera:
                camera.resolution = (544, 288)
                camera.capture('imagesmall.jpg')
            img2 = Image('imagesmall.jpg')
            time.sleep(.5)
            img1 = img1.sideBySide(img2)
            img1 = img1.scale(544,288)
            time.sleep(.5)
        if cam_mode==2:
            with picamera.PiCamera() as camera:
                camera.resolution = (544, 288)
                camera.capture('imagesmall.jpg')
            img1 = Image('imagesmall.jpg')
        self.img1 = img1

        blobs = img1.findBlobs()
        if blobs :
            ##blobs.draw()
            img1.drawCircle((blobs[-1].x,blobs[-1].y),30,color=(255,255,255))
            img1.drawCircle((blobs[-1].centroid()),10,color=(255,100,100))
            blobx1 = blobs[-1].x
            bloby1 = blobs[-1].y
            print blobx1
            print bloby1
            img1.drawText("ogp: live cam", 10, 10, fontsize=50)
            img1.drawText(str(blobx1), blobx1, 250, color=(255,255,255), fontsize=20)
            img1.drawText(str(bloby1), 10, bloby1, color=(255,255,255), fontsize=20)
            img1.save(js.framebuffer)
            sqx2=sqx+20
            sqy2=sqy+20
            time.sleep(.5) 
            wsh.write_message(wsh2, "live")
        
        else:
            wsh.write_message(wsh2, "live")
开发者ID:opengimbal,项目名称:ogp,代码行数:55,代码来源:chase2.py

示例9: face_recognize

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import save [as 别名]
def face_recognize(filename):
    from SimpleCV import Image, Display, DrawingLayer
    
    image = Image(filename)
    faces = image.findHaarFeatures('face.xml')
    if faces:
        for face in faces:
            face_layer = DrawingLayer((image.width, image.height))
            face_box = face_layer.centeredRectangle(face.coordinates(), (face.width(), face.height()))
            image.addDrawingLayer(face_layer)
            image.applyLayers()
        image.save(filename)
        print('偵測到 {} 張人臉'.format(len(faces)))
    else:
        print('沒有偵測到人臉')
开发者ID:AlexW867,项目名称:rpi2-sample-codes,代码行数:17,代码来源:face_recognize.py

示例10: activaCamara

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import save [as 别名]
def activaCamara():
	""" Se activa la camara para detectar movimiento 
	utilizando el algormitmo running segmentation de SimpleCV"""
	global proximo
	screenLength = resolucion[0] 
	min_blob_size = screenLength * 0.15
	max_blob_size = screenLength * 0.75
	ahora = datetime.datetime.now()
	
	img = util.tomaFoto(filename,brillo,resolucion,modoExposicion)
	rs.addImage(img)
	diffImg = rs.getSegmentedImage(False)
	
	if diffImg is not None:
		
		blobs = diffImg.dilate(3).findBlobs()
		
		if blobs is not None   :
			print screenLength, min_blob_size, blobs[-1].length(),  max_blob_size	
			
			if blobs[-1].length() > min_blob_size and blobs[-1].length() < max_blob_size :
				print "El sensor ha detectado algo relevante"
				mensaje = 'Alerta ' + str(ahora) + ".jpg"
				
				imagen = Image (filename)
				
				os.chdir(RUTA_BASE_LOCAL_ALERTAS)
				blobs.image = imagen
				blobs[-1].draw(width=5, color=Color.GREEN)
				imagen.drawText(str(ahora), x= 20, y =10, fontsize=25)
				imagen.save(str(ahora)+'.jpg')
				os.chdir(RUTA_BASE_LOCAL)
				
				destinatarios = ['[email protected]', '[email protected]'] 
				mensaje = 'Alerta de la alarma, visita https://www.dropbox.com para ver las fotos'
				mandaMensaje(mensaje, destinatarios)

	# ---------------------------------------------
	# Foto a intervalos regulares
	# ---------------------------------------------
	if ahora > proximo :
		print "tomada foto de cada hora"
		camara.tomaFoto(str(ahora) + ".jpg", brillo=50,resolucion=(640,480),preview=False,modoExposicion='auto')
		proximo = datetime.datetime.now() + periodo
开发者ID:chuison,项目名称:Alarma-Visual-Avanzada,代码行数:46,代码来源:alarma.py

示例11: Run

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import save [as 别名]
def Run(cmdPipe):
    steadyStateFPS = 10
    desiredBuffer = 60*60 #1 minute * 60 seconds
    numberOfFrames = steadyStateFPS*desiredBuffer;
    fmt = '%Y-%m-%d %H:%M:%S'

    disp = Display()

    filelist = []
    frameCounter = 101
    sleepTime = .1

    while disp.isNotDone():
        # check command
        if cmdPipe.poll():
            cmd = cmdPipe.recv()
            if cmd=='shutdown':
                print('player', 0, "Shutting down.")
                break

        if frameCounter > 100 or len(filelist) == 0:
            frameCounter = 0
            filelist = glob("images/*.jpg")
            if len(filelist)>numberOfFrames:
                sleepTime = 1.0/steadyStateFPS
                print("player", 0, "number of frames in buffer="+str(len(filelist))+" desired="+str(numberOfFrames)+" setting sleeptime to "+str(sleepTime))
            else:
                sleepTime = (1.0/steadyStateFPS)+.01
                print("player", 0, "number of frames in buffer="+str(len(filelist))+" desired="+str(numberOfFrames)+" setting sleeptime to "+str(sleepTime))


        filename = filelist.pop(0)
        img = Image(filename)
        matchObj = re.search(r'[0-9- :]+', filename)

        d1_ts = time.mktime(datetime.strptime(matchObj.group(), fmt).timetuple())
        d2_ts = time.mktime(datetime.utcnow().timetuple())
        offset = int(d1_ts-d2_ts)/60
        img.drawText(str(offset),  x=600, y=470)
        img.save(disp)
        os.remove(filename)
        frameCounter = frameCounter+1
        time.sleep(sleepTime)
开发者ID:dlgreenwald,项目名称:slowglass,代码行数:45,代码来源:player.py

示例12: drawImage

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import save [as 别名]
def drawImage():
    #Load Map
    d = Display((1240, 820), title="London Map - Scotland Yard")
    lMap = Image("maps/map.jpg")

    #Check Position from players

    #See corresponding pixel in list

    #Draw Circle from players
    circlesLayer = DrawingLayer((lMap.width, lMap.height))
    circlesLayer.circle ((191,44), 20,color=Color.BLACK, filled=True, alpha = 255)
    lMap.addDrawingLayer(circlesLayer)

    #Display
    lMap.applyLayers()
    lMap.save(d)

    '''Later create a "draw possibilites" areas in map for thief '''
开发者ID:Flavsditz,项目名称:projects,代码行数:21,代码来源:track_v0_3.py

示例13: __init__

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import save [as 别名]
class Scale:
    global db, Gd
    name = "Scale"

    def __init__(self, fname):
        self.img = Image(fname)
        if not fname == "input.png":
            self.img.save("input.png")
        self.cropped = Cropx(self.img)  # crop image
        self.cropped.save("cropTest.png")  # save intermediat results
        [self.wt, self.fat, self.h2o] = Part(self, self.cropped)  # partition cropped image
        self.fat.save("fatTest.png")
        self.h2o.save("h2oTest.png")
        self.wt.save("wtTest.png")
        #  hunt for the appropriate number in each partitioned image
        self.nwt = hunt(self.wt, "wt")
        self.nfat = hunt(self.fat, "fat")
        self.nh2o = hunt(self.h2o, "h2o")
        return None
开发者ID:charleswest,项目名称:Weight,代码行数:21,代码来源:weight.py

示例14: save_trained_image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import save [as 别名]
def save_trained_image(train_as, img):
    image = Image(img)
    trainPath = CLASSIFIER_TRAIN_PATH + '/' + train_as
    # make sure the train/{class} directory exist
    if not os.path.exists(trainPath):
        os.makedirs(trainPath)
    imageName = os.path.basename(img)
    (filename, fileext) = os.path.splitext(imageName)
    # make sure imageName is not duplicated by seq number
    uniq = 1
    imagePath = '%s/%s_%03d%s' % (trainPath, train_as, uniq, fileext)
    while os.path.exists(imagePath):
        imagePath = '%s/%s_%03d%s' % (trainPath, train_as, uniq, fileext)
        uniq += 1
    image.save(imagePath)
    log("save_trained_image(train_as=%s, img=%s, saved=%s)" % (train_as, img, imagePath))
    return {
        "image": img,
        "class": train_as,
        "saved": imagePath
    }
开发者ID:jonahgroup,项目名称:SnackClassifier,代码行数:23,代码来源:image_utils.py

示例15: get_image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import save [as 别名]
def get_image(url, file_name, dir='images/'):
    """Return PIL.Image

    Get 'file_name' at 'dir'
    if the file doesn't exists it download it and save it at dir+file_name
    otherwise if the files exists open the file and return the reference
    """
    img = None

    if file_name:
        output_file = dir + file_name if dir else file_name

        if file_name in os.listdir(dir):
            img = Image(output_file)
        elif url:
            buff = StringIO(get_web_content(url))
            img = Image(buff)
            img.save(output_file)
        else:
            print 'Error Impossible to get images files'

    return img
开发者ID:stevenaubertin,项目名称:hss,代码行数:24,代码来源:webServer.py


注:本文中的SimpleCV.Image.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。