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


Python Image.createAlphaMask方法代码示例

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


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

示例1: Camera

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import createAlphaMask [as 别名]
#!/usr/bin/python 

import time, webbrowser
from operator import add
from SimpleCV import Color, ColorCurve, Camera, Image, pg, np, cv
from SimpleCV.Display import Display

cam = Camera(0)
time.sleep(.1) # uhg
display = Display((800,600))
counter = 0
# load the cascades
face_cascade = cv.Load("./../Features/HaarCascades/face.xml")
nose_cascade = cv.Load("./../Features/HaarCascades/nose.xml")
stache = Image("./stache.png") # load the stache
mask = stache.createAlphaMask() # load the stache mask
count = 0
while( display.isNotDone() ):
    #count = count + 1
    img = cam.getImage()
    img = img.scale(.5) #use a smaller image
    faces = img.findHaarFeatures(face_cascade) #find faces
    if( faces is not None ): # if we have a face
        faces = faces.sortArea() #get the biggest one
        face = faces[-1]
        myFace = face.crop() # get the face image
        noses = myFace.findHaarFeatures(nose_cascade) #find the nose
        if( noses is not None ):# if we have a nose
            noses = noses.sortArea()
            nose = noses[0] # get the biggest
            # these get the upper left corner of the face/nose
开发者ID:Aravindlivewire,项目名称:SimpleCV,代码行数:33,代码来源:mustachinator.py

示例2: Display

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import createAlphaMask [as 别名]
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 16 13:56:40 2014

@author: Kelly
"""

from SimpleCV import Camera, Display, Image

cam=Camera(0)
disp= Display(cam.getImage().size())

stache=Image("mustache.jpg")
mask=stache.createAlphaMask()

while disp.isNotDone():
    img=cam.getImage()
    
    faces=img.findHaarFeatures('face')
    if (faces is not None):
        face=faces.sortArea()[-1]
        myface=face.crop()
        
        noses=myface.findHaarFeatures('nose')
        if (noses is not None ):
            nose=noses.sortArea()[-1]
            
            xmust=face.points[0][0]+nose.x+ (stache.width/2)
            ymust= face.points[0][1]+nose.y+(2*nose.height()/3)
            img=img.blit(stache,pos=(xmust,ymust), mask=mask)
        img.save(disp)
开发者ID:knealon,项目名称:Siena_College_Kelly_Nealon,代码行数:33,代码来源:Mustacheinator.py


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