Esempio n. 1
0
def create_my_pokemon():
    data = request.get_json()
    rec = Box(pid=data["pid"], name=data["name"], id=current_identity.id)
    db.session.add(rec)
    db.session.commit()
    return data[
        "name"] + " captured", 201  # return data and set the status code
Esempio n. 2
0
 def __mkbox__(self):
     ''' Creates a box in the database '''
     corp = Corporation.by_uuid(self.get_argument('corporation_uuid'))
     level = GameLevel.by_number(int(self.get_argument('game_level')))
     box = Box(
         name=unicode(self.get_argument('box_name')),
         description=unicode(self.get_argument('description')),
         difficulty=unicode(self.get_argument('difficulty')),
         corporation_id=corp.id,
         game_level_id=level.id,
     )
     dbsession.add(box)
     dbsession.flush()
Esempio n. 3
0
def create_box(name, corporation, difficulty, game_level, description,
                ipv4_addresses=[], ipv6_addresses=[]):
    print(INFO + "Create Box: " + bold + name + W)
    box = Box(
        name=unicode(name),
        corporation_id=corporation.id,
        difficulty=unicode(difficulty),
        game_level_id=game_level.id,
        description=unicode(description),
    )
    dbsession.add(box)
    dbsession.flush()
    for ip_address in ipv4_addresses:
        __mkipv4__(box, ip_address)
    for ip_address in ipv6_addresses:
        __mkipv6__(box, ip_address)
    return box
Esempio n. 4
0
def dict_to_db(data_dict, title, index_to_id):
    """Enters the data into the MongoDB.
    Args:
    * data_dict: dict containing annotations for 1 video.
        {
            'url': <url>,
            'tracks': [
                {'faces':[
                    {'time': 0.0, 'box': [1, 2, 3, 4]},
                    {'time': 1.0, 'box': [2, 3, 4, 5]},
                    ...
                 ],
                 'annotation': 'Georges Clooney'
                 }
            ]
        }
    * title : string, title of the movie
    * index_to_id: dict maps from index in the timecode.txt to entity ID
    """
    tracks = []
    for track in data_dict['tracks']:
        ent_id = index_to_id[int(track['annotation'])]
        boxes = []
        for box in sorted(track['faces'], key=lambda x: x['time']):
            boxes.append(
                Box(timestamp=box['time'],
                    x=box['box'][0],
                    y=box['box'][1],
                    w=box['box'][2],
                    h=box['box'][3]))
        tracks.append(
            Track(start=boxes[0].timestamp,
                  end=boxes[-1].timestamp,
                  boxes=boxes,
                  entity=ent_id))

    # Create the video
    vid = Video(title=title, tracks=tracks)
    vid.save()
    # Get the hash of the URL (minus the protocol)
    url = data_dict['url'].split('https://www.')[1]
    hasher = hashlib.md5()
    hasher.update(url)
    hash_md5 = hasher.hexdigest()
    SourceVideo(source_url=url, hash=hash_md5, reminiz_video=vid.id).save()
Esempio n. 5
0
def convert_to_db(paths, job, label):
    paths = clean_paths(paths)
    paths_db = []
    for path in paths:
        path_db = Path(job=job, label=label)
        for box in path:
            box_db = Box(path=path_db)
            box_db.xtl = box['rect'][0]
            box_db.ytl = box['rect'][1]
            box_db.xbr = box['rect'][0] + box['rect'][2]
            box_db.ybr = box['rect'][1] + box['rect'][3]
            box_db.frame = box['frame']
            box_db.outside = 0 if box['visible'] else 1
            box_db.occluded = 0
            path_db.boxes.append(box_db)

        paths_db.append(path_db)
    return paths_db
