@@ -35,6 +35,7 @@ import "opencv" OpenCV.Internal.Exception
3535import "base" Control.Monad (guard )
3636import "primitive" Control.Monad.Primitive
3737import "base" Data.Monoid ((<>) )
38+ import "base" Data.Word ( Word8 )
3839import qualified "vector" Data.Vector.Storable as SV
3940import "base" Foreign.C
4041import "base" Foreign.ForeignPtr (ForeignPtr , withForeignPtr )
@@ -47,7 +48,6 @@ import qualified "inline-c" Language.C.Inline.Unsafe as CU
4748import "linear" Linear
4849import "opencv" OpenCV
4950import "opencv" OpenCV.Core.Types.Vec (Vec3d )
50- import "opencv" OpenCV.Exception
5151import "this" OpenCV.Extra.Internal.C.Inline ( openCvExtraCtx )
5252import "this" OpenCV.Extra.Internal.C.Types
5353import "opencv" OpenCV.Internal
@@ -490,19 +490,45 @@ getPredefinedDictionary name =
490490
491491{-| Draw a ChArUco board, ready to be printed and used for calibration/marke
492492detection.
493+
494+ Example:
495+
496+ @
497+ drawChArUcoBoardImg
498+ :: forall (w :: Nat) (h :: Nat)
499+ . (w ~ 500, h ~ 500)
500+ => Mat ('S '[ 'S h, 'S w]) ('S 1) ('S Word8)
501+ drawChArUcoBoardImg =
502+ drawChArUcoBoard charucoBoard (Proxy :: Proxy w) (Proxy :: Proxy h)
503+ where
504+ charucoBoard :: ChArUcoBoard
505+ charucoBoard = createChArUcoBoard 10 10 20 5 dictionary
506+
507+ dictionary :: Dictionary
508+ dictionary = getPredefinedDictionary DICT_7X7_1000
509+ @
510+
511+ <<doc/generated/examples/drawChArUcoBoardImg.png drawChArUcoBoardImg>>
493512-}
494- drawChArUcoBoard :: ChArUcoBoard -> Mat ('S '[h , w ]) ('S 1 ) depth
495- drawChArUcoBoard charucoBoard = unsafePerformIO $ do
513+ drawChArUcoBoard
514+ :: (ToInt32 w , ToInt32 h )
515+ => ChArUcoBoard
516+ -> w -- ^ width
517+ -> h -- ^ height
518+ -> Mat ('S '[DSNat h , DSNat w ]) ('S 1 ) ('S Word8 )
519+ drawChArUcoBoard charucoBoard width height = unsafePerformIO $ do
496520 dst <- newEmptyMat
497521 withPtr charucoBoard $ \ c'board ->
498522 withPtr dst $ \ dstPtr ->
499523 [C. block | void {
500524 Mat & board = * $(Mat * dstPtr);
501525 Ptr<CharucoBoard> & charucoBoard = *$(Ptr_CharucoBoard * c'board);
502- charucoBoard->draw(cv::Size(500, 500 ), board);
526+ charucoBoard->draw(cv::Size($(int32_t w), $(int32_t h) ), board);
503527 }|]
504528 pure (unsafeCoerceMat dst)
505-
529+ where
530+ w = toInt32 width
531+ h = toInt32 height
506532
507533--------------------------------------------------------------------------------
508534withPtrs
0 commit comments