Skip to content

Commit

Permalink
connected cameras to Operational-View
Browse files Browse the repository at this point in the history
  • Loading branch information
Mchan2003 committed Sep 9, 2023
1 parent aa3da13 commit af114e0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/components/Camera.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
export default function Camera({ name, src }) {
return (
<div>
{src ? <img src={src} alt={name} /> : <p>Camera {name} is not connected</p>}
{src ? <img className='camera' src={src} alt={name} /> : <p>Camera {name} is not connected</p>}
</div>
)
}
23 changes: 8 additions & 15 deletions src/components/OperationalView/MainCamera.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import {useState} from "react"
import Camera from "../Camera";
import noCam from './Main_Camera_Test.png'
import cam2 from './oatmeal.gif'
//Todo: need to add more cameras
Expand All @@ -8,20 +9,23 @@ import cam2 from './oatmeal.gif'

export default function MainCamera({mainCam}){
var fileName = noCam;
//Todo: add more cameras from rover
var testCam1 = 'http://192.168.1.119:8081/'
var testCam2 = 'http://192.168.1.196:8081/'

switch (mainCam)
{
case 'chassis':
fileName = noCam;
fileName = testCam1;
break;
case 'mast':
fileName = cam2
fileName = testCam2;
break;
case 'wheel_A':
fileName = noCam;
break;
case 'wheel_B':
fileName = cam2
fileName = cam2;
break;
case 'wheel_C':
fileName = noCam;
Expand All @@ -34,18 +38,7 @@ export default function MainCamera({mainCam}){
break;
}

const camStyle = {
backgroundImage: `url(${fileName})`,
backgroundSize: 'cover',
backgroundPosition: 'center',
width: '100%',
height: '100vh',
overflow: 'hidden',
aspectRatio: '4/3'
};

return(
<div id = "ov-main-cam"style={camStyle}>
</div>
<Camera name={mainCam} src={fileName} />
);
}
3 changes: 1 addition & 2 deletions src/components/OperationalView/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export default function Menu({callback}) {
{title: "wheel_A"},
{title: "wheel_B"},
{title: "wheel_C"},
{title: "arm"},
{title: "noCam"}
{title: "arm"}
]

return (
Expand Down
9 changes: 9 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,15 @@ video {
border: 2px solid #565656;
border-radius: 8px;
}

.camera{
background-size: cover;
background-position: center;
width: 100%;
height: 100vh;
overflow: hidden;
aspect-ratio: 4/3;
}
/* .ov-camera-toggle{
background-image: url(/src/components/OperationalView/oatmeal.gif);
background-size: contain;
Expand Down

0 comments on commit af114e0

Please sign in to comment.