Add object detection, tracking, mobile notifications, and search to any security camera.
small img
roryclear2f4e5cb0cd80
diff --git a/clearcam/FileServer.m b/clearcam/FileServer.mindex ee4ec5b..cf7b038 100644--- a/clearcam/FileServer.m+++ b/clearcam/FileServer.m@@ -727,12 +727,11 @@// File path for the image (with .jpg extension)NSString *imageFilePath = [imagesDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.jpg", eventTimeStamp]];-+ NSString *imageFilePathSmall = [imagesDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@_small.jpg", eventTimeStamp]];NSError *error = nil;-// Check if the image file exists and delete itif ([[NSFileManager defaultManager] fileExistsAtPath:imageFilePath]) {- if (![[NSFileManager defaultManager] removeItemAtPath:imageFilePath error:&error]) {+ if (![[NSFileManager defaultManager] removeItemAtPath:imageFilePath error:&error] || [[NSFileManager defaultManager] removeItemAtPath:imageFilePathSmall error:&error]) {NSLog(@"Failed to delete image: %@", error.localizedDescription);} else {NSLog(@"Image deleted at path: %@", imageFilePath);@@ -1034,7 +1033,7 @@@"timeStamp": readableDate,@"classType": [event valueForKey:@"classType"] ?: @"unknown",@"quantity": [event valueForKey:@"quantity"] ?: @(0),- @"imageURL": [NSString stringWithFormat:@"images/%lld.jpg", roundedTimestamp]+ @"imageURL": [NSString stringWithFormat:@"images/%lld_small.jpg", roundedTimestamp]};[eventDataArray addObject:eventDict];}diff --git a/clearcam/SceneState.m b/clearcam/SceneState.mindex 50aae06..2be5724 100644--- a/clearcam/SceneState.m+++ b/clearcam/SceneState.m@@ -84,16 +84,22 @@}// File path for the image- NSString *filePath = [imagesDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%lld.jpg", roundedUnixTimestamp]]; // Changed file extension to .jpg-- // Convert UIImage to JPEG data+ NSString *filePath = [imagesDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%lld.jpg", roundedUnixTimestamp]];NSData *imageData = UIImageJPEGRepresentation(uiImage, 1.0); // 1.0 for maximum quality-+ NSString *filePathSmall = [imagesDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%lld_small.jpg", roundedUnixTimestamp]];// Write the image data to fileif (![imageData writeToFile:filePath atomically:YES]) {NSLog(@"Failed to save image at path: %@", filePath);} else {NSLog(@"Image saved at path: %@", filePath);+ //thumbnail+ UIGraphicsBeginImageContextWithOptions(CGSizeMake(uiImage.size.width / 2, uiImage.size.height / 2), YES, 1.0);+ [uiImage drawInRect:CGRectMake(0, 0, uiImage.size.width / 2, uiImage.size.height / 2)];+ UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();+ UIGraphicsEndImageContext();+ NSData *lowResImageData = UIImageJPEGRepresentation(resizedImage, 0.7);+ [lowResImageData writeToFile:filePathSmall atomically:YES];+if (self.last_email_time && [[NSDate date] timeIntervalSinceDate:self.last_email_time] > 60) { // only once per hour? enforce server side!NSLog(@"sending email");//if ([[NSUserDefaults standardUserDefaults] boolForKey:@"send_email_alerts_enabled"] &&