浏览代码

use live dimensions

Blake Blackshear 3 年之前
父节点
当前提交
7ab6961ee1
共有 2 个文件被更改,包括 3 次插入2 次删除
  1. 2 1
      web/src/routes/Camera.jsx
  2. 1 1
      web/src/routes/__tests__/Camera.test.jsx

+ 2 - 1
web/src/routes/Camera.jsx

@@ -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(
@@ -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>
     );

+ 1 - 1
web/src/routes/__tests__/Camera.test.jsx

@@ -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://base-url.local:5000');
     jest.spyOn(AutoUpdatingCameraImage, 'default').mockImplementation(({ searchParams }) => {