@@ -28,7 +28,7 @@ class FaceMaskDetection(private val detector: FaceMaskDetector, private val came
28
28
29
29
private val detectionScope = CoroutineScope (
30
30
ThreadPoolExecutor (1 , 1 , 30 , TimeUnit .SECONDS ,
31
- ArrayBlockingQueue (1 ), ThreadPoolExecutor .DiscardOldestPolicy ()).asCoroutineDispatcher())
31
+ ArrayBlockingQueue (1 ), ThreadPoolExecutor .DiscardOldestPolicy ()).asCoroutineDispatcher())
32
32
33
33
sealed class Message {
34
34
class FaceMaskDetect (
@@ -44,7 +44,7 @@ class FaceMaskDetection(private val detector: FaceMaskDetector, private val came
44
44
is Message .FaceMaskDetect -> {
45
45
try {
46
46
msg.detectedFaces.complete(detector.recognize(msg.picture))
47
- } catch (e: CvException ) {
47
+ } catch (e: Throwable ) {
48
48
Log .e(TAG , " Error processing picture of ${msg.picture.height} x ${msg.picture.width} sent at ${msg.sentTime} " )
49
49
msg.detectedFaces.completeExceptionally(e)
50
50
}
@@ -67,6 +67,10 @@ class FaceMaskDetection(private val detector: FaceMaskDetector, private val came
67
67
try {
68
68
val faces = detectedFacesDeferred.await()
69
69
onFaceDetected(faces)
70
+ } catch (e: CvException ) {
71
+ Log .w(TAG , " OpenCV Exception during face processing (sometimes happens), ignoring: $e " )
72
+ } catch (e: Throwable ) {
73
+ Log .e(TAG , " Unexpected exception from face mask processing: $e " )
70
74
} finally {
71
75
busy = false
72
76
}
0 commit comments