本文整理汇总了Python中SimpleCV.Image.blit方法的典型用法代码示例。如果您正苦于以下问题:Python Image.blit方法的具体用法?Python Image.blit怎么用?Python Image.blit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleCV.Image
的用法示例。
在下文中一共展示了Image.blit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _join_areas
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import blit [as 别名]
def _join_areas(self, areas):
w, h = self._bgr_frame.size()
frame = Image((w, h), colorSpace = ColorSpace.GRAY)
a1, a2, a3, a4 = areas
frame = frame.blit(a1, pos=(0, 0))
frame = frame.blit(a2, pos=(int(w*self.SPLITS[0]), 0))
frame = frame.blit(a3, pos=(int(w*self.SPLITS[1]), 0))
frame = frame.blit(a4, pos=(int(w*self.SPLITS[2]), 0))
return frame
示例2: if
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import blit [as 别名]
while disp.isNotDone():
ax = fig.gca(projection='3d')
ax.set_xlabel('BLUE', color=(0,0,1) )
ax.set_ylabel('GREEN',color=(0,1,0))
ax.set_zlabel('RED',color=(1,0,0))
# Get the color histogram
img = cam.getImage().scale(0.3)
rgb = img.getNumpyCv2()
hist = cv2.calcHist([rgb],[0,1,2],None,[bins,bins,bins],[0,256,0,256,0,256])
hist = hist/np.max(hist)
# render everything
[ ax.plot([x],[y],[z],'.',markersize=max(hist[x,y,z]*100,6),color=color) for x,y,z,color in idxs if(hist[x][y][z]>0) ]
#[ ax.plot([x],[y],[z],'.',color=color) for x,y,z,color in idxs if(hist[x][y][z]>0) ]
ax.set_xlim3d(0, bins-1)
ax.set_ylim3d(0, bins-1)
ax.set_zlim3d(0, bins-1)
azim = (azim+0.5)%360
ax.view_init(elev=35, azim=azim)
########### convert matplotlib to SimpleCV image
canvas.draw()
renderer = canvas.get_renderer()
raw_data = renderer.tostring_rgb()
size = canvas.get_width_height()
surf = pg.image.fromstring(raw_data, size, "RGB")
figure = Image(surf)
############ All done
figure = figure.floodFill((0,0), tolerance=5,color=Color.WHITE)
result = figure.blit(img, pos=(20,20))
result.save(disp)
fig.clf()
示例3: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import blit [as 别名]
kite_base = Image('http://www.winds-up.com/images/annonces/7915_1.jpg').resize(50, 50).invert()
disp = Display()
i_loop = 0
#pid = PID.PID(1, 1, 0.1)
offset = sp.pi/3*0
kite_model = kiteModel()
dX = 0*kite_model.X
while disp.isNotDone():
setpoint = sp.pi/1.7*sp.sin(2*sp.pi/7*time.time())+offset
i_loop = i_loop +1
order = 0+0*sp.randn(1)/5+2.0*disp.mouseX/background.width-1
#error = X[0] -setpoint
#order = sp.randn(1)/100 + pid.computeCorrection(error, dX[0]/dt-0)
#pid.incrementTime(error, dt)
dt = 0.1
kite_model.update(order, dt)
print kite_model.X
kite = kite_base.rotate(sp.rad2deg(kite_model.X[0]), fixed=False).invert()
#kite.save(disp)d
#background.blit(kite, (799,0)).save(disp)
toDisplay = background.blit(kite.invert(), (max(-kite.width +1, min(background.width-1, int(kite_model.X[1]+background.width/2-kite.width/2))), max(-kite.height+1, min(background.height-1, int(background.height-kite_model.X[2]-200)))), mask = kite.binarize())
toDisplay.drawText(str(i_loop*dt), 0, 0, color = Color.RED, fontsize=60)
toDisplay.save(disp)
time.sleep(dt)
示例4: fancify
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import blit [as 别名]
#.........这里部分代码省略.........
for cur_eye in eyes:
cur_right_dist = (abs(cur_eye.x - (3 * face.width() / 4)) +
abs(cur_eye.y - (nose.y - (nose.height() / 2)) / 2) +
abs(cur_eye.width() - (face.width() / 3)))
if (cur_right_dist <= right_eye_dist): # and (cur_eye.y < nose.y):
right_eye = cur_eye
right_eye_dist = cur_right_dist
if nose and right_eye and (((right_eye.y - (right_eye.height() / 2)) > nose.y) or (right_eye.x < nose.x)):
print "Culling right_eye"
right_eye = None
if nose and mouth:
chosen_faces.append(face_rect)
x_face = face.x - (face.width() / 2)
y_face = face.y - (face.height() / 2)
x_nose = nose.x - (nose.width() / 2)
y_nose = nose.y - (nose.height() / 2)
# Setup TopHat Image
scale_factor = face.width() / 175.0
cur_hat = hat.copy()
cur_hat = cur_hat.scale(scale_factor)
cur_hat_mask = hat_mask.copy()
cur_hat_mask = cur_hat_mask.scale(scale_factor)
cur_hat_mask = cur_hat_mask.createAlphaMask(hue_lb=0, hue_ub=100)
# Calculate the hat position
if (face.y - face.height() / 2) > cur_hat.height:
x_hat = face.x - (cur_hat.width / 2)
y_hat = face.y - (face.height() * 7 / 10) - (cur_hat.height / 2)
img = img.blit(cur_hat, pos=(x_hat, y_hat), alphaMask=cur_hat_mask)
if mouth:
x_mouth = mouth.x - (mouth.width() / 2)
y_mouth = mouth.y - (mouth.height() / 2)
# Setup Mustache Image
cur_stache = stache.copy()
scale_factor = ((nose.width() / 300.0) + (face.width() / 600.0)) / 2.0
cur_stache = cur_stache.scale(scale_factor)
stache_mask = cur_stache.createAlphaMask(hue_lb=0, hue_ub=10).invert()
# Calculate the mustache position
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