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


Python Image.addDrawingLayer方法代码示例

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


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

示例1: fneighbourdhood_area

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import addDrawingLayer [as 别名]
def fneighbourdhood_area(x):
    global na, thres, windowTitle, tipo
    if x % 2 ==0:
        na = x+1
    else:
        na = x
    if na == 0 or na == 1:
        na = 3
    if tipo == 0:
        thres = img
    elif tipo == 1:
        thres = cv2.adaptiveThreshold(img, maxValue,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY, na, cons)
    elif tipo == 2:
        thres = cv2.adaptiveThreshold(img, maxValue, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY,na,cons)
    blobImg = Image(thres)
    invImg = blobImg.invert()
    blobImg = blobImg.rotate90()
    invImg = blobImg.invert()
    blobs = invImg.findBlobs()
    for blob in blobs:
        #print blob.coordinates()
        invImg.dl().circle(blob.coordinates(), 3, Color.RED, filled = True)
    blobImg.addDrawingLayer(invImg.dl())
    blobs.show(color=Color.GREEN,width=1)
    
    cv2.imshow(windowTitle, thres)
开发者ID:,项目名称:,代码行数:28,代码来源:

示例2: adaptative_thresholding

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import addDrawingLayer [as 别名]
def adaptative_thresholding(x):
    global thres, na, cons, maxValue, tipo, img, windoTitle
    if x == 0:
        thres = img
        maxValue = 255
        na = 11
        cons = 2;
        cv2.createTrackbar('Neighbourhood area (odds)', windowTitle, na, maxValue, fneighbourdhood_area)
        cv2.createTrackbar('Constant', windowTitle, -maxValue, maxValue, fConstant)
        cv2.createTrackbar('MaxValue', windowTitle, maxValue, maxValue, fMaxValue)
    elif x == 1:
        thres = cv2.adaptiveThreshold(img, maxValue,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY, na, cons)
    elif x == 2:
        thres = cv2.adaptiveThreshold(img, maxValue, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY,na,cons)
    tipo = x
    blobImg = Image(thres)
    invImg = blobImg.invert()
    blobImg = blobImg.rotate90()
    invImg = blobImg.invert()
    blobs = invImg.findBlobs()
    for blob in blobs:
        #print blob.coordinates()
        invImg.dl().circle(blob.coordinates(), 3, Color.RED, filled = True)
    blobImg.addDrawingLayer(invImg.dl())
    blobs.show(color=Color.GREEN,width=1)
    cv2.imshow(windowTitle, thres)
开发者ID:,项目名称:,代码行数:28,代码来源:

示例3: thresholding

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import addDrawingLayer [as 别名]
def thresholding(x):
    global thres, value, maxValue, img, tipo
    imgO = img
    if (x == 0):
        thres = None
        filtro = img
        value = 0
        maxValue = 255
        cv2.createTrackbar('Value', windowTitle, value, maxValue, fValue)
        cv2.createTrackbar('MaxValue', windowTitle, maxValue, maxValue, fMaxValue)


    elif (x == 1):
        thres = cv2.THRESH_BINARY+cv2.THRESH_OTSU
    elif (x==2):
        thres = cv2.THRESH_BINARY+cv2.THRESH_OTSU
        img  = cv2.GaussianBlur(img,(5,5),0)
    if (x != 0):
        ret, filtro = cv2.threshold(img,value, maxValue, thres)
    tipo = x
    img = imgO
    blobImg = Image(filtro)
    invImg = blobImg.invert()
    blobImg = blobImg.rotate90()
    invImg = blobImg.invert()
    blobs = invImg.findBlobs()
    for blob in blobs:
        #print blob.coordinates()
        invImg.dl().circle(blob.coordinates(), 3, Color.RED, filled = True)
    blobImg.addDrawingLayer(invImg.dl())
    blobs.show(color=Color.GREEN,width=1)
    cv2.imshow(windowTitle, filtro)
开发者ID:,项目名称:,代码行数:34,代码来源:

示例4: addText

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

示例5: face_recognize

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

示例6: fMaxValue

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import addDrawingLayer [as 别名]
def fMaxValue(x):
    global maxValue, value, thres, img, filtro
    maxValue = x
    if (thres is None):
        filtro = img

    else:
        ret, filtro = cv2.threshold(img,value, maxValue, thres)
    blobImg = Image(filtro)
    invImg = blobImg.invert()
    blobImg = blobImg.rotate90()
    invImg = blobImg.invert()
    blobs = invImg.findBlobs()
    for blob in blobs:
        #print blob.coordinates()
        invImg.dl().circle(blob.coordinates(), 3, Color.RED, filled = True)
    blobImg.addDrawingLayer(invImg.dl())
    blobs.show(color=Color.GREEN,width=1)
    cv2.imshow(windowTitle, filtro)
