Skip to content
Merged

Dev #122

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions 4.use-case/3.show-result-texts-on-the-video.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@
https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=latest#host-the-library-yourself-recommended
-->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dbr.js"></script>
<style>
* {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="div-ui-container" style="width: 100%; height: 100vh"></div>
<div id="div-ui-container" style="width: 100%; height: 90vh"></div>
<div id="div-text-containers"></div>
<script>
if (location.protocol === "file:") {
Expand Down Expand Up @@ -95,13 +89,26 @@
const convertedP2 = scanner.convertToPageCoordinates(p2);

textContainer = document.createElement("div");
Object.assign(textContainer.style, {
position: "absolute",
left: convertedP1.x + "px",
right: document.documentElement.clientWidth - convertedP2.x + "px",
bottom: document.documentElement.clientHeight - convertedP1.y + "px",
color: "#FE8E14",
});
const bodyStyle = getComputedStyle(document.body);
if (bodyStyle.position !== "static") {
const rect = document.body.getBoundingClientRect();
const borderWidth = parseInt(bodyStyle.borderWidth);
Object.assign(textContainer.style, {
position: "absolute",
left: convertedP1.x - rect.left - borderWidth + "px",
right: rect.right - convertedP2.x - borderWidth + "px",
bottom: rect.bottom - convertedP1.y - borderWidth + "px",
color: "#FE8E14",
});
} else {
Object.assign(textContainer.style, {
position: "absolute",
left: convertedP1.x + "px",
right: document.documentElement.clientWidth - convertedP2.x + "px",
bottom: document.documentElement.clientHeight - convertedP1.y + "px",
color: "#FE8E14",
});
}
textContainer.innerText = result.barcodeText;
divTextContainers.append(textContainer);

Expand Down