本文整理汇总了Python中Camera类的典型用法代码示例。如果您正苦于以下问题:Python Camera类的具体用法?Python Camera怎么用?Python Camera使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Camera类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reProjectResidualwithX
def reProjectResidualwithX(nx, *args):
shp = args[0]
Xp_1 = args[1]
Xp_2 = args[2]
k = args[3]
R = args[4]
t = args[5]
stackedx = nx[0:shp[0]*shp[1]]
#x = nx[shp[0]*shp[1]:shp[0]*shp[1]+6]
Str_4D = stackedx.reshape(shp)
#R = cv2.Rodrigues(x[0:3])
#t = np.array(x[3:6]).reshape(3,1)
myC1 = Camera.myCamera(k)
myC2 = Camera.myCamera(k)
myC1.projectiveMatrix(np.mat([0,0,0]).transpose(),[0, 0, 0])
myC2.projectiveMatrix(np.mat(t),R[0])
rXp_1 = np.mat(myC1.project(Str_4D))
rXp_2 = np.mat(myC2.project(Str_4D))
res_1 = Xp_1 - rXp_1
res_2 = Xp_2 - rXp_2
Res = np.hstack((res_1,res_2)).reshape(-1)
nRes = 2*np.sqrt(np.sum(np.power(Res,2))/len(Res))
return nRes
示例2: reProjectResidual
def reProjectResidual(x, *args):
Str_4D = args[0]
Xp_1 = args[1]
Xp_2 = args[2]
k = args[3]
R = cv2.Rodrigues(x[0:3])
t = np.array(x[3:6]).reshape(3,1)
myC1 = Camera.myCamera(k)
myC2 = Camera.myCamera(k)
myC1.projectiveMatrix(np.mat([0,0,0]).transpose(),[0, 0, 0])
myC2.projectiveMatrix(np.mat(t),R[0])
rXp_1 = np.mat(myC1.project(Str_4D))
rXp_2 = np.mat(myC2.project(Str_4D))
res_1 = Xp_1 - rXp_1
res_2 = Xp_2 - rXp_2
Res = np.hstack((res_1,res_2)).reshape(-1)
nRes = 2*np.sqrt(np.sum(np.power(Res,2))/len(Res))
return nRes
示例3: process_inputs
def process_inputs():
"""Manages the events and keyboard in the game, sending info to entities.
"""
# Managing events
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
for entity in Entity.collection:
entity.process_event(event)
Camera.process_event(event)
Editor.process_event(event)
# Managing keyboard and mouse.
keys_pressed = pygame.key.get_pressed()
for entity in Entity.collection:
entity.process_inputs(keys_pressed)
Camera.process_inputs(keys_pressed)
Editor.process_inputs(keys_pressed)
示例4: update
def update(screen):
"""Updates the game state one step.
"""
for entity in Entity.collection:
entity.update()
Camera.update()
Editor.update(screen.get_size())
示例5: handle_IMAGE
def handle_IMAGE(self, _args):
"""
:param _args:
:return: :raise TwistedPiException:
"""
log.msg('handle_image', logLevel=logging.DEBUG)
def imageSuccess(_image):
assert _image is not None, "Image is None"
log.msg('Image Size: {0} bytes'.format(_image.tell())
,logLevel = logging.DEBUG)
_image.seek(0)
return threads.deferToThread(EncodeData, _image.read())
def imageError(_err):
log.err(_err)
raise TwistedPiException("Error capturing Image",
ErrorCodes.SERVER_ERROR)
_args = Camera.validate_image_args(_args)
d = threads.deferToThread(Camera.take_image, _args)
d.addCallbacks(imageSuccess, imageError)
return d
示例6: run
def run(self):
self.map.run()
self.enemy_list = []
# Make the enemy objects and add every enemy to the enemy_list.
# Every enemy takes a x and y coordinate as argument.
# (Spawn point)
# And the range it can walk on the x axis.
# The fish takes a third argument.
# You got two choices: 'Water' or 'Lava'.
# According to the fish you want.
self.enemy_list.append(Fish(580, 600, 110, 'Lava'))
self.enemy_list.append(Fish(2570, 600, 400, 'Lava'))
self.enemy_list.append(Slime(1736, 10))
# Add a collider for the enemies and the player.
# It takes the player, map group(tiles),
# an array with all the enemy objects, Reference to
# LevelStateManager
# as arguments.
self.collider = Collider(self.player, self.map.get_group(),
self.enemy_list, self.LevelStateManager)
# Create a camera for this level.
self.camera = Camera(self.shift_start, self.shift_end,
self.map, self.player, self.enemy_list)
# Create a timer for this level.
self.timer = Timer()
# Load the best time of level 2.
self.timer.load_best_time(2)
示例7: main
def main():
args = getArguments()
camera = None
if args.videofile:
camera = Camera.VideoCamera(args.videofile)
else:
camera = Camera.getCamera()
drone = Tracking.Drone()
cv2.namedWindow('frame')
def run():
while True:
frames = camera.getFrames()
if frames is None:
return
frame = cv2.resize(frames['color'], (0,0), fx=0.5, fy=0.5)
cv2.imshow('frame', frame)
key = cv2.waitKey(1)
if key == ord('q'):
break
del frame
gc.collect()
try:
run()
except Exception as e:
print e
finally:
camera.stop()
示例8: start
def start(self):
self.clock = pygame.time.Clock()
self.keep_going = 1
self.camera = Camera(screen, self.world_rect, self.player)
self.blank_scr("OMFG A WALL\nOF LAVA!\nRUN AWAY!")
while self.keep_going:
self.clock.tick(FRAME_RATE)
for event in pygame.event.get():
if event.type == QUIT:
exit()
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
self.keep_going = 0
"""if event.key == K_z: # jump # handled in player class now
if not self.player.states.jumping in self.player.state_lst and not self.player.states.falling in self.player.state_lst:
self.player.state_lst.append(self.player.states.jumping)"""
if event.key == K_x: # attack
if not self.player.states.attacking in self.player.state_lst:
self.player.state_lst.append(self.player.states.attacking)
sounds['fire'].play()
if event.key == K_f:
print "FPS:", self.clock.get_fps()
if event.key == K_p:
self.blank_scr('PAUSED')
self.screen.fill(self.bg_col, (0, CEIL_Y, SCR_SIZE[0], SCR_SIZE[1] - 2*CEIL_Y))
self.camera.update()
self.camera.update_grps(*self.all)
self.check_some_collisions()
self.camera.draw_grps(*self.all)
if self.keep_going:
pygame.display.flip()
sounds['lava'].stop()
示例9: __init__
def __init__( self, world_name="" ):
self._world = World()
segment = self._world.levels[ "2" ].segments[ "2.1" ]
segment_dims = segment.get_pixel_dims()
self._tilemap = segment.get_tiles()
self._entities = []
# TODO: Update this logic to more elegantly designate the entity that
# will be followed by the camera.
player_entity = None
for ( (idx_x, idx_y), entity_class ) in segment.get_entities():
entity_pos = ( TILE_DIMS[0] * idx_x, TILE_DIMS[1] * idx_y )
entity_delta = PhysicalState( CompositeHitbox(entity_pos[0], entity_pos[1]) )
entity = Entity( entity_class, entity_delta )
if entity_class == "player":
player_entity = entity
self._entities.append( entity )
self._camera = Camera( target=player_entity.get_hitbox().get_hitbox(),
new_border=PG.Rect(0, 0, segment_dims[0], segment_dims[1]) )
self._collision_detector = SpatialDictionary( segment_dims[0] / 16,
segment_dims[0], segment_dims[1] )
self._setup_collision_detector()
示例10: __init__
def __init__(self, WINDOW_SIZE):
self.WINDOW_SIZE = Vector2(1366, 768)
self.isGameOver = False
self.playWithRFID = True
self.folderDir = os.path.split(os.getcwd())[0]
self.assetDir = self.folderDir + '/Assets/'
self.inputManager = InputManager()
if self.playWithRFID:
self.myRFIDReader = RFIDReader()
self.inputManager.setRFIDInput(self.myRFIDReader)
pygame.init()
self.clock = pygame.time.Clock()
self.display = pygame.display.set_mode((self.WINDOW_SIZE.getX(), self.WINDOW_SIZE.getY()), pygame.FULLSCREEN)
pygame.display.set_caption('What A Block')
self.loadAssets()
self.cam = Camera(offSet = Vector2(self.WINDOW_SIZE.getX()/2 , self.WINDOW_SIZE.getY()/2 - self.player.getHeight()/2), camSize = self.WINDOW_SIZE)
self.player_revealver = Revealer(IsoToScreen(self.player.getIsoPos(), self.mapCollection.getBlockSize().getX(), self.mapCollection.getBlockSize().getY()), 60)
pygame.mixer.music.play(-1)
示例11: __init__
def __init__(self, music, host):
super(GameScene, self).__init__()
self.background = Surface((WINDOW_WIGTH, WINDOW_HEIGHT))
self.background.fill(Color(BACKGROUND_COLOR))
timer = pygame.time.Clock()
self.music = music
self.enemy = []
self.net=Net()
self.net.subscribe(self.sync)
self.host = host
mouse.set_pos([200, 300])
self.heroes = []
self.up = self.down = self.left = self.right = False
self.entitles_walls = pygame.sprite.Group()
self.entitles = pygame.sprite.Group()
self.addHero(Player(300, 55, 1))
self.walls = []
#map:
self.map = open("maps/testmap.txt", "r")
self.x = 0
self.y = 0
self.lenx = 0
self.leny = 0
for self.row in self.map:
for self.col in self.row:
if self.col == "-":
self.wall = wall(self.x, self.y)
self.entitles_walls.add(self.wall)
self.walls.append(self.wall)
if self.col == " ":
self.floor = floor1(self.x, self.y)
self.entitles_walls.add(self.floor)
self.x = self.x + BLOCK_X
self.y = self.y + BLOCK_Y
self.lenx = self.x / BLOCK_X
self.leny += 1
self.x = 0
for i in self.heroes:
self.entitles.add(i)
total_level_width = self.lenx*WINDOW_WIGTH
total_level_height = self.leny*WINDOW_HEIGHT
self.camera = Camera(camera_configure, total_level_width, total_level_height)
self.enemy = []
if self.host:
self.enemy = [Enemy(100, 100, 1), Enemy(200, 200, 2), Enemy(100, 500, 3)]
for i in self.enemy:
self.entitles.add(i)
self.bul = []
self.bul.append(Bullet(0,0))
if self.music == True:
pygame.mixer.music.load("music/Game.mp3")
pygame.mixer.music.play(-1)
示例12: __init__
def __init__(self, size, player, viewport):
self.size = size
self.center = size*.5
self.player = player
self.terrain\
= [[Terrain.Grass if y%2 is 0 else Pixel.Black for y in range(size.y)] for x in range(size.x)]
self.entities = [player]
self.camera = Camera(self.player.pos, viewport, self.center)
示例13: __init__
class Controller:
def __init__(self,model):
#instance of DataModel
self.__model = model
print "initController"
self.bootSystem()
#使用インスタンスを作成
#Viewを先に構築するため__init__と分離
#各インスタンスの作成
#cameraControl
def bootSystem(self):
#opencv,カメラの設定
self.__camera = Camera()
def getCameraPict(self):
print "next"
cameraPil = self.__camera.getPicturePILImage()
return cameraPil
def getCameraCVPict(self):
self.__cameraPict = self.__camera.getPicture()
#水平取得
#単位はdegree
def getHorizon(self):
try:
self.getCameraCVPict()
self.convertGray()
horizon = Horizon(self.__grayCameraPict)
horizon.detectHorizon()
degree = horizon.getHorizon()
print "degree:"+str(degree)
return degree
except:
sys.exit(sys.exc_info()[:2])
#画像変換
def convertGray(self):
cv.Smooth(self.__cameraPict,self.__cameraPict,cv.CV_GAUSSIAN,13,0,0,0)
grayCameraImage = cv.CreateImage((self.__cameraPict.width,self.__cameraPict.height),cv.IPL_DEPTH_8U,1)
cv.CvtColor(self.__cameraPict,grayCameraImage,cv.CV_BGR2GRAY)
cv.EqualizeHist(grayCameraImage,grayCameraImage)
self.__grayCameraPict = grayCameraImage
示例14: draw
def draw(self, screen):
if self.graph:
screen_x, screen_y, screen_size = (
Camera.screen_coords_and_size(screen, self.pos)
)
transformed = pygame.transform.rotozoom(
self.graph,
-rad2deg(self.angle),
screen_size)
screen.blit(transformed, (screen_x, screen_y))
示例15: __init__
def __init__(self, screen):
self.deaths = 0
self.screen = screen
self.level = Level('reallevel')
self.spawn()
self.game_area = screen.subsurface((0, 40, screen.get_width(), screen.get_height() - 40))
self.cam = Camera(self.player, self.level.bounds, self.game_area.get_size())
self.hud = screen.subsurface((0, 0, screen.get_width(), 40))
self.deathtext = pygame.font.Font(None, 20)