Ejemplo n.º 1
0
import json
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import pyplot as plt

from classes import Point, Camera, Wall

START_POINT = Point(0, 0, 0)
W = 5  # x
L = 10  # y
H = 4  # z

room_to_json = {'Walls': {}, 'Cameras': {}}

camera_1 = Camera(Point(2, 0, H), angle_v=49,
                  angle_h=64)  # Направление задано углами
camera_2 = Camera(Point(2, 0, H),
                  Point(2.001, 4, 0))  # Направление задано точкой (вектор)
cameras = [camera_1, camera_2]

# Стены задаются точками по часовой стрелке (если смотреть из комнаты) от нижней левой до нижней правой
wall_front = Wall(
    [Point(W, 0, 0),
     Point(W, 0, H),
     Point(0, 0, H),
     Point(0, 0, 0)])
wall_right = Wall(
    [Point(W, L, 0),
     Point(W, L, H),
     Point(W, 0, H),
     Point(W, 0, 0)])
wall_left = Wall(
Ejemplo n.º 2
0
system = platform.system()
date_fmt = "%Y-%m-%d %H:%M:%S"
logging.basicConfig(format="%(asctime)s: %(message)s",
                    level=logging.INFO,
                    datefmt=date_fmt)

parser = argparse.ArgumentParser()

parser.add_argument("--video", help="enable test a video")
parser.add_argument("--image", help="enable test an image")
parser.add_argument("--no-plc",
                    action="store_true",
                    help="run without PLC connection")
args = parser.parse_args()

camera = Camera()
tank = Tank()
plc = PLC()
model = TFModel()

if args.video:
    path = args.video
    camera.start()
    plc.enabled = False
elif args.image:
    path = args.image
    img = cv.imread(path, -1)
    camera.start()
    plc.enabled = False
else:
    if system == "Windows":
Ejemplo n.º 3
0
 def test(self, angel1, angel2, point_x: float, point_y: float):
     camera_2 = Camera(Point(2, 0, self.H), angle_v=float(angel1),  angle_h=float(angel2))
     if point_x-1 < camera_2.point_to.x < point_x + 1 and point_y-1 < camera_2.point_to.y < point_y+1:
         return True
     return False
Ejemplo n.º 4
0
# Importing libraries
#import cv2
#import serial
from time import sleep
#from PIL import Image
#import os

from classes import Stage, Camera
stage = Stage("/dev/tty.usbserial-1460")
camera = Camera(0)
if __name__ == "__main__":
    stage.scan(xstart=0,
               xend=1,
               step_x=.1,
               ystart=0,
               yend=1,
               step_y=.1,
               camera=camera,
               invert_x=True,
               invert_y=True)

# # The app camera cannot be opened with this camera
# cap = cv2.VideoCapture(0)
# reset_zero()
# step = .5
# n_steps = 5
# for row in range(n_steps):
#     time.sleep(3)
#     move_fwd(step)
#     for col in range(n_steps):
#         move_left(step)
Ejemplo n.º 5
0
from global_variables import *

"	INIT THE PYGAME MODULE	"

pygame.init()

"	INIT THE WINDOW, FULL SCREEN AND PREPARE CLOCK FOR 60 FPS	"

screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("My first program !")
# pygame.display.toggle_fullscreen()
clock = pygame.time.Clock()

"	INIT THE CAMERA (USER's VIEUW) AND SET THE ROTATION		"

camera = Camera((0, 0, -5), (0, 0))

"	MAIN ENGINE		"

cube = Object(cube_verts, cube_edges, cube_faces)
sphere = Sphere(sphere_center, sphere_radius)

while (ON):
	dt = clock.tick(60)/1000
	screen.fill(BLACK)

	key = pygame.key.get_pressed()
	camera.update(0.01, key)
	camera.rot_xy += 1
	camera.rot_xz += 1
Ejemplo n.º 6
0
def main():
    """this function is called when the program starts.
       it initializes everything it needs, then runs in
       a loop until the function returns."""
    #Initialize Everything
    pygame.init()
    screen = pygame.display.set_mode((WIDTH, HEIGHT))
    pygame.display.set_caption('Jungle')
    pygame.mouse.set_visible(0)

    #Create The Backgound
    background = pygame.Surface(screen.get_size())
    background = background.convert()
    background.fill((125, 125, 125))

    #Put Text On The Background, Centered
    if pygame.font:
        font = pygame.font.Font(None, 36)
        text = font.render("Jungle", 1, (10, 10, 10))
        textpos = text.get_rect(centerx=background.get_width() / 2)
        background.blit(text, textpos)

#Display The Background
    screen.blit(background, (0, 0))
    pygame.display.flip()

    #Prepare Game Objects
    clock = pygame.time.Clock()
    # whiff_sound = load_sound('whiff.wav')
    # punch_sound = load_sound('punch.wav')
    data = DataStore()
    world = World(64, 64)
    camera = Camera([0.0, 0.0], WIDTH, HEIGHT, 3)
    buffered_world_sprites = pygame.sprite.LayeredUpdates(
        init_world_tiles(WIDTH * 2, HEIGHT * 2, TILE_SIZE, data))
    displayed_world_sprites = pygame.sprite.LayeredUpdates([])

    f_sprite = Actor([0, 1], data)
    f = Fighter([3, 3], 1, 1)
    allsprites = pygame.sprite.LayeredUpdates([f_sprite])

    #Main Loop
    going = True
    while going:
        clock.tick(60)

        #Handle Input Events
        for event in pygame.event.get():
            if event.type == QUIT:
                going = False
            elif event.type == KEYDOWN and event.key == K_ESCAPE:
                going = False
            elif event.type == MOUSEBUTTONDOWN:
                pass
            elif event.type == MOUSEBUTTONUP:
                pass
            # elif event.type == MOUSEBUTTONDOWN and event.button == 4:

        pressed = pygame.key.get_pressed()
        if pressed[pygame.K_w]:
            camera.rw_pos -= np.array([0, 0.1]) * (10.0 / camera.zoom)
        if pressed[pygame.K_s]:
            camera.rw_pos += np.array([0, 0.1]) * (10.0 / camera.zoom)
        if pressed[pygame.K_a]:
            camera.rw_pos -= np.array([0.1, 0]) * (10.0 / camera.zoom)
        if pressed[pygame.K_d]:
            camera.rw_pos += np.array([0.1, 0]) * (10.0 / camera.zoom)
        if pressed[pygame.K_q]:
            camera.set_zoom(camera.zoom + 0.1)
        if pressed[pygame.K_e]:
            camera.set_zoom(camera.zoom - 0.1)

        # update world camera
        sx, sy = camera.rw_pos
        ex, ey = camera.rw_pos + camera.rw_dim
        buffered_world_sprites.add(displayed_world_sprites.sprites())
        displayed_world_sprites.empty()
        for rw_tile in world.get_flat_slice(sx, ex, sy, ey):
            camera_pos = camera.rw_to_camera(rw_tile[:2])
            sprite = buffered_world_sprites.get_sprite(0)
            sprite.rect.topleft = camera_pos
            sprite.set_tile(rw_tile[2])
            sprite.zoom(camera.zoom)
            buffered_world_sprites.remove(sprite)
            displayed_world_sprites.add(sprite)

        f_sprite.rect.topleft = camera.rw_to_camera(f.pos)
        f_sprite.zoom(camera.zoom)

        #Draw Everything
        screen.blit(background, (0, 0))
        displayed_world_sprites.draw(screen)
        allsprites.draw(screen)
        pygame.display.flip()

    pygame.quit()
Ejemplo n.º 7
0
loading_image = load_image('fon', 'loading', 'jpg')
player_image = pygame.transform.scale(player_image, (100, 100))
tile_width = tile_height = 100
pygame.init()
size = width, height = 1240, 768
fon = pygame.transform.scale(load_image('fon', 'fon', 'jpg'), (width, height))
screen = pygame.display.set_mode(size)
FPS = 25
clock = pygame.time.Clock()
start_screen(screen, fon)
startsc = True
player = None
all_sprites = pygame.sprite.Group()
wall_group = pygame.sprite.Group()
player_group = pygame.sprite.Group()
camera = Camera(width, height)
level = [[]]
marx = None
marx2 = None
mary = None
mario = None
level_name = "1"
image_grass = load_image(level_name, 'grass', 'png')
image_stone = load_image(level_name, 'stone', 'png')
g_right = False
g_left = False
g_up = False
g_down = False
reverse = False
went = False
brothrun = []