Add object detection, tracking, mobile notifications, and search to any security camera.
use annot thumbnails
roryclear50423e9fc90e
diff --git a/clearcam.py b/clearcam.pyindex ca43a93..c63326b 100644--- a/clearcam.py+++ b/clearcam.py@@ -609,10 +609,14 @@ class VideoCapture:if (send_det and userID is not None) and time.time() - last_det >= 15: #send 15ish second clip afteros.makedirs(CAMERA_BASE_DIR / self.cam_name / "event_clips", exist_ok=True)mp4_filename = CAMERA_BASE_DIR / f"{self.cam_name}/event_clips/{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.mp4"+ temp_output = CAMERA_BASE_DIR / f"{self.cam_name}/event_clips/{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}_temp.mp4"self.streamer.export_clip(Path(mp4_filename))+ # img preview?+ subprocess.run(['ffmpeg', '-i', mp4_filename, '-i', str(filename), '-map', '0', '-map', '1', '-c', 'copy', '-disposition:v:1', 'attached_pic', '-y', temp_output])+ os.replace(temp_output, mp4_filename)encrypt_file(Path(mp4_filename), Path(f"""{mp4_filename}.aes"""), key)- os.unlink(mp4_filename)threading.Thread(target=upload_file, args=(Path(f"""{mp4_filename}.aes"""), userID), daemon=True).start()+ os.unlink(mp4_filename)send_det = Falseif userID and (time.time() - last_live_check) >= 5:last_live_check = time.time()diff --git a/ios/clearcam/GalleryViewController.m b/ios/clearcam/GalleryViewController.mindex a7b13ad..361068b 100644--- a/ios/clearcam/GalleryViewController.m+++ b/ios/clearcam/GalleryViewController.m@@ -639,15 +639,32 @@- (UIImage *)generateThumbnailForVideoAtPath:(NSString *)videoPath {NSURL *videoURL = [NSURL fileURLWithPath:videoPath];AVAsset *asset = [AVAsset assetWithURL:videoURL];+ NSArray *artworks = [AVMetadataItem metadataItemsFromArray:asset.metadata+ withKey:AVMetadataCommonKeyArtwork+ keySpace:AVMetadataKeySpaceCommon];++ for (AVMetadataItem *item in artworks) {+ if ([item.value isKindOfClass:[NSData class]]) {+ NSData *imageData = (NSData *)item.value;+ UIImage *embeddedThumbnail = [UIImage imageWithData:imageData];+ if (embeddedThumbnail) {+ return embeddedThumbnail;+ }+ }+ }AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];generator.appliesPreferredTrackTransform = YES;CMTime duration = asset.duration;Float64 durationInSeconds = CMTimeGetSeconds(duration);- Float64 middleTime = durationInSeconds / 1.75;+ Float64 middleTime = durationInSeconds / 2.0;CMTime time = CMTimeMakeWithSeconds(middleTime, 600);NSError *error = nil;CGImageRef imageRef = [generator copyCGImageAtTime:time actualTime:NULL error:&error];- if (!imageRef) return nil;+ if (!imageRef) {+ UIImage *videoImage = [UIImage systemImageNamed:@"video"];+ UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:40];+ return [videoImage imageByApplyingSymbolConfiguration:config];+ }UIImage *thumbnail = [UIImage imageWithCGImage:imageRef];CGImageRelease(imageRef);return thumbnail;@@ -788,6 +805,8 @@VideoTableViewCell *updateCell = [tableView cellForRowAtIndexPath:indexPath];if (updateCell) {updateCell.thumbnailView.image = thumbnail;+ updateCell.thumbnailView.contentMode = UIViewContentModeScaleAspectFill;+ updateCell.thumbnailView.tintColor = nil;}});});@@ -799,9 +818,7 @@cell.thumbnailView.contentMode = UIViewContentModeCenter;cell.thumbnailView.tintColor = [UIColor systemGrayColor];}-[cell.menuButton addTarget:self action:@selector(menuTapped:forEvent:) forControlEvents:UIControlEventTouchUpInside];-return cell;}