gcs-user-interface/src/components/Camera.vue

63 lines
1.4 KiB
Vue
Raw Normal View History

2024-02-23 03:42:11 -08:00
<script>
export default {
2024-03-03 00:12:50 -08:00
props: ['cameraNumber'],
2024-02-23 03:42:11 -08:00
data() {
return {
2024-03-03 00:12:50 -08:00
localIp: 'http://192.168.1.173', //maybe change accordingly
port: '5000', //maybe change accordingly
cameraUrls: {
1: 'video_feed', //cam url here
2: 'video_feed2',
}
2024-02-23 03:42:11 -08:00
};
},
mounted() {
2024-03-03 00:12:50 -08:00
// this.initCam();
2024-02-23 03:42:11 -08:00
},
methods: {
2024-03-03 00:12:50 -08:00
// async initCam() {
// try {
// const constraints = { video: true };
// const stream = await navigator.mediaDevices.getUserMedia(constraints);
// this.streams.push(stream);
// } catch (error) {
// console.error('Error accessing camera:', error);
// }
// },
getCameraImageUrl(cameraNumber) {
return `${this.localIp}:${this.port}/${this.cameraUrls[cameraNumber]}`;
2024-02-23 03:42:11 -08:00
}
}
};
</script>
<template>
<div class="box video-section">
2024-03-03 00:43:12 -08:00
<img :src="getCameraImageUrl(cameraNumber)" class="video-image">
2024-02-23 03:42:11 -08:00
</div>
</template>
<style scoped>
2024-03-03 00:43:12 -08:00
/* .app {
2024-02-23 03:42:11 -08:00
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
2024-03-03 00:43:12 -08:00
} */
2024-02-23 03:42:11 -08:00
.video-section {
2024-03-03 00:12:50 -08:00
width: 100%;
height: 100%;
2024-02-23 03:42:11 -08:00
box-sizing: border-box;
2024-03-03 00:12:50 -08:00
border: 2px solid #ccc;
2024-02-23 03:42:11 -08:00
}
2024-03-03 00:43:12 -08:00
.video-image {
2024-02-23 03:42:11 -08:00
width: 100%;
height: 100%;
2024-03-03 00:43:12 -08:00
/* object-fit: contain; */
2024-02-23 03:42:11 -08:00
}
.box{
2024-03-03 00:12:50 -08:00
border: 2px solid #030303;
2024-02-23 03:42:11 -08:00
}
</style>