Mediapipe:如何正确释放 MPPGraph

Mediapipe: How to properly dealloc MPPGraph

我不清楚如何正确停止和释放 MPPGraph。我创建了一个与 this 非常相似的框架。每次以某种方式调用 dealloc 时都会抛出此异常。 Thread 1: Exception: "waitUntilDoneWithError: should not be called on the main thread".

我不知道如何不在主线程中调用它,希望有人对此有所了解。

Here you can find the swift code that is calling the mediapipe framework. This example has been created with the framework that can be found here

对于遇到同样问题的任何人。此问题已解决 here 并提出了解决方案。

编辑: 最后一点可能是错误的,但我是这样使用 dealloc 的:

- (void)dealloc {
  self.mediapipeGraph.delegate = nil;
  [self.mediapipeGraph cancel];
  // Ignore errors since we're cleaning up.
  [self.mediapipeGraph closeAllInputStreamsWithError:nil];
  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    [self.mediapipeGraph waitUntilDoneWithError:nil];
  });
}