开发者ID:,项目名称:,代码行数:21,代码来源:

示例7: drawImage

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

示例8: fConstant

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import addDrawingLayer [as 别名]
def fConstant(x):
    global cons, thres, windowTitle, tipo, maxValue, na, img
    # const positive to white, otherwise, to black
    cons = x
    if tipo == 0:
        thres = img
    elif tipo == 1:
        thres = cv2.adaptiveThreshold(img, maxValue,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY, na, cons)
    elif tipo == 2:
        thres = cv2.adaptiveThreshold(img, maxValue, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY,na,cons)
    
    blobImg = Image(thres)
    invImg = blobImg.invert()
    blobImg = blobImg.rotate90()
    invImg = blobImg.invert()
    blobs = invImg.findBlobs()
    for blob in blobs:
        #print blob.coordinates()
        invImg.dl().circle(blob.coordinates(), 3, Color.RED, filled = True)
    blobImg.addDrawingLayer(invImg.dl())
    blobs.show(color=Color.GREEN,width=1)
    cv2.imshow(windowTitle, thres)
开发者ID:,项目名称:,代码行数:24,代码来源:

示例9: Image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import addDrawingLayer [as 别名]
#!/usr/local/env python
# coding=utf-8
#
# Author: Archer Reilly
# Desc: 按照颜色找出物体blob
# File: FindBlobs.py
# Date: 30/July/2016
#
from SimpleCV import Color, Image

# img = Image('/home/archer/Downloads/Chapter 8/mandms-dark.png')
img = Image('/home/archer/Downloads/1185391864.jpg')

# blue_distance = img.colorDistance(Color.BLUE).invert()
blue_distance = img.colorDistance(Color.BLACK).invert()

blobs = blue_distance.findBlobs(minsize=15)

blobs.draw(color=Color.RED, width=3)

blue_distance.show()

img.addDrawingLayer(blue_distance.dl())
img.save('res.png')
img.show()
开发者ID:csrgxtu,项目名称:ComputerVision,代码行数:27,代码来源:FindBlobs.py

示例10: str

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import addDrawingLayer [as 别名]
            #object.draw(color=Color.PUCE, width=2)
            #blue_distance.show()
            #blue_distance.save("/dev/shm/p3.png")

            corners=img.findCorners()

            statusWin.clear()
            statusWin.addstr( 1, 1,  str(object.meanColor()))

            num_corners = len(corners)
            statusWin.addstr(2,1, "Corners Found:" + str(num_corners))

            corners.draw()

            img.addDrawingLayer(object.dl())


            # circle tracking

            #dist = img.colorDistance(Color.BLACK).dilate(2)
            #segmented = dist.stretch(200,255)

            blobs = img.findBlobs()
            if blobs:
                    circles = blobs.filter([b.isCircle(0.2) for b in blobs])
                    if circles:
                        img.drawCircle((circles[-1].x, circles[-1].y), circles[-1].radius(),Color.BLUE,3)


开发者ID:kgroveshok,项目名称:rasppi,代码行数:29,代码来源:robot.py

示例11: lasmanchas

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import addDrawingLayer [as 别名]
(red,green,blue)=pruebalunar.splitChannels(False) # la separo en RGB
red.save("fotoenrojo.png")
green.save("fotoenverde.png")
blue.save("fotoenazul.png")

#codigo para encontrarn manchas solo se a echo en escala de grises  
prueba69=green.binarize() #la binarizo por que se vera mejor asi 
mancha=prueba69.findBlobs() #ocupo el comando para encontrar lasmanchas (lunares)
mancha.show(Color.YELLOW)
prueba69.save("porfavorguardate3.png")


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)
开发者ID:yavier123,项目名称:lab3pdi2016,代码行数:33,代码来源:fotoslunar.py

示例12: Image

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

img = Image("ex23b.png") #Open ex23b.png too :)

colorDist = img.colorDistance(Color.BLUE).invert()
blobs = colorDist.findBlobs()

# Draw a BLACK border at blobs
blobs.draw(color=Color.BLACK, width=3)

# The thing is at this line before
img.addDrawingLayer(colorDist.dl())
img.show()
开发者ID:italofernandes84,项目名称:Python-SimpleCV_Course_Examples,代码行数:15,代码来源:ex23.py

