def __init__(self, *args, **kwargs):
        super(TestClient, self).__init__(*args, **kwargs)

        recording_id = 871
        frame_uuid = "44d25183-cc3e-4c8b-8661-8c286e71b2dc"
        host_url = "http://webplayer.horus.nu/"

        self.grid = Grid()
        self.request_builder = ImageRequestBuilder(recording_id, frame_uuid)
        self.stitcher = ImageProvider()
        self.client = Client(host_url)
示例#2
0
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
request_builder = ImageRequestBuilder(frame.recordingid, frame.uuid)
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)
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:
def get_client(args):
    try:
        return Client(args.server)
    except OSError as exception:
        logging.error(f"{exception}. Connecting to server {args.server}")
        exit()
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)
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:
示例#6
0
import numpy
import cv2
from typing import NamedTuple
from matplotlib import patches as patches, pyplot as pyplot

from horus_db import Recordings, Recording, Frames, Frame
from horus_media import Client, ImageRequestBuilder, ImageProvider, ComputationRequestBuilder, \
                                ComputationProvider, Size, Direction
from horus_gis import PositionVector, Geographic

# This example shows how to use triangulation to get geographic positions
# on boxes drawn by the user on 3 consecutive frames

connection = psycopg2.connect(
    "dbname=HorusWebMoviePlayer user=postgres password=horusweb")
client = Client()
image_provider = ImageProvider()
computation_provider = ComputationProvider()


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()
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:
    alti_next = next_frame.altitude
示例#8
0
import psycopg2

from horus_db import Frames, Frame
from horus_media import Client, ImageRequestBuilder, ImageProvider, Mode, Scales, Direction

# This example shows how to request a panoramic 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
mode = Mode.panoramic
scale = Scales.Px_2048

# Get the image
request_builder = ImageRequestBuilder(frame.recordingid, frame.uuid)
class TestClient(unittest.TestCase):

    def __init__(self, *args, **kwargs):
        super(TestClient, self).__init__(*args, **kwargs)

        recording_id = 871
        frame_uuid = "44d25183-cc3e-4c8b-8661-8c286e71b2dc"
        host_url = "http://webplayer.horus.nu/"

        self.grid = Grid()
        self.request_builder = ImageRequestBuilder(recording_id, frame_uuid)
        self.stitcher = ImageProvider()
        self.client = Client(host_url)

    def request_stitched_sections(self, sections, scale, path=None):
        requests = self.client.fetch_all(
            self.request_builder.build(Mode.panoramic, scale, section) for section in sections)

        result = self.stitcher.combine(requests, scale.size, scale.size)
        if path:
            with open(path, 'wb') as f:
                f.write(result.image.getvalue())
            result.image.close()
        return result

    def test_client_request_pano(self):
        request = self.client.fetch(self.request_builder.build(Mode.panoramic, Scales.Px_1024))
        with open('./tests/data/pano.jpg', "wb") as file:
            file.write(request.result())

    def test_client_request(self):
        sections = self.grid.filter(h_min=-44, h_max=44, w_min=-170, w_max=-1)
        self.request_stitched_sections(
            sections, Scales.Px_1024, './tests/data/stitched.jpg')

    def test_client_request_pano_stitched(self):
        result = self.request_stitched_sections(
            self.grid, Scales.Px_1024, './tests/data/pano_stitched.jpg')
        self.assertEqual(result.to_pixel_coordinates((0, 0)).x, 0)
        self.assertEqual(result.fov, Rect(
            x=-180.0, y=-90.0, width=360.0, height=180.0))


    def test_client_request_single_section_stitched(self):
        result = self.request_stitched_sections(
            (self.grid[3],), Scales.Px_1024, './tests/data/single_section_stitched.jpg')
        self.assertEqual(result.to_pixel_coordinates((170.0, 0)).x, 796)
        self.assertEqual(result.fov, Rect(
            x=-45.0, y=45.0, width=45.0, height=45.0))

    def test_client_request_left_wrapped(self):
        sections = self.grid.filter(h_min=-46, h_max=1, w_min=-270, w_max=-46)
        result = self.request_stitched_sections(
            sections, Scales.Px_1024, './tests/data/stitched_lw.jpg')
        self.assertEqual(result.to_pixel_coordinates((0, 0)).x, 0)

    def test_client_request_right_wrapped(self):
        sections = self.grid.filter(h_min=0, w_min=70, w_max=246)
        result = self.request_stitched_sections(
            sections, Scales.Px_1024, './tests/data/stitched_rw.jpg')
        self.assertEqual(result.to_pixel_coordinates((70.0, 0)).x, 1592)
        self.assertEqual(result.fov, Rect(
            x=-180.0, y=0.0, width=225.0, height=90.0))

    def test_client_request_left_right_wrapped(self):
        sections = self.grid.filter(w_min=-240, w_max=246)
        result = self.request_stitched_sections(
            sections, Scales.Px_1024, './tests/data/stitched_lrw.jpg')
        self.assertEqual(result.to_pixel_coordinates((-240.0, 0)).x, 2730)
        self.assertEqual(result.fov, Rect(
            x=-180.0, y=-90.0, width=180.0, height=180.0))
import psycopg2

from horus_db import Frames, Frame
from horus_media import Client, ImageRequestBuilder, ImageProvider, Mode, Scales, Direction, Grid

# This example shows how to request a panoramic 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
mode = Mode.panoramic
scale = Scales.Px_2048

# Get the image