Skip to content

Commit b6dc3a8

Browse files
committed
update sizing for video container
1 parent 42b3b27 commit b6dc3a8

3 files changed

Lines changed: 63 additions & 40 deletions

File tree

docker-compose.override.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,25 @@ services:
5252
command: 'serve -a 0.0.0.0:8000 -f ./mkdocs.dev.yml'
5353
ports:
5454
- 8003:8000
55+
56+
57+
client:
58+
image: node:20
59+
working_dir: /app
60+
command: >
61+
sh -c "
62+
npm install &&
63+
# If node_modules is not writable by others, make it so the host can modify and delete them
64+
[ \"\$(stat -c '%A' node_modules | cut -c9)\" != 'w' ] && chmod o+w node_modules;
65+
# Always run the dev server
66+
npm run dev
67+
"
68+
ports:
69+
- "3000:3000"
70+
volumes:
71+
- ./client:/app
72+
env_file:
73+
- ./dev/.env.docker-compose
74+
5575
volumes:
5676
vector-workdir:

scripts/fmv/kwiver-klv.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -102,36 +102,37 @@ def create_geojson_and_bbox(
102102
continue
103103

104104
# Sensor location
105-
sensor_lat = float(frame["Sensor Geodetic Latitude (EPSG:4326)"])
106-
sensor_lon = float(frame["Sensor Geodetic Longitude (EPSG:4326)"])
105+
sensor_lat = float(frame['Sensor Geodetic Latitude (EPSG:4326)'])
106+
sensor_lon = float(frame['Sensor Geodetic Longitude (EPSG:4326)'])
107107

108108
# Frame center and bounding
109-
center_lat = float(frame["Geodetic Frame Center Latitude (EPSG:4326)"])
110-
center_lon = float(frame["Geodetic Frame Center Longitude (EPSG:4326)"])
111-
width = float(frame["Target Width (meters)"])
109+
center_lat = float(frame['Geodetic Frame Center Latitude (EPSG:4326)'])
110+
center_lon = float(frame['Geodetic Frame Center Longitude (EPSG:4326)'])
111+
target_width = float(frame['Target Width (meters)'])
112+
image_width = float(frame['Image Width'])
113+
image_height = float(frame['Image Height'])
112114
platform_heading = float(frame['Platform Heading Angle (degrees)'])
113115
sensor_heading = float(frame['Sensor Relative Azimuth Angle (degrees)'])
114116
heading = platform_heading + sensor_heading
115117
# Build a rectangular footprint centered at the center point, rotated by heading
116-
# Assume the footprint is square for now (or width x width)
117-
half = width / 2
118-
119-
# Define rectangle in heading-relative azimuths (clockwise from north)
120-
rotation_offset = 0 # degrees (CCW)
121-
rotated_heading = (heading + rotation_offset) % 360
122-
123-
angles = [
124-
rotated_heading - 45, # Top-left
125-
rotated_heading + 45, # Top-right
126-
rotated_heading + 135, # Bottom-right
127-
rotated_heading - 135, # Bottom-left
128-
]
118+
# Compute height in meters based on aspect ratio
119+
target_height = (image_height / image_width) * target_width
120+
121+
# Half dimensions
122+
half_width = target_width / 2
123+
half_height = target_height / 2
124+
125+
# Corner offsets (dx, dy) relative to center
126+
corner_offsets = [(-half_width, half_height), (half_width, half_height),
127+
(half_width, -half_height), (-half_width, -half_height)]
128+
129129
corners = []
130-
for az in angles:
131-
lon, lat, _ = geod.fwd(center_lon, center_lat, az % 360, half * (2 ** 0.5))
130+
for dx, dy in corner_offsets:
131+
distance = (dx**2 + dy**2) ** 0.5
132+
angle = (heading + np.degrees(np.arctan2(dx, dy))) % 360
133+
lon, lat, _ = geod.fwd(center_lon, center_lat, angle, distance)
132134
corners.append((lon, lat))
133-
corners.append(corners[0]) # close the polygon
134-
polygon = Polygon(corners)
135+
corners.append(corners[0]) # Close polygon polygon = Polygon(corners)
135136
polygons.append(polygon)
136137
frame_polygons.append((frame_id, polygon))
137138
frame_to_bbox[frame_id] = corners

uvdat/core/tasks/fmv.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pyproj
1212
from shapely.geometry import Point, Polygon, mapping
1313
from shapely.ops import unary_union
14+
import numpy as np
1415

1516
from uvdat.core.models import (
1617
FMVLayer,
@@ -185,30 +186,31 @@ def create_geojson_and_bbox(
185186
# Frame center and bounding
186187
center_lat = float(frame['Geodetic Frame Center Latitude (EPSG:4326)'])
187188
center_lon = float(frame['Geodetic Frame Center Longitude (EPSG:4326)'])
188-
width = float(frame['Target Width (meters)'])
189+
target_width = float(frame['Target Width (meters)'])
190+
image_width = float(frame['Image Width'])
191+
image_height = float(frame['Image Height'])
189192
platform_heading = float(frame['Platform Heading Angle (degrees)'])
190193
sensor_heading = float(frame['Sensor Relative Azimuth Angle (degrees)'])
191194
heading = platform_heading + sensor_heading
192195
# Build a rectangular footprint centered at the center point, rotated by heading
193-
# Assume the footprint is square for now (or width x width)
194-
half = width / 2
195-
196-
# Define rectangle in heading-relative azimuths (clockwise from north)
197-
rotation_offset = 0 # degrees (CCW)
198-
rotated_heading = (heading + rotation_offset) % 360
199-
200-
angles = [
201-
rotated_heading - 45, # Top-left
202-
rotated_heading + 45, # Top-right
203-
rotated_heading + 135, # Bottom-right
204-
rotated_heading - 135, # Bottom-left
205-
]
196+
# Compute height in meters based on aspect ratio
197+
target_height = (image_height / image_width) * target_width
198+
199+
# Half dimensions
200+
half_width = target_width / 2
201+
half_height = target_height / 2
202+
203+
# Corner offsets (dx, dy) relative to center
204+
corner_offsets = [(-half_width, half_height), (half_width, half_height),
205+
(half_width, -half_height), (-half_width, -half_height)]
206+
206207
corners = []
207-
for az in angles:
208-
lon, lat, _ = geod.fwd(center_lon, center_lat, az % 360, half * (2**0.5))
208+
for dx, dy in corner_offsets:
209+
distance = (dx**2 + dy**2) ** 0.5
210+
angle = (heading + np.degrees(np.arctan2(dx, dy))) % 360
211+
lon, lat, _ = geod.fwd(center_lon, center_lat, angle, distance)
209212
corners.append((lon, lat))
210-
corners.append(corners[0]) # close the polygon
211-
213+
corners.append(corners[0]) # Close polygon
212214
polygon = Polygon(corners)
213215
polygons.append(polygon)
214216
frame_polygons.append((frame_id, polygon))

0 commit comments

Comments
 (0)