示例13: Image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import addDrawingLayer [as 别名]
head = Image('head.png')

amgothic = Image('amgothic.png')

scream = Image('scream.png')

amgothic.dl().blit(head,(175, 110))

amgothic.show()

time.sleep(2)

layer = amgothic.getDrawingLayer()

scream.addDrawingLayer(layer)

scream.show()
time.sleep(2)

print amgothic._mLayers
print scream._mLayers

layer.blit(head,(75,220))

amgothic.show()
time.sleep(2)
scream.show()

time.sleep(5)
开发者ID:vizcacha,项目名称:practicalcv,代码行数:31,代码来源:HeadOnSpike.py

示例14: Display

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import addDrawingLayer [as 别名]
from SimpleCV import Image,Display,DrawingLayer,Color
from time import sleep

myDisplay = Display()

raspberryImage = Image("test.jpg")

myDrawingLayer = DrawingLayer((raspberryImage.width, raspberryImage.height))
myDrawingLayer.rectangle((50,20),(250,60),filled=True)
myDrawingLayer.setFontSize(45)
myDrawingLayer.text("Raspberries!",(50,20),color=Color.WHITE)
raspberryImage.addDrawingLayer(myDrawingLayer)
raspberryImage.applyLayers()
raspberryImage.save(myDisplay)
while not myDisplay.isDone():
  sleep(0.1)
开发者ID:Naohiro2g,项目名称:raspberry-pi-python-sample,代码行数:18,代码来源:superimpose.py

示例15: fancify

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

#.........这里部分代码省略.........
                    bottom_of_nose = y_nose + (nose.height() * 4 / 5)
                    top_of_mouth = y_mouth
                    # if top_of_mouth > bottom_of_nose:
                    #    top_of_mouth = bottom_of_nose
                    y_must = y_face + ((bottom_of_nose + top_of_mouth) / 2) - (cur_stache.height / 2)

                    middle_of_nose = nose.x
                    middle_of_mouth = mouth.x
                    x_must = x_face + ((middle_of_nose + middle_of_mouth) / 2) - (cur_stache.width / 2)

                if right_eye:
                    x_right_eye = right_eye.x - (right_eye.width() / 2)
                    y_right_eye = right_eye.y - (right_eye.height() / 2)

                    # Setup Monocle Image
                    cur_mono = monocle.copy()
                    scale_factor = ((right_eye.width() / 65.0) + (face.width() / 200.0)) / 2.0
                    cur_mono = cur_mono.scale(scale_factor)
                    mono_mask = cur_mono.createAlphaMask(hue_lb=0, hue_ub=100).invert()

                    # Calculate Monocle Position
                    x_mono = x_face + x_right_eye
                    y_mono = y_face + y_right_eye
                    img = img.blit(cur_mono, pos=(x_mono, y_mono), alphaMask=mono_mask)

                img = img.blit(cur_stache, pos=(x_must, y_must), alphaMask=stache_mask)

                if debug:
                    noselayer = DrawingLayer((img.width, img.height))
                    nosebox_dimensions = (nose.width(), nose.height())
                    center_point = (face.x - (face.width() / 2) + nose.x,
                                    face.y - (face.height() / 2) + nose.y)
                    nosebox = noselayer.centeredRectangle(center_point, nosebox_dimensions, width=3)
                    img.addDrawingLayer(noselayer)
                    img = img.applyLayers()

            else:
                print "Face culled:"
                if not nose:
                    print "  No Nose"
                if not mouth:
                    print "  No mouth"
                if not right_eye:
                    print "  No right eye"
                    print

            if debug:
                face_left_edge = face.x - (face.width() / 2)
                face_top_edge = face.y - (face.height() / 2)

                facelayer = DrawingLayer((img.width, img.height))
                facebox_dimensions = (face.width(), face.height())
                center_point = (face.x, face.y)
                facebox = facelayer.centeredRectangle(center_point, facebox_dimensions, Color.BLUE)
                img.addDrawingLayer(facelayer)

                if noses:
                    for nose in noses:
                        noselayer = DrawingLayer((img.width, img.height))
                        nosebox_dimensions = (nose.width(), nose.height())
                        center_point = (face.x - (face.width() / 2) + nose.x,
                                    face.y - (face.height() / 2) + nose.y)
                        nosebox = noselayer.centeredRectangle(center_point, nosebox_dimensions)
                        img.addDrawingLayer(noselayer)

                if mouths:
开发者ID:chadnickbok,项目名称:fancify,代码行数:70,代码来源:fancify.py


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