Skip to content

Commit

Permalink
runNT_ , gpu match example
Browse files Browse the repository at this point in the history
  • Loading branch information
albertoruiz committed Mar 25, 2012
1 parent 5446c76 commit 2dc8f3a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
20 changes: 20 additions & 0 deletions packages/contrib/gpu/examples/match.hs
@@ -0,0 +1,20 @@
import Vision.GUI
import ImagProc
import ImagProc.GPU.SIFT
import Util.Misc(debug)

getView m = clickKeep "click to set base view" (const id) (g m) Nothing

main = do
prepare
match <- getMatchGPU
runNT_ camera $ sift grayscale >>> getView match


g match ((x,psx),(s,pss)) = Draw [ Draw (rgb x)
, text (Point 0 0) (show (length psx, length matches))
, color red matches ]
where
matches' = match 0.7 0.8 psx pss
matches = map (\[a,b]-> (Segment (ipPosition (psx!! a)) (ipPosition(pss!! b)))) matches'

4 changes: 3 additions & 1 deletion packages/contrib/gpu/examples/siftgpu.hs
Expand Up @@ -4,7 +4,9 @@ import Vision.GUI
import ImagProc import ImagProc
import ImagProc.GPU.SIFT import ImagProc.GPU.SIFT


main = run $ sift grayscale >>> observe "SIFT GPU" sh main = do
prepare
runNT_ camera $ sift grayscale >>> observe "SIFT GPU" sh


sh (x, feats) = Draw [ Draw (rgb x), color yellow feats ] sh (x, feats) = Draw [ Draw (rgb x), color yellow feats ]


14 changes: 13 additions & 1 deletion packages/gui/src/Vision/GUI/Arrow.hs
Expand Up @@ -15,7 +15,8 @@ Arrow interface.
----------------------------------------------------------------------------- -----------------------------------------------------------------------------


module Vision.GUI.Arrow( module Vision.GUI.Arrow(
runITrans, runT_, runT, runS, ITrans(ITrans), transUI, arrL, (@@@), delay', arrIO runITrans, runT_, runT, runS, ITrans(ITrans), transUI, arrL, (@@@), delay', arrIO,
runNT_,
)where )where


import Control.Concurrent (forkIO) import Control.Concurrent (forkIO)
Expand All @@ -28,6 +29,7 @@ import Control.Monad
import Data.Either(lefts,rights) import Data.Either(lefts,rights)
import System.IO.Unsafe(unsafeInterleaveIO) import System.IO.Unsafe(unsafeInterleaveIO)
import Control.Concurrent import Control.Concurrent
import Graphics.UI.GLUT (mainLoopEvent)


-------------------------------------------------------------------------------- --------------------------------------------------------------------------------


Expand Down Expand Up @@ -140,6 +142,16 @@ runT_ gcam gt = runIt $ do
g !_x = putStr "" g !_x = putStr ""




runNT_ :: IO (IO a) -> ITrans a b -> IO ()
-- ^ run process without fork, (needs explicit "prepare").
-- This is currently required for certain GPU applications.
runNT_ gcam gt = do
bs <- runS gcam gt
mapM_ g bs
where
g !_x = putStr "" >> mainLoopEvent


runT :: IO (IO a) -> ITrans a b -> IO [b] runT :: IO (IO a) -> ITrans a b -> IO [b]
-- ^ run a camera generator on a transformer, returning the results in a lazy list -- ^ run a camera generator on a transformer, returning the results in a lazy list
runT gcam gt = do runT gcam gt = do
Expand Down

0 comments on commit 2dc8f3a

Please sign in to comment.