-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Functional Combinators for Computer Vision -- -- Initial version; using the HOpenCV package as a backend. -- -- Provides a functional combinator library, naturally expressed as Arrow -- instances (but also Category, Functor and Applicative). -- -- Read the module docs for more information. See the test program -- (src/Test.hs) for example usage. @package cv-combinators @version 0.1.1 -- | Framework for expressing monadic actions that require initialization -- and finalizers. This module provides a *functional* interface for -- defining and chaining a series of processors. -- -- Motivating example: bindings to C libraries that use functions such -- as: f(foo *src, foo *dst), where the pointer dst must be -- pre-allocated. In this case we normally do: -- -- foo *dst = allocateFoo(); ... while (something) { f(src, dst); ... } -- releaseFoo(dst); -- -- You can use the runUntil function below to emulate that loop. -- -- Processor is an instance of Category, Functor, Applicative and Arrow. module AI.CV.Processor -- | The type of Processors -- -- The semantic model is: -- --
-- [[ Processor m o a b ]] = a -> b ---- -- The idea is that the monad m is usually IO, and that a and b are -- usually pointers. It is meant for functions that require a -- pre-allocated output pointer to operate. -- --
-- win = window 0 -- The number is essentially a label for the window -- cam = camera 0 -- Autodetect camera -- edge = canny 30 190 3 -- Edge detecting processor using canny operator -- -- test = win . edge . cam -- A processor that captures frames from camera and displays edge-detected version in the window. --module AI.CV.ImageProcessors type ImageSink = Processor IO (Ptr IplImage) () type ImageSource = Processor IO () (Ptr IplImage) type ImageProcessor = Processor IO (Ptr IplImage) (Ptr IplImage) -- | Some general utility functions for use with Processors and OpenCV -- -- Predicate for pressed keys keyPressed :: (Show a) => a -> IO Bool -- | Runs the processor until a predicate is true, for predicates, and -- processors that take () as input (such as chains that start with a -- camera). runTill :: (Monad m) => Processor m () b -> (b -> m Bool) -> m b -- | Name (and type) says it all. runTillKeyPressed :: (Show a) => Processor IO () a -> IO () -- | A capture device, using OpenCV's HighGui lib's cvCreateCameraCapture -- should work with most webcames. See OpenCV's docs for information. -- This processor outputs the latest image from the camera at each -- invocation. camera :: Int -> ImageSource -- | A window that displays images. Note: windows with the same index will -- be the same window....is this ok? window :: Int -> ImageSink -- | A convenience function for constructing a common type of processors -- that work exclusively on images imageProcessor :: (Ptr IplImage -> Ptr IplImage -> IO (Ptr IplImage)) -> (Ptr IplImage -> IO (Ptr IplImage)) -> ImageProcessor -- | OpenCV's cvResize resize :: Int -> Int -> InterpolationMethod -> ImageProcessor -- | OpenCV's cvDilate dilate :: Int -> ImageProcessor -- | OpenCV's cvCanny canny :: Int -> Int -> Int -> ImageProcessor -- | Wrapper for OpenCV's cvHaarDetectObjects and the surrounding required -- things (mem storage, cascade loading, etc). haarDetect :: String -> Double -> Int -> HaarDetectFlag -> CvSize -> Processor IO (Ptr IplImage) [CvRect] -- | OpenCV's cvRectangle, currently without width, color or line type -- control drawRects :: Processor IO (Ptr IplImage, [CvRect]) (Ptr IplImage)