-
-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Webcam): add a optional overlay for IDEX calibration #2053
Open
meteyou
wants to merge
1
commit into
mainsail-crew:develop
Choose a base branch
from
meteyou:feat/add-nozzle-crosshair-webcam
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<template> | ||
<div ref="container" class="crosshair-container"> | ||
<div class="line horizontal" :style="styleLines" /> | ||
<div class="line vertical" :style="styleLines" /> | ||
<div class="circle" :style="styleCircle" /> | ||
<resize-observer @notify="handleResize" /> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Component from 'vue-class-component' | ||
import { Mixins, Prop, Ref } from 'vue-property-decorator' | ||
import BaseMixin from '@/components/mixins/base' | ||
import { GuiWebcamStateWebcam } from '@/store/gui/webcams/types' | ||
|
||
@Component | ||
export default class WebcamWrapper extends Mixins(BaseMixin) { | ||
@Prop({ type: Object, required: true }) webcam!: GuiWebcamStateWebcam | ||
@Ref() container!: HTMLDivElement | ||
|
||
clientHeight = 0 | ||
|
||
get color() { | ||
return this.webcam.extra_data?.nozzleCrosshairColor ?? '#ff0000' | ||
} | ||
|
||
get styleLines() { | ||
return { | ||
backgroundColor: this.color, | ||
} | ||
} | ||
|
||
get styleCircle() { | ||
const nozzleCrosshairSize = this.webcam.extra_data?.nozzleCrosshairSize ?? 0.1 | ||
const size = this.clientHeight * nozzleCrosshairSize | ||
|
||
return { | ||
borderColor: this.color, | ||
width: `${size}px`, | ||
height: `${size}px`, | ||
marginLeft: `-${size / 2}px`, | ||
marginTop: `-${size / 2}px`, | ||
} | ||
} | ||
|
||
mounted() { | ||
this.handleResize() | ||
} | ||
|
||
handleResize() { | ||
this.$nextTick(() => { | ||
this.clientHeight = this.container.clientHeight | ||
}) | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.crosshair-container { | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
} | ||
|
||
.line { | ||
position: absolute; | ||
background-color: #ff0000; | ||
} | ||
|
||
.horizontal { | ||
height: 1px; | ||
top: 50%; | ||
left: 0; | ||
right: 0; | ||
} | ||
|
||
.vertical { | ||
left: 50%; | ||
top: 0; | ||
bottom: 0; | ||
width: 1px; | ||
} | ||
|
||
.circle { | ||
position: absolute; | ||
border: 1px solid #ff0000; | ||
border-radius: 50%; | ||
box-sizing: border-box; | ||
top: 50%; | ||
left: 50%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<template> | ||
<div> | ||
<div class="position-relative d-flex"> | ||
<video | ||
v-show="status === 'connected'" | ||
ref="stream" | ||
|
@@ -8,6 +8,7 @@ | |
autoplay | ||
muted | ||
playsinline /> | ||
<webcam-nozzle-crosshair v-if="nozzleCrosshair" :webcam="camSettings" /> | ||
<v-row v-if="status !== 'connected'"> | ||
<v-col class="_webcam_webrtc_output text-center d-flex flex-column justify-center align-center"> | ||
<v-progress-circular v-if="status === 'connecting'" indeterminate color="primary" class="mb-3" /> | ||
|
@@ -23,14 +24,15 @@ import BaseMixin from '@/components/mixins/base' | |
import { GuiWebcamStateWebcam } from '@/store/gui/webcams/types' | ||
import WebcamMixin from '@/components/mixins/webcam' | ||
import { capitalize } from '@/plugins/helpers' | ||
import WebcamNozzleCrosshair from '@/components/webcams/WebcamNozzleCrosshair.vue' | ||
|
||
interface CameraStreamerResponse extends RTCSessionDescriptionInit { | ||
id: string | ||
iceServers?: RTCIceServer[] | ||
} | ||
|
||
@Component({ | ||
methods: { capitalize }, | ||
components: { WebcamNozzleCrosshair }, | ||
}) | ||
export default class WebrtcCameraStreamer extends Mixins(BaseMixin, WebcamMixin) { | ||
capitalize = capitalize | ||
|
@@ -65,6 +67,10 @@ export default class WebrtcCameraStreamer extends Mixins(BaseMixin, WebcamMixin) | |
return output | ||
} | ||
|
||
get nozzleCrosshair() { | ||
return this.camSettings.extra_data?.nozzleCrosshair ?? false | ||
} | ||
|
||
get expanded(): boolean { | ||
if (this.page !== 'dashboard') return true | ||
|
||
|
@@ -243,6 +249,10 @@ export default class WebrtcCameraStreamer extends Mixins(BaseMixin, WebcamMixin) | |
</script> | ||
|
||
<style scoped> | ||
.position-relative { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is an position relative |
||
position: relative; | ||
} | ||
|
||
.webcamStream { | ||
width: 100%; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debug output