8000 Add drawChArUcoBoard · LumiGuide/haskell-opencv@978d3fa · GitHub
[go: up one dir, main page]

Skip to content

Commit 978d3fa

Browse files
committed
Add drawChArUcoBoard
1 parent 7f09fb3 commit 978d3fa

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

opencv-extra/src/OpenCV/Extra/ArUco.hs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module OpenCV.Extra.ArUco
1717
-- * ChArUco markers
1818
, ChArUcoBoard
1919
, createChArUcoBoard
20+
, drawChArUcoBoard
2021

2122
-- ** Detecting markers
2223
, interpolateChArUcoMarkers
@@ -48,6 +49,7 @@ import "this" OpenCV.Extra.Internal.C.Inline ( openCvExtraCtx )
4849
import "this" OpenCV.Extra.Internal.C.Types
4950
import "opencv" OpenCV.Internal
5051
import "opencv" OpenCV.Internal.C.Types
52+
import "opencv" OpenCV.Internal.Core.Types.Mat
5153
import "base" System.IO.Unsafe
5254
import qualified "vector" Data.Vector.Storable as SV
5355

@@ -485,6 +487,23 @@ getPredefinedDictionary name =
485487
case name of
486488
DICT_7X7_1000 -> [C.pure| int { DICT_7X7_1000 } |]
487489

490+
491+
{-| Draw a ChArUco board, ready to be printed and used for calibration/marke
492+
detection.
493+
-}
494+
drawChArUcoBoard :: ChArUcoBoard -> Mat ('S '[h, w]) ('S 1) depth
495+
drawChArUcoBoard charucoBoard = unsafePerformIO $ do
496+
dst <- newEmptyMat
497+
withPtr charucoBoard $ \c'board ->
498+
withPtr dst $ \dstPtr ->
499+
[C.block| void {
500+
Mat & board = * $(Mat * dstPtr);
501+
Ptr<CharucoBoard> & charucoBoard = *$(Ptr_CharucoBoard * c'board);
502+
charucoBoard->draw(cv::Size(500, 500), board);
503+
}|]
504+
pure (unsafeCoerceMat dst)
505+
506+
488507
--------------------------------------------------------------------------------
489508
withPtrs
490509
:: WithPtr a

0 commit comments

Comments
 (0)
0