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


Python Image.createBinaryMask方法代码示例

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


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

示例1: Camera

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

camera = Camera(prop_set={'width':320, 'height':240})
display = Display(resolution=(320, 240))

mustacheImage = Image("/Users/jharms/Desktop/Mustache.jpg")
mustacheImage = mustacheImage.resize(w=120, h=80)
stacheMask = mustacheImage.createBinaryMask(color1=(10,10,10), color2=(255,255,255))
stacheMask = stacheMask.invert()
#i.save(myDisplay)

def mustachify(frame):
    faces = None
    print frame.listHaarFeatures()
    faces = frame.findHaarFeatures('face')
    if faces:
        for face in faces:
            print "Gesicht bei " + str(face.coordinates())
            frame = frame.blit(mustacheImage, pos=face.coordinates(), mask=stacheMask)
    return frame
    
while not display.isDone():
    frame = camera.getImage()
    frame = mustachify(frame)
    frame.save(display)
    sleep(.1)
开发者ID:tyunkeow,项目名称:raspi_python,代码行数:29,代码来源:camera.py

示例2: Camera

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import createBinaryMask [as 别名]
from time import sleep, time
from SimpleCV import Camera, Image, Display
import RPi.GPIO as GPIO

myCamera = Camera(prop_set={'width':320, 'height': 240})
myDisplay = Display(resolution=(320, 240))
stache = Image("mustache.png")
stacheMask = stache.createBinaryMask(color1=(0,0,0), color2=(254,254,254))
stacheMask = stacheMask.invert()

GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.IN)

def mustachify(frame):
   faces = frame.findHaarFeatures('face')
   if faces:
      for face in faces:
         print "Face at: " + str(face.coordinates())
         myFace = face.crop()
         noses = myFace.findHaarFeatures('nose')
         if noses:
            nose = noses.sortArea()[-1]
            print "Nose at: " + str(nose.coordinates())
            xmust = face.points[0][0] + nose.x - (stache.width/2)
            ymust = face.points[0][1] + nose.y + (stache.height/3)
         else:
            return frame
      frame = frame.blit(stache, pos=(xmust, ymust), mask=stacheMask)
      return frame
   else:
      return frame
开发者ID:Insight-book,项目名称:Getting-Started-With-Raspberry-Pi,代码行数:33,代码来源:photobooth.py

示例3: Image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import createBinaryMask [as 别名]
from SimpleCV import Image,Color
img = Image("lena.jpg")
mask = img.createBinaryMask(color1=(130,125,100),color2=Color.BLACK)
mask = mask.morphClose()
result = img - mask.invert()
result.show()
开发者ID:srinath9,项目名称:simplecv,代码行数:8,代码来源:masking.py


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