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 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_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")
# Copyright(C) 2020 Horus View and Explore B.V. import psycopg2 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)
import psycopg2 from horus_db import Frames, Frame from horus_media import Client, ImageRequestBuilder, ImageProvider, Size, Direction # 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
("password", args.db_password), ] try: connection_string = " ".join( map("=".join, filter(lambda x: x[1] != None, db_params))) connection = psycopg2.connect(connection_string) except psycopg2.OperationalError as exception: logging.error(f"{exception} Connecting to database") exit() try: client = Client(args.server) except OSError as exception: logging.error(f"{exception}. Connecting to server {args.server}") exit() frames = Frames(connection) 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)
client = util.get_client(args) 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 get_next_frame(frame): frames = Frames(connection) cursor = frames.query(recordingid=frame.recordingid, index=frame.index + 1) return Frame(cursor)
import psycopg2 from horus_db import Frames, Frame from horus_media import Client, ImageRequestBuilder, ImageProvider, Mode, Size, Geometry # 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:
# Copyright(C) 2020 Horus View and Explore B.V. import psycopg2 from horus_db import Frames, Recordings, Frame, Recording # This example shows how to iterate over all the frames in a recording def get_connection(): return psycopg2.connect( "dbname=HorusWebMoviePlayer user=postgres password=horusweb") connection = get_connection() recordings = Recordings(connection) frames = Frames(connection) cursor = recordings.all() # Get the first recording recording = Recording(cursor) print(" ", recording.id, " ", recording.directory) if recording is None: print("No recordings!") exit() # Get all frames of a recording cursor = frames.query(recordingid=recording.id) frame = Frame(cursor)