Skip to content

Commit

Permalink
unsafePerformIO houghLinesP
Browse files Browse the repository at this point in the history
I'm sure there's a good reason it's in Prim,
but I don't have time right now.
  • Loading branch information
davetapley committed Nov 15, 2018
1 parent 206b6d8 commit 35e1a63
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/TilePositioner.hs
Expand Up @@ -13,6 +13,7 @@ import OpenCV as CV
import OpenCV.Extra.XFeatures2d
import OpenCV.Internal.C.Types
import OpenCV.ImgProc.FeatureDetection
import System.IO.Unsafe ( unsafePerformIO )

import Loop
import Track
Expand Down Expand Up @@ -48,8 +49,8 @@ type EdgeMat = Mat ('S ['D, 'D]) ('S 1) ('S Word8)
edges :: FrameMat -> EdgeMat
edges frame = exceptError $ canny 30 200 Nothing CannyNormL1 frame

lines :: (PrimMonad m) => FrameMat -> m (Vector (LineSegment Int32))
lines frame = do
lines :: FrameMat -> Vector (LineSegment Int32)
lines frame = unsafePerformIO $ do
imgM <- CV.thaw (edges frame)
exceptErrorM $ houghLinesP 1 (pi / 180) 80 (Just 30) (Just 10) imgM

Expand Down
2 changes: 1 addition & 1 deletion src/TilePositionerDebug.hs
Expand Up @@ -37,7 +37,7 @@ showHough t frame = exceptError $ do
let [h, w] = miShape . matInfo $ frame
withMatM (h ::: w ::: Z) (Proxy :: Proxy 3) (Proxy :: Proxy Word8) white $ \imgM -> do
void $ matCopyToM imgM zero edgesBgr Nothing
lines' <- lines frame
let lines' = lines frame
for_ lines' $ \lineSegment -> line imgM (lineSegmentStart lineSegment) (lineSegmentStop lineSegment) red 2 LineType_8 0

imgG <- cvtColor bgr gray frame
Expand Down
2 changes: 1 addition & 1 deletion test/Spec.hs
Expand Up @@ -163,7 +163,7 @@ tilePositionerMinRadius =

tilePositionerLines :: Assertion
tilePositionerLines = do
tpLines <- TP.lines idleNoCarsRotated
let tpLines = TP.lines idleNoCarsRotated
V.length tpLines @?= 38

tilePositionerCircles :: Assertion
Expand Down

0 comments on commit 35e1a63

Please sign in to comment.