本文整理汇总了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)
示例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
示例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()