Skip to content

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

add 480p and fix square stuff

roryclear953b1d3f13ac
diff --git a/clearcam/SettingsViewController.m b/clearcam/SettingsViewController.m
index 65bce8f..d6cbd2b 100644
--- a/clearcam/SettingsViewController.m
+++ b/clearcam/SettingsViewController.m
@@ -1001,7 +1001,7 @@
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
- NSArray *resolutions = @[@"720p", @"1080p"];
+ NSArray *resolutions = @[@"480p",@"720p", @"1080p"];
for (NSString *resolution in resolutions) {
UIAlertAction *action = [UIAlertAction actionWithTitle:resolution
@@ -1013,6 +1013,8 @@
[settingsManager updateResolutionWithWidth:@"1280" height:@"720" textSize:@"2" preset:@"AVCaptureSessionPreset1280x720"];
} else if ([resolution isEqualToString:@"1080p"]) {
[settingsManager updateResolutionWithWidth:@"1920" height:@"1080" textSize:@"3" preset:@"AVCaptureSessionPreset1920x1080"];
+ } else if ([resolution isEqualToString:@"480p"]) {
+ [settingsManager updateResolutionWithWidth:@"640" height:@"480" textSize:@"2" preset:@"AVCaptureSessionPreset640x480"];
}
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
diff --git a/clearcam/player.html b/clearcam/player.html
index fed6d2b..9c2fbe1 100644
--- a/clearcam/player.html
+++ b/clearcam/player.html
@@ -514,12 +514,24 @@
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;
+ if (aspect_ratio !== 9 / 16) {
+ let scale = aspect_ratio / (16 / 9);
+ let offset = (1 - scale) / 2;
+ originY = originY * scale + offset;
+ height *= scale;
+ }
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);
+ if (aspect_ratio !== 16 / 9) {
+ let scale = aspect_ratio / (16 / 9);
+ let offset = (1 - scale) / 2;
+ originX = originX * scale + offset;
+ length *= scale;
+ }
drawBoundingBox(originX, originY, length, height, yolo_classes[frames[shape_idx].squares[i].classIndex][1], yolo_classes[frames[shape_idx].squares[i].classIndex][0]);
}
}
@@ -1139,22 +1151,16 @@
const video = container.querySelector("video");
const containerAspectRatio = container.clientWidth / container.clientHeight;
- const videoAspectRatio = video.videoWidth / video.videoHeight;
-
let videoWidth, videoHeight, offsetX, offsetY;
if (portrait) {
// Video is pillarboxed
videoHeight = container.clientHeight;
- videoWidth = videoHeight * videoAspectRatio;
- offsetX = (container.clientWidth - videoWidth) / 2;
- offsetY = 0;
+ videoWidth = videoHeight * containerAspectRatio;
} else {
// Video is letterboxed
videoWidth = container.clientWidth;
- videoHeight = videoWidth / videoAspectRatio;
- offsetX = 0;
- offsetY = (container.clientHeight - videoHeight) / 2;
+ videoHeight = videoWidth / containerAspectRatio;
}
let boxWrapper = document.createElement("div");
@@ -1163,8 +1169,8 @@
// Create the bounding box
let box = document.createElement("div");
box.style.position = "absolute";
- box.style.left = `${offsetX + relativeX * videoWidth}px`;
- box.style.top = `${offsetY + relativeY * videoHeight}px`;
+ box.style.left = `${relativeX * videoWidth}px`;
+ box.style.top = `${relativeY * videoHeight}px`;
box.style.width = `${relativeWidth * videoWidth}px`;
box.style.height = `${relativeHeight * videoHeight}px`;
box.style.border = `2px solid ${color}`;