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


Python Image.drawText方法代码示例

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


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

示例1: processQuote

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawText [as 别名]
def processQuote(src):
	try:
		img = Image(src)
		text = img.binarize().readText()
	except Exception as e:
		print e
		print '###'
	else:
		cleantext = cleanText(text)
		translated = trans.translate(cleantext, langpair)
		if translated:
			img.drawText(translated, 0, 0, color=Color.BLACK, fontsize=24)
			print lan1 + ": " + cleantext
			print lan2 + ": " + translated.encode('utf-8')
			print '###'
		img.show()
开发者ID:pianiel,项目名称:simplecv-demo,代码行数:18,代码来源:quotes.py

示例2: activaCamara

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawText [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

示例3: Run

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawText [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

示例4: run

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawText [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

示例5: run

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawText [as 别名]
    def run(self):

        wsh = self.wsh
      ##  c = self.c
        js = self.js
        wsh2 = self.wsh2
        acu = int(1)
        acd = int(1)
        acl = int(1)
        acr = int(1)
        irpic = pinoir2(js)

        img1 = Image('imagesmall.jpg')   
        blobs = img1.findBlobs()
        img1.drawCircle((blobs[-1].x,blobs[-1].y),30,color=(255,255,255))
        img1.drawCircle((blobs[-1].centroid()),10,color=(255,100,100))
        acx1 = blobs[-1].x
        acy1 = blobs[-1].y


        img1.drawText("ogp: autocalibrating", 10, 10, fontsize=50)
        img1.drawText(str(acx1), 10, 50, color=(255,255,255), fontsize=20)
        img1.drawText(str(acy1), 10, 75, color=(255,255,255), fontsize=20)
        img1.save(js.framebuffer)
        
        d = 'r'
        ms = 50
        s.write('4')
        mov = acx(s, d, ms, acu, acd, acl, acr)
        mov.run()
            
        time.sleep(1)

        img1 = c.getImage()   
        blobs = img1.findBlobs()
        img1.drawCircle((blobs[-1].x,blobs[-1].y),30,color=(255,255,255))
        img1.drawCircle((blobs[-1].centroid()),10,color=(255,100,100))
        acx2 = blobs[-1].x
        acy2 = blobs[-1].y

        
        img1.drawText("ogp: autocalibrating", 10, 10, fontsize=50)
        img1.drawText(str(acx1), 10, 50, color=(255,255,255), fontsize=20)
        img1.drawText(str(acy1), 10, 75, color=(255,255,255), fontsize=20)        
        img1.drawText(str(acx2), 40, 50, color=(255,255,255), fontsize=20)
        img1.drawText(str(acy2), 40, 75, color=(255,255,255), fontsize=20)
        img1.save(js.framebuffer)
        
        d = 'd'
        ms = 50
        s.write('9')
        mov = acx(s, d, ms, acu, acd, acl, acr)
        mov.run()
        time.sleep(1)


        img1 = c.getImage()   
        blobs = img1.findBlobs()
        img1.drawCircle((blobs[-1].x,blobs[-1].y),30,color=(255,255,255))
        img1.drawCircle((blobs[-1].centroid()),10,color=(255,100,100))
        acx3 = blobs[-1].x
        acy3 = blobs[-1].y

        img1.drawText("ogp: autocalibrating", 10, 10, fontsize=50)
        img1.drawText(str(acx1), 10, 50, color=(255,255,255), fontsize=20)
        img1.drawText(str(acy1), 10, 75, color=(255,255,255), fontsize=20)        
        img1.drawText(str(acx2), 40, 50, color=(255,255,255), fontsize=20)
        img1.drawText(str(acy2), 40, 75, color=(255,255,255), fontsize=20)
        img1.drawText(str(acx3), 70, 50, color=(255,255,255), fontsize=20)
        img1.drawText(str(acy3), 70, 75, color=(255,255,255), fontsize=20)
        img1.save(js.framebuffer)
        d = 'l'
        ms = 50
        s.write('2')
        mov = acx(s, d, ms, acu, acd, acl, acr)
        mov.run()
        time.sleep(1)


        img1 = c.getImage()   
        blobs = img1.findBlobs()
        img1.drawCircle((blobs[-1].x,blobs[-1].y),30,color=(255,255,255))
        img1.drawCircle((blobs[-1].centroid()),10,color=(255,100,100))
        acx4 = blobs[-1].x
        acy4 = blobs[-1].y

        img1.drawText("ogp: autocalibrating", 10, 10, fontsize=50)
        img1.drawText(str(acx1), 10, 50, color=(255,255,255), fontsize=20)
        img1.drawText(str(acy1), 10, 75, color=(255,255,255), fontsize=20)        
        img1.drawText(str(acx2), 40, 50, color=(255,255,255), fontsize=20)
        img1.drawText(str(acy2), 40, 75, color=(255,255,255), fontsize=20)
        img1.drawText(str(acx3), 70, 50, color=(255,255,255), fontsize=20)
        img1.drawText(str(acy3), 70, 75, color=(255,255,255), fontsize=20)
        img1.drawText(str(acx4), 100, 50, color=(255,255,255), fontsize=20)
        img1.drawText(str(acy4), 100, 75, color=(255,255,255), fontsize=20)
        img1.save(js.framebuffer)
        d = 'u'
        ms = 50
        s.write('6')
        mov = acx(s, d, ms, acu, acd, acl, acr)
#.........这里部分代码省略.........
开发者ID:juoni,项目名称:ogp,代码行数:103,代码来源:ogplab.py

示例6: run

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawText [as 别名]
    def run(self):
        cam_mode=self.cam_mode
        s.write('s')
        wsh = self.wsh
        js = self.js
        wsh2 = self.wsh2
        ms = 50
        d = "n"
        acu = int(1)
        acd = int(1)
        acl = int(1)
        acr = int(1)
        c2=self.c2
        sqx=self.sqx
        sqy=self.sqy
        x=0
        y=0
        stat="centering"
        if cam_mode == 3:
            img1 = c2.getImage()
        if cam_mode==1:
            with picamera.PiCamera() as camera:
                camera.resolution = (544, 288)
                camera.capture('imagesmall.jpg')
            img1 = Image('imagesmall.jpg')
        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: centering", 10, 10, fontsize=50)
            img1.drawText(str(blobx1), 10, 200, color=(255,255,255), fontsize=50)
            ##img1.drawText(str(bloby1), 50, 200, color=(255,255,255), fontsize=50)
            img1.drawText(str(bloby1), 10, 250, color=(255,255,255), fontsize=50)
            img1.save(js.framebuffer)
            sqx2=sqx+20
            sqy2=sqy+20

            if blobx1 > sqx2:
                d = '_r'
                s.write('4')
                mov = acx(s, d, ms, acu, acd, acl, acr)
                mov.run()
                wsh.write_message(wsh2, "g_"+ str(d))

            if blobx1 < sqx:
                d = 'l'
                s.write('2')
                mov = acx(s, d, ms, acu, acd, acl, acr)
                mov.run()
                wsh.write_message(wsh2, "g_"+ str(d))

            if bloby1 > sqy2:
                d = 'd'
                s.write('9')
                mov = acx(s, d, ms, acu, acd, acl, acr)
                mov.run()
                wsh.write_message(wsh2, "g_"+ str(d))

            if bloby1 < sqy:
                d = 'u'
                s.write('6')
                mov = acx(s, d, ms, acu, acd, acl, acr)
                mov.run()
                wsh.write_message(wsh2, "g_"+ str(d))
         
            wsh.write_message(wsh2, "c")
        
        else:
            wsh.write_message(wsh2, "c_" + "null" )
开发者ID:juoni,项目名称:ogp,代码行数:83,代码来源:chase2.py

示例7: Camera

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawText [as 别名]

if __name__ == '__main__':
    cam = Camera(0)
    img = Image()

    samples = 0
    coordinates = redCoords = (0,0)
    text = " "

    while True:
        img = cam.getImage()
        # Make image black and white
        tmp = findRedDot(img)
        if (tmp != None):
            coordinates= (coordinates[0]+tmp[0][0], coordinates[1]+tmp[0][1])
            samples+=1

        if samples == 10:
            samples = 0
            coordinates = (coordinates[0]/10, coordinates[1]/10)
            text = str(coordinates)
            redCoords = coordinates
            coordinates = (0,0)

        redcircle = DrawingLayer((img.width, img.height))
        redcircle.circle(redCoords, 5, filled=True, color=(0,255,0)) #add circle point 10,10, radius 10.
        img.addDrawingLayer(redcircle)
        img.applyLayers()
        img.drawText(text)
        img.show()
开发者ID:Flavsditz,项目名称:projects,代码行数:32,代码来源:findRedDot.py

示例8: Image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawText [as 别名]
# -*- coding: utf-8 -*-

from SimpleCV import Display, Image, Color
import time

img = Image("img-ex3.png")
display = Display()

img.drawText("Hello World", 50, 50, Color.RED, 50)

img.save(display)
time.sleep(5)

exit()
开发者ID:relsi,项目名称:Python-SimpleCV_Course_Examples,代码行数:16,代码来源:ex3.py

示例9: histo

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import drawText [as 别名]
    def histo(self): ## this def is the "light meter" part---
        cam_mode = self.cam_mode ## the pic gets cataloged if true ---
        js = self.js
        w = self.w
        cent = 0
        rgb1 = 0
        c2 = self.c2
        wsh = self.wsh
        wsh2 = self.wsh2
        i=0
        brightpixels=0
        darkpixels=0
        blobs = 0

        if cam_mode == 3: ## sort out the confusing cam modes
            img1 = c2.getImage()
            time.sleep(.25)

        if cam_mode==1:
            with picamera.PiCamera() as camera:
                camera.resolution = (544, 288)
                camera.capture('imagesmall.jpg')
            img1 = Image('imagesmall.jpg')

        if cam_mode==2:
            with picamera.PiCamera() as camera:
                camera.resolution = (544, 288)
                camera.capture('imagesmall.jpg')
            img1 = Image('imagesmall.jpg')

        blobs = img1.findBlobs()
        time.sleep(0.5)

        if blobs:
##find the blob centroid and cut it out 20x20
            crop1 = blobs[-1].x      
            crop2 = blobs[-1].y
            crop3 = crop1 - 10
            crop4 = crop2 - 10
            thumbnail = img1.crop(crop3,crop4,20,20)
            img2 = thumbnail
            hist = img2.histogram(20)
            ## split the thumb into 20 levels of darkness
            brightpixels = hist[10]
            ## 10 is where the darkest of the light pixels accumulate
            print brightpixels

##while i < 20:
##old code for if you want to split the histogram in two
##if (i < 10):
##darkpixels = darkpixels + hist[i]
##self.darkpixels = darkpixels
##print hist[i]
##else:
##brightpixels = brightpixels + hist[i]
##self.brightpixels = brightpixels
##print hist[i]
##i = i + 1

            if (brightpixels<400):   ## heres where it decides to catalog the pic or not...
                wsh.write_message(wsh2, "histo_" + str(darkpixels) + "_" + str(brightpixels))
                print "blob"
                x = self.x
                y = self.y
                p = self.p
                p = p + 1
                thumb1 = "/var/www/html/images/thumbs/thumb"
                thumb3 = ".png"
                thumbpath = thumb1 + str(p) + thumb3
                print thumbpath
                thumbnail.save(thumbpath)
                img1.drawText("blob = True", 10, 35, color=(255,255,255),fontsize=30)
                img1.drawText("search_mode", 10, 5, color=(0,0,255),fontsize=40)
                img1.drawText("blob centroid", blobs[-1].x,blobs[-1].y, color=(255,255,255),fontsize=20)
                img1.drawCircle((blobs[-1].x,blobs[-1].y),30,color=(255,255,0))
                img1.drawCircle((blobs[0].centroid()),10,color=(255,255,255))
                print blobs[-1].meanColor()
                rgb1 = blobs[-1].meanColor()
                cent = blobs[-1].centroid()

                pth1 = "/var/www/html/images/image"
                pth3 = ".png"
                pth = pth1 + str(p) + pth3
                print pth
                img1.save(pth)
                time.sleep(0.5)

                self.p = p

                mySet.add((p,x,y,w,cent,rgb1))
                self.mySet = mySet

                wshx = str(self.x)
                wshy = str(self.y)

                centroidx = int(cent[0])
                centroidy=int(cent[1])
                rcolor=rgb1[0]
                gcolor=rgb1[1]
                bcolor=rgb1[2]
#.........这里部分代码省略.........
开发者ID:opengimbal,项目名称:ogp,代码行数:103,代码来源:ogplab.py


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