Skip to content

Commit

Permalink
use live dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeblackshear committed Oct 17, 2021
1 parent ae24cf3 commit 7ab6961
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion web/src/routes/Camera.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default function Camera({ camera }) {
const [viewMode, setViewMode] = useState('live');

const cameraConfig = config?.cameras[camera];
const liveWidth = Math.round(cameraConfig.live.height * (cameraConfig.detect.width / cameraConfig.detect.height))
const [options, setOptions] = usePersistence(`${camera}-feed`, emptyObject);

const handleSetOption = useCallback(
Expand Down Expand Up @@ -87,7 +88,7 @@ export default function Camera({ camera }) {
player = (
<Fragment>
<div>
<JSMpegPlayer camera={camera} width={cameraConfig.detect.width} height={cameraConfig.detect.height} />
<JSMpegPlayer camera={camera} width={liveWidth} height={cameraConfig.live.height} />
</div>
</Fragment>
);
Expand Down
2 changes: 1 addition & 1 deletion web/src/routes/__tests__/Camera.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Camera Route', () => {
mockSetOptions = jest.fn();
mockUsePersistence = jest.spyOn(Context, 'usePersistence').mockImplementation(() => [{}, mockSetOptions]);
jest.spyOn(Api, 'useConfig').mockImplementation(() => ({
data: { cameras: { front: { name: 'front', detect: {width: 1280, height: 720}, objects: { track: ['taco', 'cat', 'dog'] } } } },
data: { cameras: { front: { name: 'front', detect: {width: 1280, height: 720}, live: {height: 720}, objects: { track: ['taco', 'cat', 'dog'] } } } },
}));
jest.spyOn(Api, 'useApiHost').mockImplementation(() => 'http:https://base-url.local:5000');
jest.spyOn(AutoUpdatingCameraImage, 'default').mockImplementation(({ searchParams }) => {
Expand Down

0 comments on commit 7ab6961

Please sign in to comment.