@@ -35,6 +35,7 @@ import "opencv" OpenCV.Internal.Exception
35
35
import "base" Control.Monad (guard )
36
36
import "primitive" Control.Monad.Primitive
37
37
import "base" Data.Monoid ((<>) )
38
+ import "base" Data.Word ( Word8 )
38
39
import qualified "vector" Data.Vector.Storable as SV
39
40
import "base" Foreign.C
40
41
import "base" Foreign.ForeignPtr (ForeignPtr , withForeignPtr )
@@ -47,7 +48,6 @@ import qualified "inline-c" Language.C.Inline.Unsafe as CU
47
48
import "linear" Linear
48
49
import "opencv" OpenCV
49
50
import "opencv" OpenCV.Core.Types.Vec (Vec3d )
50
- import "opencv" OpenCV.Exception
51
51
import "this" OpenCV.Extra.Internal.C.Inline ( openCvExtraCtx )
52
52
import "this" OpenCV.Extra.Internal.C.Types
53
53
import "opencv" OpenCV.Internal
@@ -490,19 +490,45 @@ getPredefinedDictionary name =
490
490
491
491
{-| Draw a ChArUco board, ready to be printed and used for calibration/marke
492
492
detection.
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>>
493
512
-}
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
496
520
dst <- newEmptyMat
497
521
withPtr charucoBoard $ \ c'board ->
498
522
withPtr dst $ \ dstPtr ->
499
523
[C. block | void {
500
524
Mat & board = * $(Mat * dstPtr);
501
525
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);
503
527
}|]
504
528
pure (unsafeCoerceMat dst)
505
-
529
+ where
530
+ w = toInt32 width
531
+ h = toInt32 height
506
532
507
533
--------------------------------------------------------------------------------
508
534
withPtrs
0 commit comments