Skip to content

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

move scene to viewController

roryclearfb74edc5344b
diff --git a/clearcam/ViewController.m b/clearcam/ViewController.m
index a8c07e7..dd0f1ab 100644
--- a/clearcam/ViewController.m
+++ b/clearcam/ViewController.m
@@ -4,6 +4,7 @@
#import "Yolo.h"
#import "FileServer.h"
#import "SettingsManager.h"
+#import "SceneState.h"
@interface ViewController ()
@@ -31,6 +32,7 @@
@property (nonatomic, strong) NSManagedObjectContext *backgroundContext;
@property (nonatomic, strong) NSString *dayFolderName;
@property (nonatomic, strong) dispatch_queue_t segmentQueue;
+@property (nonatomic, strong) SceneState *scene;
#define MIN_FREE_SPACE_MB 500 //threshold to start deleting
@@ -42,6 +44,7 @@ NSMutableDictionary *classColorMap;
- (void)viewDidLoad {
[super viewDidLoad];
+ self.scene = [[SceneState alloc] init];
self.segmentQueue = dispatch_queue_create("com.example.segmentQueue", DISPATCH_QUEUE_SERIAL);
self.current_segment_squares = [[NSMutableArray alloc] init];
self.digits = [NSMutableDictionary dictionary];
@@ -749,6 +752,7 @@ NSMutableDictionary *classColorMap;
CGImageRef cgImage = [self.ciContext createCGImage:croppedImage fromRect:cropRect];
NSArray *output = [self.yolo yolo_infer:cgImage withOrientation:videoOrientation];
+ [self.scene processOutput:output withImage:cgImage];
CGImageRelease(cgImage);
__weak typeof(self) weak_self = self;
diff --git a/clearcam/Yolo.h b/clearcam/Yolo.h
index 9960e32..96ac226 100644
--- a/clearcam/Yolo.h
+++ b/clearcam/Yolo.h
@@ -1,7 +1,6 @@
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>
#import <AVFoundation/AVFoundation.h>
-#import "SceneState.h"
NS_ASSUME_NONNULL_BEGIN
@@ -20,7 +19,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong) NSString *input_buffer;
@property (nonatomic, strong) NSString *output_buffer;
@property (nonatomic, assign) UInt8 *rgbData;
-@property (nonatomic, strong) SceneState *scene;
- (NSArray *)yolo_infer:(CGImageRef)cgImage withOrientation:(AVCaptureVideoOrientation)orientation;
// Initializer
diff --git a/clearcam/Yolo.m b/clearcam/Yolo.m
index ed42eba..86dc20b 100644
--- a/clearcam/Yolo.m
+++ b/clearcam/Yolo.m
@@ -3,7 +3,6 @@
#import <UIKit/UIKit.h>
#import <sys/utsname.h>
#import "SettingsManager.h"
-#import "SceneState.h"
@implementation Yolo
@@ -23,7 +22,6 @@ UInt8 *rgbData;
- (instancetype)init {
self = [super init];
- self.scene = [[SceneState alloc] init];
self.device = MTLCreateSystemDefaultDevice();
self.pipeline_states = [[NSMutableDictionary alloc] init];
self.buffers = [[NSMutableDictionary alloc] init];
@@ -368,7 +366,7 @@ UInt8 *rgbData;
[classNamesString appendString:self.yolo_classes[[output[i][4] intValue]][0]];
if (i < output.count - 1) [classNamesString appendString:@", "];
}
- [self.scene processOutput:output withImage:cgImage];
+ /* todo, move or remove?
if(output.count > 0){
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
@@ -380,6 +378,7 @@ UInt8 *rgbData;
[fileHandle writeData:[[logEntry stringByAppendingString:@"\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[fileHandle closeFile];
}
+ */
return output;
}