Exemple #1
0
def main():
    no_of_frames = 3
    no_of_points = 4

    # Example parameters
    size = Size(718, 476)
    direction = Direction(0, 0)
    hor_fov = 112.915016

    # Get a frame, see 'get_frame.py' to get a specific frame
    frame = get_frame()

    if frame is None:
        print("No recordings!")
        exit()

    pos_vecs = []

    # Request image, apply detection and request position vector for detection
    for i in range(no_of_frames):
        # Get the image and apply detection
        request = get_image_request(frame, size, direction, hor_fov)
        box = get_detection(image_provider.fetch(request).image.getvalue())

        # Request position vector for each pixel coordinate
        for pix_coor in box:
            for px in pix_coor:
                pos_vecs.append(get_position_vector(frame, request, px))

        frame = get_next_frame(frame)

    # Triangulate position for each box corner
    positions = []
    for i in range(no_of_points):
        positions.append(
            Geographic.triangulate([
                pos_vecs[i], pos_vecs[i + no_of_points],
                pos_vecs[i + (2 * no_of_points)]
            ]))

    plot_results(pos_vecs, positions)
Exemple #2
0
        "dbname=HorusWebMoviePlayer user=postgres password=horusweb")


connection = get_connection()
frames = Frames(connection)
client = Client()
image_provider = ImageProvider()

# Get a frame
frame = Frame(frames.query())

if frame is None:
    print("No recordings!")
    exit()

# Set parameters
size = Size(1024, 1024)
direction = Direction(yaw=45, pitch=-20)

# Get the image
request_builder = ImageRequestBuilder(frame.recordingid, frame.uuid)
request = client.fetch(request_builder.build_spherical(size, direction))
result = image_provider.fetch(request)

# Save the file
filename = ".\\spherical_{}.jpg".format(frame.id)

with open(filename, 'wb') as f:
    f.write(result.image.getvalue())
    result.image.close()
                    default="localhost",
                    help="database database host address")
parser.add_argument("--db-port",
                    type=int,
                    default=5432,
                    help="database connection port number")

args = parser.parse_args()

temp_path = args.path
recording_id = tuple(args.recording) if args.recording != None else None
distance = args.distance
horizontal_fov = args.fov[0]
vertical_fov = args.fov[1]
mode = args.mode
size = Size(args.size[0], args.size[1])
clipping_interval = tuple(args.clipping)
geometry = Geometry(args.geom_scale, args.geom_width, args.geom_height,
                    args.geom_dist, args.geom_shift, None)

db_params = [
    ("host", args.db_host),
    ("port", str(args.db_port)),
    ("dbname", args.db_name),
    ("user", args.db_user),
    ("password", args.db_password),
]
try:
    connection_string = " ".join(
        map("=".join, filter(lambda x: x[1] != None, db_params)))
    connection = psycopg2.connect(connection_string)
    frame = next(results)
    if frame is None:
        print("No frames!")
        exit()

    print("Got frame:", frame, frame.get_location())
    sp_camera.set_frame(recording, frame)
    print("camera_height", sp_camera.height)

    for poi in foi[1]:

        sp_camera.set_horizontal_fov(90)
        sp_camera.set_yaw(poi.yaw)
        sp_camera.set_pitch(poi.pitch)

        spherical_image = sp_camera.acquire(Size(800, 800))

        with open('frame' + str(frame.index) + '_' + poi.name + '.jpeg', 'wb') as image_file:
            image_file.write(spherical_image.get_image().getvalue())
            spherical_image.get_image().close()

        # Step 5
        # obtain a GeoReferencedPixel
        grp: GeoReferencedPixel = spherical_image.project_pixel_on_ground_surface(
            poi.pixel)
        grp.name = poi.name

        # you can store multiple GeoReferencedPixels with a different label
        spherical_image.store_geo_referenced_pixel(grp)

        list_of_images.append(spherical_image)
def get_position_vector(frame, size, direction, fov):
    request_builder = ComputationRequestBuilder(frame.recordingid, frame.uuid)
    request = client.fetch(request_builder.build(size, direction, fov, 0, 0))
    result = computation_provider.fetch(request)
    return PositionVector(*result.values())


connection = util.get_connection(args)
client = util.get_client(args)

frames = Frames(connection)
image_provider = ImageProvider()
computation_provider = ComputationProvider()

# Output parameters
size = Size(args.size[0], args.size[1])  # defaults to (1024px, 1024px)
horizontal_fov = args.horizontal_fov  # defaults to 90 deg
overlap = args.overlap  # 20deg
recording_id = tuple(args.recording) if args.recording != None else None

displacement = horizontal_fov - overlap

directions = {
    "right": Direction(yaw=displacement, pitch=0),
    "center": Direction(yaw=0, pitch=0),
    "left": Direction(yaw=-displacement, pitch=0),
}

csv_header = [
    "File",
    "Index",
    print("No recordings!")
    exit()

# If available, the altitude of the next frame is used in calculating ground plane
# (optional, required if results should be equal to the Horus MoviePlayer)
cursor = frames.query(recordingid=frame.recordingid, index=frame.index + 1)
next_frame = Frame(cursor)
if next_frame is not None:
    alti_next = next_frame.altitude
else:
    alti_next = None

# Set parameters

# Size of render buffer, should at least be the size of the original camera resolution of the roi
size = Size(4096, 2048)

# The geometry values relative to the frame center, same as used in the Horus MoviePlayer ortho projection
geom_scale = 400  # output scale (px/m)
geom_width = 6  # geometry width (m)
geom_height = 2  # geometry height (m)
geom_dist = 4  # geometry distance (m)
geom_shift = 0  # geometry shift (m)
geometry = Geometry(geom_scale, geom_width, geom_height, geom_dist, geom_shift,
                    alti_next)

# Get the image
request_builder = ImageRequestBuilder(frame.recordingid, frame.uuid)
request = client.fetch(request_builder.build_orthographic(size, geometry))
result = image_provider.fetch(request)
# This example shows how to request orthographic images
output_path = args.path

if output_path is None:
    logging.error(f"Specify an output path using '--path'")
    exit()

connection = util.get_connection(args)
client = util.get_client(args)

frames = Frames(connection)
image_provider = ImageProvider()
computation_provider = ComputationProvider()

# Output parameters
size = Size(args.size[0], args.size[1])  # defaults to (4096px, 2048px)
recording_id = tuple(args.recording) if args.recording != None else None

# Get frames
results = Frame.query(
    frames,
    recordingid=recording_id,
    order_by="index",
)
if args.limit:
    results = itertools.islice(results, args.limit)
for frame in results:
    if frame is None:
        print("No frames!")
        exit()