Browse files

runNT_ , gpu match example

  • Loading branch information...
1 parent 5446c76 commit 2dc8f3a37949769b702a2175884ceea497526e43 @albertoruiz committed Mar 25, 2012
View
20 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'
+
View
4 packages/contrib/gpu/examples/siftgpu.hs
@@ -4,7 +4,9 @@ import Vision.GUI
import ImagProc
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 ]
View
14 packages/gui/src/Vision/GUI/Arrow.hs
@@ -15,7 +15,8 @@ Arrow interface.
-----------------------------------------------------------------------------
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
import Control.Concurrent (forkIO)
@@ -28,6 +29,7 @@ import Control.Monad
import Data.Either(lefts,rights)
import System.IO.Unsafe(unsafeInterleaveIO)
import Control.Concurrent
+import Graphics.UI.GLUT (mainLoopEvent)
--------------------------------------------------------------------------------
@@ -140,6 +142,16 @@ runT_ gcam gt = runIt $ do
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]
-- ^ run a camera generator on a transformer, returning the results in a lazy list
runT gcam gt = do

0 comments on commit 2dc8f3a

Please sign in to comment.