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


Python Image.flipHorizontal方法代码示例

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


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

示例1: Fish

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import flipHorizontal [as 别名]
class Fish():
    def __init__(self, image_url, mask_url):
        self.position = (10, 10)
        self.last_position = (0, 0)
        self.draw_position = (0, 0)
        self.direction = "left"
        self.orig_image = Image(image_url)
        self.orig_mask = Image(mask_url).invert()
        self.draw_image = self.orig_image.copy()
        self.draw_mask = self.orig_mask.copy()

    def update(self, x, y, w, h):
        self.update_dir()

        self.position = (x, y)

        self.draw_image = self.orig_image.resize(w=w, h=h)
        self.draw_mask = self.orig_mask.resize(w=w, h=h)
 
        if self.direction == "left":
            self.draw_position = self.position
        
        elif self.direction == "right":
            # TODO: setup offsets here for image when facing another direction
            self.draw_position = (self.position[0] + 0, self.position[1] + 0)
            pass

    def update_dir(self):
        hor_change = self.position[0] - self.last_position[0]
        # if the difference is more than 10 pixels
        if abs(hor_change) > 5:
            # TODO: can optimise this slightly by checking if == left && horchange is positive
            # (so doesnt flip it every time over 10 pixels in the same direction)
            if self.direction == "left":
                self.direction = "right"
                self.draw_image = self.orig_image.flipHorizontal().copy()
                self.draw_mask = self.orig_mask.flipHorizontal().copy()
            elif self.direction == "right":
                self.direction = "left"
                self.draw_image = self.orig_image.copy()
                self.draw_mask = self.orig_mask.copy()
            self.last_position = self.position

    def draw(self, parent):
        #self.draw_image.save(canvas)
        print self.draw_image
        print self.draw_position
        parent.canvas = parent.canvas.blit(self.draw_image, pos=self.draw_position, alphaMask=self.draw_mask)
开发者ID:mcteo,项目名称:interactive-fish-tank,代码行数:50,代码来源:fish_tank.py

示例2: Image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import flipHorizontal [as 别名]
from SimpleCV import Image
import time
img = Image('ladies.jpg')
# Flip the image along the horizontal axis, and then display the results
flip = img.flipHorizontal()
flip.show()
time.sleep(10)
开发者ID:popsonebz,项目名称:lesson1,代码行数:9,代码来源:helloWorld24.py


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