Add object detection, tracking, mobile notifications, and search to any security camera.
clean and add fake date thing
roryclear2a61caebd167
diff --git a/clearcam/AppDelegate.h b/clearcam/AppDelegate.hindex 5f964eb..67e2db7 100644--- a/clearcam/AppDelegate.h+++ b/clearcam/AppDelegate.h@@ -6,6 +6,4 @@@property (strong, nonatomic) UIWindow *window;@property (readonly, strong) NSPersistentContainer *persistentContainer; // Core Data container-- (void)saveContext;-@enddiff --git a/clearcam/AppDelegate.m b/clearcam/AppDelegate.mindex 589763c..e27b94f 100644--- a/clearcam/AppDelegate.m+++ b/clearcam/AppDelegate.m@@ -19,14 +19,4 @@}return _persistentContainer;}--- (void)saveContext {- NSManagedObjectContext *context = self.persistentContainer.viewContext;- NSError *error = nil;- if ([context hasChanges] && ![context save:&error]) {- NSLog(@"Unresolved error %@, %@", error, error.userInfo);- abort();- }-}-@enddiff --git a/clearcam/FileServer.m b/clearcam/FileServer.mindex 290c2e1..05cafef 100644--- a/clearcam/FileServer.m+++ b/clearcam/FileServer.m@@ -26,9 +26,9 @@//TODO REMOVE THIS- [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"LastDeletedDayIndex"];- [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"LastDeletedSegmentIndex"];- [[NSUserDefaults standardUserDefaults] synchronize];+ //[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"LastDeletedDayIndex"];+ //[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"LastDeletedSegmentIndex"];+ //[[NSUserDefaults standardUserDefaults] synchronize];NSFileManager *fileManager = [NSFileManager defaultManager];NSURL *documentsURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] firstObject];@@ -59,7 +59,6 @@// Save a new stringNSLog(@"core data segments?:");- //[self fetchAllSegmentsInContext:self.context];[self deleteAllDayEntitiesInContext:self.context]; //to delete all, not thread safe yet!// Fetch all saved strings// coredata stuff@@ -468,60 +467,6 @@}}-- (void)fetchAllSegmentsInContext:(NSManagedObjectContext *)context {- NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"SegmentEntity"];-- // Execute the fetch request- NSError *error = nil;- NSArray *results = [context executeFetchRequest:fetchRequest error:&error];-- if (error) {- NSLog(@"Failed to fetch segments: %@", error.localizedDescription);- } else {- NSLog(@"Fetched segments:");- for (NSManagedObject *segment in results) {- NSString *url = [segment valueForKey:@"url"];- double timeStamp = [[segment valueForKey:@"timeStamp"] doubleValue];- double duration = [[segment valueForKey:@"duration"] doubleValue];-- NSLog(@"Segment - URL: %@, TimeStamp: %f, Duration: %f", url, timeStamp, duration);-- // Fetch the ordered frames- NSOrderedSet *frames = [segment valueForKey:@"frames"];- if (frames.count == 0) {- NSLog(@" No frames associated with this segment.");- } else {- NSLog(@" Frames:");- for (NSManagedObject *frame in frames) {- double frameTimeStamp = [[frame valueForKey:@"frame_timeStamp"] doubleValue];- double aspectRatio = [[frame valueForKey:@"aspect_ratio"] doubleValue];- int res = [[frame valueForKey:@"res"] intValue];-- NSLog(@" - Frame: TimeStamp: %f, Aspect Ratio: %f, Resolution: %d", frameTimeStamp, aspectRatio, res);-- // Fetch the ordered squares within this frame- NSOrderedSet *squares = [frame valueForKey:@"squares"];- if (squares.count == 0) {- NSLog(@" No squares associated with this frame.");- } else {- NSLog(@" Squares:");- for (NSManagedObject *square in squares) {- double originX = [[square valueForKey:@"originX"] doubleValue];- double originY = [[square valueForKey:@"originY"] doubleValue];- double bottomRightX = [[square valueForKey:@"bottomRightX"] doubleValue];- double bottomRightY = [[square valueForKey:@"bottomRightY"] doubleValue];- int classIndex = [[square valueForKey:@"classIndex"] intValue];-- NSLog(@" - Square: Origin(%.2f, %.2f), BottomRight(%.2f, %.2f), Class Index: %d",- originX, originY, bottomRightX, bottomRightY, classIndex);- }- }- }- }- }- }-}-- (void)deleteAllDayEntitiesInContext:(NSManagedObjectContext *)context {NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"DayEntity"];diff --git a/clearcam/ViewController.m b/clearcam/ViewController.mindex b235b76..c4a7116 100644--- a/clearcam/ViewController.m+++ b/clearcam/ViewController.m@@ -28,7 +28,7 @@@property (nonatomic, strong) NSMutableArray *current_segment_squares;@property (nonatomic, strong) NSLock *segmentLock;-#define MIN_FREE_SPACE_MB 21000 //threshold to start deleting+#define MIN_FREE_SPACE_MB 500 //threshold to start deleting@end@@ -132,6 +132,18 @@ NSMutableDictionary *classColorMap;return [formatter stringFromDate:[NSDate date]];}+- (NSString*)fake_getDateString { //todo remove+ NSDate *now = [NSDate date];+ NSCalendar *calendar = [NSCalendar currentCalendar];+ NSDateComponents *nowComponents = [calendar components:(NSCalendarUnitHour | NSCalendarUnitMinute) fromDate:now];++ if (nowComponents.hour < 12 || (nowComponents.hour == 12 && nowComponents.minute < 20)) {+ return @"2025-02-14";+ } else {+ return @"2025-02-15";+ }+}+- (void)startNewRecording {NSString *dayFolderName = [self getDateString];@@ -499,7 +511,6 @@ NSMutableDictionary *classColorMap;NSLog(@"No more DayEntities available. Resetting deletion indexes.");[defaults removeObjectForKey:@"LastDeletedDayIndex"];[defaults removeObjectForKey:@"LastDeletedSegmentIndex"];- [defaults synchronize];return;}