From db712e31e29e44c8a3ac7a0aca8e9d91be3a0a24 Mon Sep 17 00:00:00 2001 From: sabade-omkar <112235933+sabade-omkar@users.noreply.github.com> Date: Thu, 9 Nov 2023 19:47:09 +0530 Subject: [PATCH 1/2] Fix: start graph for the case where the input sourceMode is set to video. --- .../examples/ios/common/CommonViewController.mm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mediapipe/examples/ios/common/CommonViewController.mm b/mediapipe/examples/ios/common/CommonViewController.mm index f6c47eacf..dd020562f 100644 --- a/mediapipe/examples/ios/common/CommonViewController.mm +++ b/mediapipe/examples/ios/common/CommonViewController.mm @@ -113,7 +113,7 @@ static const char* kVideoQueueLabel = "com.google.mediapipe.example.videoQueue"; self.videoSource = [[MPPPlayerInputSource alloc] initWithAVAsset:video]; [self.videoSource setDelegate:self queue:self.videoQueue]; dispatch_async(self.videoQueue, ^{ - [self.videoSource start]; + [self startGraphAndVideo]; }); break; } @@ -149,6 +149,18 @@ static const char* kVideoQueueLabel = "com.google.mediapipe.example.videoQueue"; } } +- (void)startGraphAndVideo { + NSError* error; + if (![self.mediapipeGraph startWithError:&error]) { + NSLog(@"Failed to start graph: %@", error); + } + else if (![self.mediapipeGraph waitUntilIdleWithError:&error]) { + NSLog(@"Failed to complete graph initial run: %@", error); + } + + [self.videoSource start]; +} + - (void)startGraphAndCamera { // Start running self.mediapipeGraph. NSError* error; From 5ada0efd237917e2286880856ad86e6ed7a792a5 Mon Sep 17 00:00:00 2001 From: sabade-omkar <112235933+sabade-omkar@users.noreply.github.com> Date: Tue, 5 Dec 2023 00:09:49 +0530 Subject: [PATCH 2/2] refactor: move dispatch block to startGraphAndVideo --- mediapipe/examples/ios/common/CommonViewController.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mediapipe/examples/ios/common/CommonViewController.mm b/mediapipe/examples/ios/common/CommonViewController.mm index dd020562f..d804483c4 100644 --- a/mediapipe/examples/ios/common/CommonViewController.mm +++ b/mediapipe/examples/ios/common/CommonViewController.mm @@ -112,9 +112,8 @@ static const char* kVideoQueueLabel = "com.google.mediapipe.example.videoQueue"; withExtension:@"mov"]]; self.videoSource = [[MPPPlayerInputSource alloc] initWithAVAsset:video]; [self.videoSource setDelegate:self queue:self.videoQueue]; - dispatch_async(self.videoQueue, ^{ - [self startGraphAndVideo]; - }); + self.noCameraLabel.hidden = YES; + [self startGraphAndVideo]; break; } case MediaPipeDemoSourceCamera: { @@ -157,8 +156,9 @@ static const char* kVideoQueueLabel = "com.google.mediapipe.example.videoQueue"; else if (![self.mediapipeGraph waitUntilIdleWithError:&error]) { NSLog(@"Failed to complete graph initial run: %@", error); } - - [self.videoSource start]; + dispatch_async(self.videoQueue, ^{ + [self.videoSource start]; + }); } - (void)startGraphAndCamera {