|
1 | 1 | {-# language DataKinds #-}
|
2 | 2 | {-# language FlexibleInstances #-}
|
| 3 | +{-# language ScopedTypeVariables #-} |
3 | 4 | {-# language TemplateHaskell #-}
|
4 | 5 | {-# language TupleSections #-}
|
5 | 6 | {-# language ViewPatterns #-}
|
@@ -49,14 +50,19 @@ main = do
|
49 | 50 | case mbImg of
|
50 | 51 | Just img -> do
|
51 | 52 | -- Assert that the retrieved frame is 2-dimensional.
|
52 |
| - let img' :: CV.Mat ('S ['D, 'D]) ('S 3) ('S Word8) |
53 |
| - img' = CV.exceptError $ CV.coerceMat img |
54 |
| - imgGray = CV.exceptError $ CV.cvtColor CV.bgr CV.gray img' |
55 |
| - |
56 |
| - faces = ccDetectMultiscale ccFrontal imgGray |
57 |
| - eyedFaces = V.concat . V.toList . CV.exceptError |
58 |
| - $ mapM (\f -> V.map (addCorner f) . ccDetectMultiscale ccEyes |
59 |
| - <$> CV.matSubRect imgGray f) faces |
| 53 | + img' :: CV.Mat ('S ['D, 'D]) ('S 3) ('S Word8) |
| 54 | + <- CV.exceptErrorIO $ CV.coerceMat img |
| 55 | + imgGray <- CV.exceptErrorIO $ CV.cvtColor CV.bgr CV.gray img' |
| 56 | + faces <- CV.exceptErrorIO $ ccDetectMultiscale ccFrontal imgGray |
| 57 | + eyedFaces <- |
| 58 | + fmap (V.concat . V.toList) $ CV.exceptErrorIO $ |
| 59 | + mapM |
| 60 | + (\faceRect -> do |
| 61 | + faceImg <- CV.matSubRect imgGray faceRect |
| 62 | + eyeRects <- ccDetectMultiscale ccEyes faceImg |
| 63 | + pure $ V.map (addCorner faceRect) eyeRects |
| 64 | + ) |
| 65 | + faces |
60 | 66 |
|
61 | 67 | let box = CV.exceptError $
|
62 | 68 | CV.withMatM (h ::: w ::: Z) (Proxy :: Proxy 3) (Proxy :: Proxy Word8) white $ \imgM -> do
|
|
0 commit comments