cv-combinators 0.1.2 → 0.1.2.1
raw patch · 2 files changed
+35/−12 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- AI.CV.ImageProcessors: capture :: IO (Ptr CvCapture) -> ImageSource
- AI.CV.ImageProcessors: imageProcessor :: (Ptr IplImage -> Ptr IplImage -> IO (Ptr IplImage)) -> (Ptr IplImage -> IO (Ptr IplImage)) -> ImageProcessor
+ AI.CV.ImageProcessors: type Image = PImage
- AI.CV.ImageProcessors: drawRects :: IOProcessor (Ptr IplImage, [CvRect]) (Ptr IplImage)
+ AI.CV.ImageProcessors: drawRects :: IOProcessor (Image, [CvRect]) Image
- AI.CV.ImageProcessors: haarDetect :: String -> Double -> Int -> HaarDetectFlag -> CvSize -> IOProcessor (Ptr IplImage) [CvRect]
+ AI.CV.ImageProcessors: haarDetect :: String -> Double -> Int -> HaarDetectFlag -> CvSize -> IOProcessor Image [CvRect]
- AI.CV.ImageProcessors: type ImageProcessor = IOProcessor (Ptr IplImage) (Ptr IplImage)
+ AI.CV.ImageProcessors: type ImageProcessor = IOProcessor Image Image
- AI.CV.ImageProcessors: type ImageSink = IOSink (Ptr IplImage)
+ AI.CV.ImageProcessors: type ImageSink = IOSink Image
- AI.CV.ImageProcessors: type ImageSource = IOSource () (Ptr IplImage)
+ AI.CV.ImageProcessors: type ImageSource = IOSource () Image
Files
- cv-combinators.cabal +1/−1
- src/AI/CV/ImageProcessors.hs +34/−11
cv-combinators.cabal view
@@ -1,5 +1,5 @@ name: cv-combinators-version: 0.1.2+version: 0.1.2.1 license: BSD3 maintainer: Noam Lewis <jones.noamle@gmail.com> bug-reports: mailto:jones.noamle@gmail.com
src/AI/CV/ImageProcessors.hs view
@@ -24,11 +24,31 @@ -- -- The last expression is a processor that captures frames from camera and displays edge-detected version in the window. ---------------------------------------------------------------module AI.CV.ImageProcessors where+module AI.CV.ImageProcessors + (ImageSink, + ImageSource, + ImageProcessor, + Image, + + camera,+ videoFile, + window, + resize,+ dilate,+ canny,++ haarDetect,++ drawRects,++ runTill, runTillKeyPressed, keyPressed) where++ import AI.CV.Processor +import AI.CV.OpenCV.Types(PImage) import qualified AI.CV.OpenCV.CV as CV import qualified AI.CV.OpenCV.CxCore as CxCore import qualified AI.CV.OpenCV.HighGui as HighGui@@ -37,12 +57,15 @@ import Foreign.Ptr -type ImageSink = IOSink (Ptr IplImage) -type ImageSource = IOSource () (Ptr IplImage)-type ImageProcessor = IOProcessor (Ptr IplImage) (Ptr IplImage) +type Image = PImage +type ImageSink = IOSink Image+type ImageSource = IOSource () Image+type ImageProcessor = IOProcessor Image Image ++ ------------------------------------------------------------------ -- | Some general utility functions for use with Processors and OpenCV @@ -98,15 +121,15 @@ -- Note: windows with the same index will be the same window....is this ok? window :: Int -> ImageSink window num = processor procFunc allocFunc (do return) (do return)- where procFunc :: (Ptr IplImage -> () -> IO ())+ where procFunc :: (Image -> () -> IO ()) procFunc src x = (HighGui.showImage (fromIntegral num) src) >> (return x) - allocFunc :: (Ptr IplImage -> IO ())+ allocFunc :: (Image -> IO ()) allocFunc _ = HighGui.newWindow (fromIntegral num) True ------------------------------------------------------------------ -- | 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 :: (Image -> Image -> IO Image) -> (Image -> IO Image) -> ImageProcessor imageProcessor procFunc allocFunc = processor procFunc allocFunc (do return) (CxCore.cvReleaseImage) @@ -163,16 +186,16 @@ -> Int -- ^ min neighbors -> CV.HaarDetectFlag -- ^ flags -> CvSize -- ^ min size- -> IOProcessor (Ptr IplImage) [CvRect]+ -> IOProcessor Image [CvRect] haarDetect cascadeFileName scaleFactor minNeighbors flags minSize = processor procFunc allocFunc convFunc freeFunc - where procFunc :: (Ptr IplImage) -> ([CvRect], (Ptr CvHaarClassifierCascade, Ptr CvMemStorage)) + where procFunc :: Image -> ([CvRect], (Ptr CvHaarClassifierCascade, Ptr CvMemStorage)) -> IO ([CvRect], (Ptr CvHaarClassifierCascade, Ptr CvMemStorage)) procFunc image (_, x@(cascade, storage)) = do seqP <- CV.cvHaarDetectObjects image cascade storage (realToFrac scaleFactor) (fromIntegral minNeighbors) flags minSize recs <- CxCore.seqToList seqP return (recs, x) - allocFunc :: Ptr IplImage -> IO ([CvRect], (Ptr CvHaarClassifierCascade, Ptr CvMemStorage))+ allocFunc :: Image -> IO ([CvRect], (Ptr CvHaarClassifierCascade, Ptr CvMemStorage)) allocFunc _ = do storage <- CxCore.cvCreateMemStorage 0 (cascade, name) <- CxCore.cvLoad cascadeFileName storage Nothing@@ -192,7 +215,7 @@ -- need a datatype that combines the shape types for that. -- | OpenCV's cvRectangle, currently without width, color or line type control-drawRects :: IOProcessor (Ptr IplImage, [CvRect]) (Ptr IplImage)+drawRects :: IOProcessor (Image, [CvRect]) Image drawRects = processor procFunc (CxCore.cvCloneImage . fst) (do return) CxCore.cvReleaseImage where procFunc (src,rects) dst = do CxCore.cvCopy src dst