Esempio n. 6
0
def main():
    width = 900
    height = 700

    pygame.init()
    screen = pygame.display.set_mode((width, height))
    color = (0.40, 0.40, 0 / 40)
    box1 = Box(100, 10, 200, 80, 90, 2)
    box2 = Box(-100, 10, 200, 85, 90, 2)
    box3 = Box(100, 10, 300, 100, 100, 2)
    box4 = Box(-100, 10, 300, 100, 130, 2)
    rect = Rectangle(0, 100, 80, 300, 3)

    roll = 0
    pitch = 0
    yaw = 0
    x_offset = 0
    y_offset = 0
    z_offset = 0
    fov = 80
    epsilon = 0.005
    keys = {}
    vp = viewport(0, 0, 0.1, 100, width, height)
    while True:
        screen.fill((255, 255, 255))
        # controls
        event = pygame.event.poll()
        if event.type == KEYDOWN:
            keys[event.key] = True
        elif event.type == KEYUP:
            keys[event.key] = False
        if keys.get(K_a, False):
            x_offset -= STEP
        if keys.get(K_d, False):
            x_offset += STEP
        if keys.get(K_u, False):
            y_offset += STEP
        if keys.get(K_j, False):
            y_offset -= STEP
        if keys.get(K_s, False):
            z_offset -= STEP
        if keys.get(K_w, False):
            z_offset += STEP
        if keys.get(K_LEFT, False):
            yaw += STEP
        if keys.get(K_RIGHT, False):
            yaw -= STEP
        if keys.get(K_z, False):
            roll -= STEP
        if keys.get(K_x, False):
            roll += STEP
        if keys.get(K_UP, False) and keys.get(K_LCTRL, False):
            fov -= STEP
        elif keys.get(K_UP, False):
            pitch += STEP
        if keys.get(K_DOWN, False) and keys.get(K_LCTRL, False):
            fov += STEP
        elif keys.get(K_DOWN, False):
            pitch -= STEP
        text = set_up_text(fov, pitch, yaw, roll, x_offset, y_offset, z_offset)

        projection = perspective_projection(fov, 0.1, 100, width, height)
        t = translation(-x_offset, -y_offset, -z_offset)
        mat = t.dot(rotation(-pitch, -yaw, -roll))
        mat = mat.dot(projection)
        mat = mat.dot(vp)

        transformed_triangles = []
        for box in (box1, box2, box3, box4, rect):
            transformed_points = [point.dot(mat) for point in box.POINTS]
            for triangle in box.TRIANGLES:
                p0 = transformed_points[triangle[0]]
                p1 = transformed_points[triangle[1]]
                p2 = transformed_points[triangle[2]]

                if p0[3] < epsilon or p1[3] < epsilon or p2[3] < epsilon:
                    continue

                p0 = p0 / p0[3]
                p1 = p1 / p1[3]
                p2 = p2 / p2[3]

                transformed_triangles.append((p0, p1, p2))

        for p0, p1, p2 in sorted(transformed_triangles,
                                 key=get_z,
                                 reverse=True):
            # drawing
            pygame.draw.polygon(screen, 0xabcaf4, [p0[:2], p1[:2], p2[:2]])
            pygame.draw.aalines(screen, (0, 0, 0), True,
                                [p0[:2], p1[:2], p2[:2]], 1)
            # screen.blit(text, (420 - text.get_width() // 2, 10 - text.get_height() // 2))

        # exit
        if event.type == QUIT or (event.type == KEYDOWN
                                  and event.key == K_ESCAPE):
            pygame.quit()
            sys.exit()
        pygame.display.flip()
Esempio n. 7
0
def tovaticbox(path, box):
    newbox = Box()
    newbox.frombox(box)
    return newbox
Esempio n. 8
0
            if re.match("^\d+$", old_card.box):
                collection = numbered_boxes
            else:
                collection = other_boxes
            box_name = old_card.box

        #get or create the box

        if box_name not in boxes[collection]:
            collection_index = 0
            if collection == numbered_boxes:
                collection_index = int(box_name)
            else:
                collection_index = len(boxes[collection])
            boxes[collection][box_name] = Box(
                    name = box_name,
                    collection = collection,
                    collection_index = collection_index)
        box = boxes[collection][box_name]

        #create the new card & image.
        #for now, use set_name/card_name/card_name_downcased as the card_id
        #this should be similar to mtgjson's UID.

        #fill out any notes we might care about
        things_of_interest = []
        if old_card.language != 'english' and old_card.language is not None:
            things_of_interest.append(old_card.language)
        if old_card.is_foil:
            things_of_interest.append("foil")
        if old_card.condition is not None and old_card.condition != '' and old_card.condition != 'near_mint':
            things_of_interest.append("condition "+old_card.condition)
Esempio n. 9
0
def create_box():
    return Box(splits=[
        Split(id="nest", description='I am stuck in here', name="Nest Uno"),
        Split(id="nest2", description="Its dark in here", name="Nest Dos")
    ])