Add object detection, tracking, mobile notifications, and search to any security camera.
send squares with segments
roryclear1503d7418bfe
diff --git a/clearcam/ViewController.m b/clearcam/ViewController.mindex 62a3142..35be36d 100644--- a/clearcam/ViewController.m+++ b/clearcam/ViewController.m@@ -28,6 +28,8 @@@property (nonatomic, assign) NSDate *last_file_timestamp;@property (nonatomic, assign) NSDate *current_file_timestamp;@property (nonatomic, strong) NSMutableDictionary *digits;+@property (nonatomic, strong) NSMutableArray *last_segment_squares;+@property (nonatomic, strong) NSMutableArray *current_segment_squares;@end@@ -37,6 +39,8 @@ NSMutableDictionary *classColorMap;- (void)viewDidLoad {[super viewDidLoad];+ self.last_segment_squares = [[NSMutableArray alloc] init];+ self.current_segment_squares = [[NSMutableArray alloc] init];self.digits = [NSMutableDictionary dictionary];self.digits[@"0"] = @[@[ @0, @0, @3, @1], @[ @0, @1, @1 , @3], @[ @2, @1, @1 , @3], @[ @0, @4, @3 , @1]];self.digits[@"1"] = @[@[ @2, @0, @1, @5 ]];@@ -347,13 +351,15 @@ NSMutableDictionary *classColorMap;self.last_file_duration = time;self.last_file_url = [self.assetWriter.outputURL copy];self.last_file_timestamp = self.current_file_timestamp;+ self.last_segment_squares = self.current_segment_squares; //todo, clean} else {CMTime timeDifference = CMTimeMakeWithSeconds([self.current_file_timestamp timeIntervalSinceDate:self.last_file_timestamp], NSEC_PER_SEC);NSMutableDictionary *segmentEntry = [NSMutableDictionary dictionaryWithDictionary:@{ //does this fix last segment in hour/day?@"url": [NSString stringWithFormat:@"%@/%@", [[self.last_file_url URLByDeletingLastPathComponent] lastPathComponent], self.last_file_url.lastPathComponent],@"duration": @(CMTimeGetSeconds(self.last_file_duration)),- @"timeDifference": @(CMTimeGetSeconds(timeDifference))+ @"timeDifference": @(CMTimeGetSeconds(timeDifference)),+ @"squares":self.last_segment_squares}];NSMutableArray *segmentsForDate = self.fileServer.segmentsDict[dateKey];@@ -372,7 +378,9 @@ NSMutableDictionary *classColorMap;self.last_file_duration = time;self.last_file_url = [self.assetWriter.outputURL copy];self.last_file_timestamp = self.current_file_timestamp;+ self.last_segment_squares = self.current_segment_squares;}+ [self.current_segment_squares removeAllObjects];NSLog(@"Duration is %f seconds", CMTimeGetSeconds(time));[self startNewRecording];@@ -465,6 +473,18 @@ NSMutableDictionary *classColorMap;size_t width = CVPixelBufferGetWidth(imageBuffer);size_t height = CVPixelBufferGetHeight(imageBuffer);CGFloat aspect_ratio = (CGFloat)width / (CGFloat)height;++ NSMutableDictionary *frame = [[NSMutableDictionary alloc] init];//todo, init elsewhere+ NSMutableDictionary *frameSquare = [[NSMutableDictionary alloc] init];;+ NSMutableArray *frameSquares = [[NSMutableArray alloc] init];;++ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];+ [dateFormatter setDateFormat:@"yyyy-MM-dd_HH:mm:ss:SSS"];+ NSString *formattedDate = [dateFormatter stringFromDate:[NSDate date]];+ frame[@"timeStamp"] = formattedDate;+ frame[@"res"] = @(self.yolo.yolo_res);+ frame[@"aspect_ratio"] = @(aspect_ratio);+CGFloat targetWidth = self.yolo.yolo_res;CGSize targetSize = CGSizeMake(targetWidth, targetWidth / aspect_ratio);@@ -490,7 +510,15 @@ NSMutableDictionary *classColorMap;bottomRightY:[output[i][3] floatValue]classIndex:[output[i][4] intValue]aspectRatio:aspect_ratio];+ frameSquare[@"originX"] = output[i][0];+ frameSquare[@"originY"] = output[i][1];+ frameSquare[@"length"] = output[i][2];+ frameSquare[@"height"] = output[i][3];+ frameSquare[@"classIndex"] = output[i][4];+ [frameSquares addObject:frameSquare];}+ frame[@"squares"] = frameSquares;+ [self.current_segment_squares addObject:frame];[weak_self updateFPS];weak_self.isProcessing = NO;});