def get_frame(): recordings = Recordings(connection) frames = Frames(connection) cursor = recordings.all() recording = Recording(cursor) cursor = frames.query(recordingid=recording.id, index=0) return Frame(cursor)
def test_query(self): connection = get_connection() recordings = (973, 972) point = (5.7058276, 50.8510157) # EPSG:4326 (lon, lat) distance = 2 # in meters frames = Frames(connection) cursor = frames.query(within=(point, distance), recordingid=recordings, limit=1) self.assertIsNotNone(cursor) frame = Frame(cursor) timestamp = datetime.datetime(2016, 5, 11, 8, 6, 24, 90000) self.assertEqual(frame.id, 727692) self.assertEqual(frame.recordingid, 972) self.assertEqual(frame.guid, "c5a3c5f5-b760-44f7-875a-fddaa268d710") self.assertEqual(frame.uuid, "c5a3c5f5-b760-44f7-875a-fddaa268d710") self.assertEqual(frame.latitude, 50.8510157) self.assertEqual(frame.longitude, 5.7058276) self.assertEqual(frame.altitude, 95.029) self.assertEqual(frame.roll, -0.1474) self.assertEqual(frame.pitch, 1.1014) self.assertEqual(frame.azimuth, 162.0647) self.assertEqual(frame.heading, 162.0647) self.assertEqual(frame.timestamp, timestamp) self.assertEqual(frame.stamp, timestamp) self.assertEqual(frame.index, 271) self.assertEqual(frame.distance, 0.0)
def test_query_recordingid(self): connection = get_connection() recordings = 972 point = (5.7058276, 50.8510157) # EPSG:4326 (lon, lat) distance = 2 # in meters frames = Frames(connection) cursor = frames.query(within=(point, distance), recordingid=recordings, limit=3, offset=1) self.assertIsNotNone(cursor) frame = Frame(cursor) timestamp = datetime.datetime(2016, 5, 11, 8, 6, 24, 90000) self.assertEqual(frame.id, 727953) self.assertEqual(frame.recordingid, 972) self.assertEqual(frame.uuid, "9089f29d-9437-4a3c-bd88-ed9e27445289")
from horus_db import Frames, Frame # This example shows how to geo-query frames def get_connection(): return psycopg2.connect( "dbname=HorusWebMoviePlayer user=postgres password=horusweb") connection = get_connection() frames = Frames(connection) # Get a frame frame = Frame(frames.query()) if frame is None: print("No recordings!") exit() # Get frames within a certain distance of this frame point = (frame.longitude, frame.latitude) # EPSG:4326 (lon, lat) distance = 20 # in meters cursor = frames.query(within=(point, distance)) frame = Frame(cursor) while frame is not None: print(" ", frame.uuid, " ", frame.longitude, " ", frame.latitude) frame = Frame(cursor)
# This example shows how to request a spherical image def get_connection(): return psycopg2.connect( "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
grid = Grid() image_provider = ImageProvider(grid) def compute_angle(frame, sign_location): camera_model = CameraModel(frame.get_location(), frame.heading) return -camera_model.look_at_angle(sign_location) for location in args.target: print(f"Looking for {location}") results = [] cursor = frames.query(within=(location, distance), recordingid=recording_id, limit=1) frame = Frame(cursor) if not frame: logging.warning( f"Location {location} not found within {distance} meters") continue if recording_id: assert frame.recordingid in recording_id angle = compute_angle(frame, location) attempts = args.attempts while True: if (clipping_interval[0] <= angle <= clipping_interval[1]): requestBuilder = ImageRequestBuilder(frame.recordingid, frame.uuid) filename = None
recordings = Recordings(connection) # Select the demo city of Rotterdam recording = next(Recording.query( recordings, directory_like="Rotterdam360\\\\Ladybug5plus")) recordings.get_setup(recording) print(recording, " -> ", recording.directory) print(recording.setup) # Step 1. create and configure spherical camera sp_camera = SphericalCamera() sp_camera.set_network_client(client) # Step 2. Get a recorded frame and place the camera onto that 'frame' frames = Frames(connection) results = Frame.query(frames, recordingid=recording.id, index=210, order_by="index",) # step 3. do some sight seeing.. # This sections hardcodes looking at points of interest, which # normally would come from image processing or AI tooling. class Poi(): """Describes and labels a point of interest within the image """ pixel: Pixel name: str yaw: float pitch: float def __init__(self, pixel, name, yaw, pitch) -> None: self.name = name
def get_next_frame(frame): frames = Frames(connection) cursor = frames.query(recordingid=frame.recordingid, index=frame.index + 1) return Frame(cursor)
"Azimuth", "Latitude", "Longitude", "Pitch", "Roll", "Stamp" ] # Open output csv file with open(os.path.join(output_path, 'output.csv'), 'w', newline='') as csvfile: writer = csv.writer(csvfile, quoting=csv.QUOTE_MINIMAL) writer.writerow(csv_header) # 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() print(frame) # Get the image # Set parameters request_builder = ImageRequestBuilder(frame.recordingid, frame.uuid) for direction_id, direction in directions.items(): request = client.fetch(request_builder.build_spherical( size, direction, horizontal_fov))
# This example shows how to request a georeferenced orthographic image (geotiff) def get_connection(): return psycopg2.connect( "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() # 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
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() print(frame) # Get the image # Set parameters request_builder = ImageRequestBuilder(frame.recordingid, frame.uuid)