Skip to content
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

Fix yolo demo for iOS and macOS Safari #2

Merged
merged 1 commit into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/components/common/WebcamModelUI.vue
Original file line number Diff line number Diff line change
Expand Up @@ -528,12 +528,12 @@ export default class WebcamModelUI extends Vue {
this.webcamElement,
beginWidth,
beginHeight,
this.videoOrigWidth,
this.videoOrigHeight,
size,
size,
0,
0,
this.webcamElement.width,
this.webcamElement.height
canvas.width,
canvas.height
);
return context;
}
Expand Down Expand Up @@ -575,6 +575,7 @@ export default class WebcamModelUI extends Vue {
height: 416px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
& :nth-child(n + 3) {
Expand Down
1 change: 1 addition & 0 deletions src/components/models/Emotion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default class Emotion extends Vue {
) {
const rect = document.createElement("div");
const label = document.createElement("div");
rect.style.cssText = `top: 0px;`;
label.style.cssText = "font-size: 24px";
label.innerText = text;
rect.appendChild(label);
Expand Down
7 changes: 5 additions & 2 deletions src/components/models/Yolo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,16 @@ export default class Yolo extends Vue {
text = "",
color = "red"
) {
const webcamContainerElement = document.getElementById("webcam-container") as HTMLElement;
// Depending on the display size, webcamContainerElement might be smaller than 416x416.
const [ox, oy] = [(webcamContainerElement.offsetWidth - 416) / 2, (webcamContainerElement.offsetHeight - 416) / 2];
const rect = document.createElement("div");
rect.style.cssText = `top: ${y}px; left: ${x}px; width: ${w}px; height: ${h}px; border-color: ${color};`;
rect.style.cssText = `top: ${y+oy}px; left: ${x+ox}px; width: ${w}px; height: ${h}px; border-color: ${color};`;
const label = document.createElement("div");
label.innerText = text;
rect.appendChild(label);

(document.getElementById("webcam-container") as HTMLElement).appendChild(
webcamContainerElement.appendChild(
rect
);
}
Expand Down