Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

boxes in portrait

roryclear51f8b08f40d9
diff --git a/clearcam/player.html b/clearcam/player.html
index 7c5ee88..07c46ea 100644
--- a/clearcam/player.html
+++ b/clearcam/player.html
@@ -539,11 +539,19 @@
let aspect_ratio = frames[shape_idx].aspect_ratio;
let res = frames[shape_idx].res;
for(let i = 0; i < frames[shape_idx].squares.length; i++){
- let originX = (frames[shape_idx].squares[i].originX / res);
- let originY = (frames[shape_idx].squares[i].originY / (res / aspect_ratio));
- let length = ((frames[shape_idx].squares[i].bottomRightX - frames[shape_idx].squares[i].originX) / res);
- let height = ((frames[shape_idx].squares[i].bottomRightY - frames[shape_idx].squares[i].originY) / (res / aspect_ratio));
- drawBoundingBox(originX, originY, length, height,yolo_classes[frames[shape_idx].squares[i].classIndex][1],yolo_classes[frames[shape_idx].squares[i].classIndex][0]);
+ if(portrait){ //todo, can just send the correct aspect ratio instead?
+ let originX = (frames[shape_idx].squares[i].originX / (res / aspect_ratio));
+ let originY = (frames[shape_idx].squares[i].originY / res);
+ let length = ((frames[shape_idx].squares[i].bottomRightX - frames[shape_idx].squares[i].originX) / (res / aspect_ratio));
+ let height = ((frames[shape_idx].squares[i].bottomRightY - frames[shape_idx].squares[i].originY) / res);
+ drawBoundingBox(originX, originY, length, height,yolo_classes[frames[shape_idx].squares[i].classIndex][1],yolo_classes[frames[shape_idx].squares[i].classIndex][0]);
+ } else {
+ let originX = (frames[shape_idx].squares[i].originX / res);
+ let originY = (frames[shape_idx].squares[i].originY / (res / aspect_ratio));
+ let length = ((frames[shape_idx].squares[i].bottomRightX - frames[shape_idx].squares[i].originX) / res);
+ let height = ((frames[shape_idx].squares[i].bottomRightY - frames[shape_idx].squares[i].originY) / (res / aspect_ratio));
+ drawBoundingBox(originX, originY, length, height,yolo_classes[frames[shape_idx].squares[i].classIndex][1],yolo_classes[frames[shape_idx].squares[i].classIndex][0]);
+ }
}
let boundingBoxes = document.querySelectorAll(".bounding-box");
for (let i = 0; i < n_boxes; i++) {
@@ -555,6 +563,7 @@
timeDisplay.innerText = `${formatTime(currentTime)} / ${formatTime(adjustedStartTimestamp + totalDuration)}`;
updateGaps();
}
+
function updateGaps() {
const progressBar = document.getElementById("progress");
@@ -785,7 +794,7 @@
}
console.log("preload DONE");
}
-
+ let portrait = false;
function adjustContainerForOrientation(videoElement) {
const videoContainer = document.getElementById('videoContainer');
@@ -798,10 +807,12 @@
// Adjust the container's dimensions based on the video's orientation
if (isPortrait) {
+ portrait = true;
// Portrait mode: set container to 480x640
videoContainer.style.maxWidth = '480px';
videoContainer.style.aspectRatio = '3 / 4'; // 480:640 simplifies to 3:4
} else {
+ portrait = false;
// Landscape mode: set container to 640x480
videoContainer.style.maxWidth = '640px';
videoContainer.style.aspectRatio = '4 / 3'; // 640:480 simplifies to 4:3