tracking details tweaks

- fix 4:3 layout
- get and use aspect of record stream if different from detect stream
This commit is contained in:
Josh Hawkins 2026-01-18 07:50:19 -06:00
parent 0a8f499640
commit 3f61ae1b78
2 changed files with 16 additions and 4 deletions

View File

@ -13,7 +13,7 @@ import HlsVideoPlayer from "@/components/player/HlsVideoPlayer";
import { baseUrl } from "@/api/baseUrl"; import { baseUrl } from "@/api/baseUrl";
import { REVIEW_PADDING } from "@/types/review"; import { REVIEW_PADDING } from "@/types/review";
import { import {
ASPECT_VERTICAL_LAYOUT, ASPECT_PORTRAIT_LAYOUT,
ASPECT_WIDE_LAYOUT, ASPECT_WIDE_LAYOUT,
Recording, Recording,
} from "@/types/record"; } from "@/types/record";
@ -39,6 +39,7 @@ import { useApiHost } from "@/api";
import ImageLoadingIndicator from "@/components/indicators/ImageLoadingIndicator"; import ImageLoadingIndicator from "@/components/indicators/ImageLoadingIndicator";
import ObjectTrackOverlay from "../ObjectTrackOverlay"; import ObjectTrackOverlay from "../ObjectTrackOverlay";
import { useIsAdmin } from "@/hooks/use-is-admin"; import { useIsAdmin } from "@/hooks/use-is-admin";
import { VideoResolutionType } from "@/types/live";
type TrackingDetailsProps = { type TrackingDetailsProps = {
className?: string; className?: string;
@ -253,16 +254,25 @@ export function TrackingDetails({
const [timelineSize] = useResizeObserver(timelineContainerRef); const [timelineSize] = useResizeObserver(timelineContainerRef);
const [fullResolution, setFullResolution] = useState<VideoResolutionType>({
width: 0,
height: 0,
});
const aspectRatio = useMemo(() => { const aspectRatio = useMemo(() => {
if (!config) { if (!config) {
return 16 / 9; return 16 / 9;
} }
if (fullResolution.width && fullResolution.height) {
return fullResolution.width / fullResolution.height;
}
return ( return (
config.cameras[event.camera].detect.width / config.cameras[event.camera].detect.width /
config.cameras[event.camera].detect.height config.cameras[event.camera].detect.height
); );
}, [config, event]); }, [config, event, fullResolution]);
const label = event.sub_label const label = event.sub_label
? event.sub_label ? event.sub_label
@ -460,7 +470,7 @@ export function TrackingDetails({
return "normal"; return "normal";
} else if (aspectRatio > ASPECT_WIDE_LAYOUT) { } else if (aspectRatio > ASPECT_WIDE_LAYOUT) {
return "wide"; return "wide";
} else if (aspectRatio < ASPECT_VERTICAL_LAYOUT) { } else if (aspectRatio < ASPECT_PORTRAIT_LAYOUT) {
return "tall"; return "tall";
} else { } else {
return "normal"; return "normal";
@ -556,6 +566,7 @@ export function TrackingDetails({
onSeekToTime={handleSeekToTime} onSeekToTime={handleSeekToTime}
onUploadFrame={onUploadFrameToPlus} onUploadFrame={onUploadFrameToPlus}
onPlaying={() => setIsVideoLoading(false)} onPlaying={() => setIsVideoLoading(false)}
setFullResolution={setFullResolution}
isDetailMode={true} isDetailMode={true}
camera={event.camera} camera={event.camera}
currentTimeOverride={currentTime} currentTimeOverride={currentTime}
@ -623,7 +634,7 @@ export function TrackingDetails({
<div <div
className={cn( className={cn(
isDesktop && "justify-start overflow-hidden", isDesktop && "justify-start overflow-hidden",
aspectRatio > 1 && aspectRatio < 1.5 aspectRatio > 1 && aspectRatio < ASPECT_PORTRAIT_LAYOUT
? "lg:basis-3/5" ? "lg:basis-3/5"
: "lg:basis-2/5", : "lg:basis-2/5",
)} )}

View File

@ -44,4 +44,5 @@ export type RecordingStartingPoint = {
export type RecordingPlayerError = "stalled" | "startup"; export type RecordingPlayerError = "stalled" | "startup";
export const ASPECT_VERTICAL_LAYOUT = 1.5; export const ASPECT_VERTICAL_LAYOUT = 1.5;
export const ASPECT_PORTRAIT_LAYOUT = 1.333;
export const ASPECT_WIDE_LAYOUT = 2; export const ASPECT_WIDE_LAYOUT = 2;