Add object detection, tracking, mobile notifications, and search to any security camera.
start monitoring state
roryclear13265256a619
diff --git a/clearcam/SceneState.h b/clearcam/SceneState.hindex b1f19b8..a96922f 100644--- a/clearcam/SceneState.h+++ b/clearcam/SceneState.h@@ -3,5 +3,9 @@@interface SceneState : NSObject@property (nonatomic, strong) NSMutableArray<NSDictionary *> *lastN;+@property (nonatomic, strong) NSMutableDictionary *lastN_total;+@property (nonatomic, strong) NSMutableDictionary *lastN_state;+@property (nonatomic, strong) NSArray<NSArray<NSNumber *> *> *events;+- (void)processOutput:(NSArray *)array;@enddiff --git a/clearcam/SceneState.m b/clearcam/SceneState.mindex fbe5a34..13b27c5 100644--- a/clearcam/SceneState.m+++ b/clearcam/SceneState.m@@ -1,4 +1,5 @@#import "SceneState.h"+#import "SettingsManager.h"@implementation SceneState@@ -6,8 +7,40 @@self = [super init];if (self) {self.lastN = [NSMutableArray array];+ self.lastN_total = [[NSMutableDictionary alloc] init];+ self.lastN_state = [[NSMutableDictionary alloc] init];+ self.events = [SettingsManager sharedManager].events;}return self;}+- (void)processOutput:(NSArray *)array {+ NSMutableDictionary *frame = [[NSMutableDictionary alloc] init];+ for(int i = 0; i < array.count; i++){+ frame[array[i][4]] = frame[array[i][4]] ? @([frame[array[i][4]] intValue] + 1) : @1;+ }+ [self.lastN addObject:frame];++ if(self.lastN.count > 10){+ NSLog(@"> 10 %lu",(unsigned long)self.lastN.count);+ for(int i = 0; i < self.events.count; i++){+ NSNumber *totalValue = self.lastN_total[self.events[i][0]] ?: @0;+ NSNumber *frameValue = frame[self.events[i][0]] ?: @0;+ self.lastN_total[self.events[i][0]] = @(totalValue.intValue + frameValue.intValue);++ totalValue = self.lastN_total[self.events[i][0]] ?: @0;+ frameValue = self.lastN[0][self.events[i][0]] ?: @0;+ self.lastN_total[self.events[i][0]] = @(totalValue.intValue - frameValue.intValue);++ [self.lastN removeObjectAtIndex:0];++ NSLog(@"rory event %d = %@",i,self.events[i][0]);+ NSLog(@"rory event total = %@",self.lastN_total[self.events[i][0]]);+ }+ }++ return;+}+@end+diff --git a/clearcam/Yolo.m b/clearcam/Yolo.mindex 29bf182..577f91b 100644--- a/clearcam/Yolo.m+++ b/clearcam/Yolo.m@@ -368,6 +368,7 @@ UInt8 *rgbData;if (i < output.count - 1) [classNamesString appendString:@", "];}//NSLog(@"Class Names: %@", classNamesString);+ [self.scene processOutput:output];if(output.count > 0){NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];