Skip to content

Commit 17dde52

Browse files
author
敛心
committed
人脸检测主线程返回,定时器放到主线程
1 parent 18785c8 commit 17dde52

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

IOS/SDK/LuaViewSDK/Classes/lvsdk/LVCamera.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ - (void)captureOutput:(AVCaptureOutput *)output didOutputMetadataObjects:(NSArra
193193
for (AVMetadataObject *metadata in metadataObjects){
194194
if ([metadata.type isEqualToString:AVMetadataObjectTypeFace]){
195195
CGRect face = [self.previewLayer rectForMetadataOutputRectOfInterest:metadata.bounds];
196-
[self onFaceDetected:face];
196+
dispatch_async(dispatch_get_main_queue(), ^{
197+
[self onFaceDetected:face];
198+
});
197199
#ifdef DEBUG
198200
CGPathAddRect(path, NULL, face);
199201
#endif

IOS/SDK/LuaViewSDK/Classes/lvsdk/LVTimer.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ -(void) startTimer{
6363
if( self.delay>0 ) {
6464
NSDate* date = [[NSDate alloc] initWithTimeIntervalSinceNow:self.delay];
6565
timer = [[NSTimer alloc] initWithFireDate:date interval:self.interval target:self selector:@selector(timerCallBack) userInfo:nil repeats:self.repeat];
66-
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
66+
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
6767
} else {
6868
timer = [NSTimer scheduledTimerWithTimeInterval:self.interval target:self selector:@selector(timerCallBack) userInfo:nil repeats:self.repeat];
69-
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
69+
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
7070
}
7171
}
7272

0 commit comments

Comments
 (0)