packages feed

CV 0.3.5.4 → 0.3.6.0

raw patch · 14 files changed

+150/−71 lines, 14 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ CV.Bindings.Types: cvSeqToVector :: (Unbox a, Storable a) => Ptr C'CvSeq -> IO (Vector a)
+ CV.Features: mkSURFParams :: Double -> Int -> Int -> Bool -> SURFParams
+ CV.Filters: instance HasMedianFiltering (Image GrayScale D32)
+ CV.Transforms: Default :: HomographyMethod
+ CV.Transforms: LMeds :: HomographyMethod
+ CV.Transforms: Ransac :: HomographyMethod
+ CV.Transforms: cvFindHomography :: (Ptr ()) -> ((Ptr ()) -> ((Ptr ()) -> (CInt -> (CDouble -> ((Ptr ()) -> (IO CInt))))))
+ CV.Transforms: data HomographyMethod
+ CV.Transforms: getHomography' :: Matrix Float -> Matrix Float -> HomographyMethod -> Float -> Matrix Float
+ CV.Transforms: instance Enum HomographyMethod
+ Utils.GeometryClass: instance Point2D (Float, Float)
+ Utils.GeometryClass: ipt :: (Point2D a, RealFrac (ELP a)) => a -> (Int, Int)
- CV.Matrix: create :: Exists a => Args a -> a
+ CV.Matrix: create :: Exists a => Args a -> IO a

Files

CV.cabal view
@@ -1,5 +1,5 @@ Name:				 CV-Version:             0.3.5.4+Version:             0.3.6.0 Description:         OpenCV Bindings License:             GPL License-file:        LICENSE@@ -18,6 +18,8 @@                       <http://aleator.github.com/CV/>                      .                      Changelog.+                     0.3.6.0 - Critical referential transparency bug fix.+                     .                      0.3.5.4 - Bug fixes and preliminary compatability with opencv 2.4                      .                      0.3.5 - Many new wrappers, clean ups and other fixes.
CV/Bindings/Types.hsc view
@@ -9,6 +9,7 @@ import Foreign.Marshal.Array import Utils.GeometryClass import Utils.Rectangle+import qualified Data.Vector.Unboxed as U import GHC.Float  #strict_import@@ -87,6 +88,15 @@    dest <- mallocArray (fromIntegral $ c'CvSeq'total seq)    c'extractCVSeq ptrseq (castPtr dest)    peekArray (fromIntegral $ c'CvSeq'total seq) dest++-- | A version of `cvSeqToList` that returns a vector instead. All the warnings of `CvSeqToList` apply.+cvSeqToVector :: (U.Unbox a, Storable a) => Ptr C'CvSeq -> IO (U.Vector a)+cvSeqToVector ptrseq = do+   seq <- peek ptrseq+   dest <- mallocArray (fromIntegral $ c'CvSeq'total seq)+   c'extractCVSeq ptrseq (castPtr dest)+   U.generateM (fromIntegral $ c'CvSeq'total seq) (peekElemOff dest)+   -- peekArray (fromIntegral $ c'CvSeq'total seq) dest   #starttype CvRect
CV/Features.hs view
@@ -1,5 +1,5 @@ {-#LANGUAGE RecordWildCards, ScopedTypeVariables, TypeFamilies#-}-module CV.Features (SURFParams, defaultSURFParams, getSURF+module CV.Features (SURFParams, defaultSURFParams, mkSURFParams, getSURF #ifndef OpenCV24                    ,getMSER, MSERParams, mkMSERParams, defaultMSERParams #endif
CV/Filters.chs view
@@ -132,6 +132,9 @@ instance HasMedianFiltering (Image GrayScale D8) where     median = median' +instance HasMedianFiltering (Image GrayScale D32) where+    median a = unsafeImageTo32F . median' a . unsafeImageTo8Bit+ instance HasMedianFiltering (Image RGB D8) where     median = median' @@ -156,9 +159,9 @@ -- (x,y) within (0,0) and (w,h) convolve2D :: (Point2D anchor, ELP anchor ~ Int) =>                Matrix D32 -> anchor -> Image GrayScale D32 -> Image GrayScale D32-convolve2D kernel anchor image = unsafePerformIO $ -                                      let result = emptyCopy image-                                      in withGenImage image $ \c_img->+convolve2D kernel anchor image = unsafePerformIO $ do+                                      result <- create (getSize image)+                                      withGenImage image $ \c_img->                                          withGenImage result $ \c_res->                                          withMatPtr kernel $ \c_mat ->                                          with (convertPt anchor) $ \c_pt ->
CV/Fitting.hs view
@@ -52,7 +52,7 @@  -- | Fit a minimum area rectangle over a set of points minAreaRect :: Matrix (Float,Float) -> C'CvBox2D-minAreaRect pts = unsafePerformIO $ +minAreaRect pts = unsafePerformIO $    withMatPtr pts $ \cMat ->    with (C'CvBox2D (C'CvPoint2D32f 0 0) (C'CvSize2D32f 0 0) 0) $ \result -> do            c'wrapMinAreaRect2 (castPtr cMat) nullPtr result@@ -60,7 +60,7 @@  -- | Calculate the minimum axis-aligned bounding rectangle of given points. boundingRect :: Matrix (Float,Float) -> C'CvRect-boundingRect pts = unsafePerformIO $ +boundingRect pts = unsafePerformIO $    withMatPtr pts $ \cMat ->    with (C'CvRect 0 0 0 0) $ \result -> do            c'wrapBoundingRect (castPtr cMat) 0 result@@ -68,22 +68,22 @@  -- | Calculate the minimum enclosing circle of a point set. boundingCircle :: (ELP a ~ Double, Point2D a) => Matrix (Float,Float) -> (a, Double)-boundingCircle pts = unsafePerformIO $ +boundingCircle pts = unsafePerformIO $    withMatPtr pts $ \cMat ->-   with 0         $ \cRadius ->   +   with 0         $ \cRadius ->    with (C'CvPoint2D32f 0 0 ) $ \result -> do            c'cvMinEnclosingCircle (castPtr cMat) result cRadius            (,) <$> (convertPt <$> peek result) <*> (realToFrac <$> peek cRadius)  -- | Calculcate the clockwise convex hull of a point set convexHull :: Matrix (Float,Float) -> Matrix (Float,Float)-convexHull pts =  - let res = create (getSize pts) :: Matrix (Float,Float)- in  unsafePerformIO $+convexHull pts = do+ unsafePerformIO $ do+     res <- create (getSize pts) :: IO (Matrix (Float,Float))      withMatPtr pts $ \cMat ->-     withMatPtr res $ \cRes ->-     withNewMemory  $ \ptr_mem -> do-     with (C'CvPoint2D32f 0 0 ) $ \result -> do+      withMatPtr res $ \cRes ->+       withNewMemory  $ \ptr_mem -> do+        with (C'CvPoint2D32f 0 0 ) $ \result -> do              c'cvConvexHull2 (castPtr cMat) (castPtr cRes) c'CV_CLOCKWISE 1              return res 
CV/HoughTransform.hs view
@@ -66,7 +66,7 @@  houghLinesStandard :: Image GrayScale D8 -> Int -> Double -> Double -> Int -> [(CFloat,CFloat)] houghLinesStandard img n ρ θ t = unsafePerformIO $ do-    let m :: Matrix (CFloat,CFloat) = create (1,n)+    m :: Matrix (CFloat,CFloat) <- create (1,n)     withMatPtr m $ \c_m ->         withImage img $ \c_img ->             c'cvHoughLines2 (castPtr c_img) (castPtr c_m) c'CV_HOUGH_STANDARD ρ θ t 0 0@@ -75,7 +75,7 @@ houghLinesProbabilistic :: Image GrayScale D8 -> Int -> Double -> Double -> Int -> Double -> Double                                 -> [(CInt,CInt,CInt,CInt)] houghLinesProbabilistic img n ρ θ t minLength maxGap = unsafePerformIO $ do-    let m :: Matrix (CInt,CInt,CInt,CInt) = create (1,n)+    m :: Matrix (CInt,CInt,CInt,CInt) <- create (1,n)     withMatPtr m $ \c_m ->         withImage img $ \c_img ->             c'cvHoughLines2 (castPtr c_img) (castPtr c_m) c'CV_HOUGH_PROBABILISTIC ρ θ t minLength maxGap@@ -84,7 +84,7 @@ houghLinesMultiscale :: Image GrayScale D8 -> Int -> Double -> Double -> Int -> Double -> Double                                 -> [(CFloat,CFloat)] houghLinesMultiscale img n ρ θ t distDiv angleDiv = unsafePerformIO $ do-    let m :: Matrix (CFloat,CFloat) = create (1,n)+    m :: Matrix (CFloat,CFloat) <- create (1,n)     withMatPtr m $ \c_m ->         withImage img $ \c_img ->             c'cvHoughLines2 (castPtr c_img) (castPtr c_m) c'CV_HOUGH_MULTI_SCALE ρ θ t distDiv angleDiv@@ -92,7 +92,7 @@  houghCirclesGradient :: Image GrayScale D8 -> Int -> Double -> Double -> Double -> Double -> Int -> Int -> [(CFloat, CFloat, CFloat)] houghCirclesGradient img n dp minDist cannyThresh accumThresh minRad maxRad = unsafePerformIO $ do-    let m :: Matrix (CFloat,CFloat,CFloat) = create (1,n)+    m :: Matrix (CFloat,CFloat,CFloat) <- create (1,n)     withMatPtr m $ \c_m ->         withImage img $ \c_img ->             c'cvHoughCircles (castPtr c_img) (castPtr c_m) c'CV_HOUGH_GRADIENT dp minDist cannyThresh accumThresh minRad maxRad
CV/Matrix.hs view
@@ -52,51 +52,51 @@  class Exists a where     type Args a :: *-    create :: Args a -> a+    create :: Args a -> IO a  instance Exists (Matrix Float) where     type Args (Matrix Float) = (Int,Int)-    create (r,c) = unsafePerformIO $ creatingMat (c'cvCreateMat r c c'CV_32FC1)+    create (r,c) = creatingMat (c'cvCreateMat r c c'CV_32FC1)  instance Exists (Matrix Int) where     type Args (Matrix Int) = (Int,Int)-    create (r,c) = unsafePerformIO $ creatingMat (c'cvCreateMat r c c'CV_32SC1)+    create (r,c) = creatingMat (c'cvCreateMat r c c'CV_32SC1)  instance Exists (Matrix (Int,Int)) where     type Args (Matrix (Int,Int)) = (Int,Int)-    create (r,c) = unsafePerformIO $ creatingMat (c'cvCreateMat r c c'CV_32SC2)+    create (r,c) = creatingMat (c'cvCreateMat r c c'CV_32SC2)  instance Exists (Matrix (Float,Float)) where     type Args (Matrix (Float,Float)) = (Int,Int)-    create (r,c) = unsafePerformIO $ creatingMat (c'cvCreateMat r c c'CV_32FC2)+    create (r,c) = creatingMat (c'cvCreateMat r c c'CV_32FC2)  instance Exists (Matrix (CFloat,CFloat)) where     type Args (Matrix (CFloat,CFloat)) = (Int,Int)-    create (r,c) = unsafePerformIO $ creatingMat (c'cvCreateMat r c c'CV_32FC2)+    create (r,c) = creatingMat (c'cvCreateMat r c c'CV_32FC2)  instance Exists (Matrix (Float,Float,Float)) where     type Args (Matrix (Float,Float,Float)) = (Int,Int)-    create (r,c) = unsafePerformIO $ creatingMat (c'cvCreateMat r c c'CV_32FC3)+    create (r,c) = creatingMat (c'cvCreateMat r c c'CV_32FC3)  instance Exists (Matrix (CFloat,CFloat,CFloat)) where     type Args (Matrix (CFloat,CFloat,CFloat)) = (Int,Int)-    create (r,c) = unsafePerformIO $ creatingMat (c'cvCreateMat r c c'CV_32FC3)+    create (r,c) = creatingMat (c'cvCreateMat r c c'CV_32FC3)  instance Exists (Matrix (Int,Int,Int,Int)) where     type Args (Matrix (Int,Int,Int,Int)) = (Int,Int)-    create (r,c) = unsafePerformIO $ creatingMat (c'cvCreateMat r c c'CV_32SC4)+    create (r,c) = creatingMat (c'cvCreateMat r c c'CV_32SC4)  instance Exists (Matrix (CInt,CInt,CInt,CInt)) where     type Args (Matrix (CInt,CInt,CInt,CInt)) = (Int,Int)-    create (r,c) = unsafePerformIO $ creatingMat (c'cvCreateMat r c c'CV_32SC4)+    create (r,c) = creatingMat (c'cvCreateMat r c c'CV_32SC4)  instance Exists (Matrix Double) where     type Args (Matrix Double) = (Int,Int)-    create (r,c) = unsafePerformIO $ creatingMat (c'cvCreateMat r c c'CV_64FC1)+    create (r,c) = creatingMat (c'cvCreateMat r c c'CV_64FC1)  instance Exists (Matrix (Double,Double)) where     type Args (Matrix (Double,Double)) = (Int,Int)-    create (r,c) = unsafePerformIO $ creatingMat (c'cvCreateMat r c c'CV_64FC2)+    create (r,c) = creatingMat (c'cvCreateMat r c c'CV_64FC2)  instance Sized (Matrix a) where     type Size (Matrix a) = (Int,Int)@@ -107,14 +107,14 @@  -- | Create an empty matrix of given dimensions emptyMatrix :: Exists (Matrix a) => Args (Matrix a) -> Matrix a-emptyMatrix a = create a+emptyMatrix = unsafePerformIO . create  -- | Create an identity matrix identity :: (Num a, Sized (Matrix a), Args (Matrix a) ~ (Int,Int),  Size (Matrix a) ~ (Int,Int),  Storable a, Exists (Matrix a)) =>              (Matrix a) -> Matrix a identity a = unsafePerformIO $ do-             let res = create (getSize a)-                 (rows,cols) = getSize a+             res <- create (getSize a)+             let (rows,cols) = getSize a              sequence_ [put res row col 1                        | row <- [0..rows-1]                        | col <- [0..cols-1]]@@ -123,7 +123,7 @@ -- | Transpose a matrix. Does not do complex conjugation for complex matrices transpose :: (Exists (Matrix a), Args (Matrix a) ~ Size (Matrix a)) => Matrix a -> Matrix a transpose m@(Matrix f_m) = unsafePerformIO $ do-                 let res@(Matrix f_c) = create (getSize m)+                 res@(Matrix f_c) <- create (getSize m)                  withForeignPtr f_m $ \c_m ->                   withForeignPtr f_c $ c'cvTranspose c_m                  return res@@ -131,7 +131,7 @@ -- | Convert a rotation vector to a rotation matrix (1x3 -> 3x3) rodrigues2 :: (Exists (Matrix a), Args (Matrix a) ~ Size (Matrix a)) => Matrix a -> Matrix a rodrigues2 m@(Matrix f_m) = unsafePerformIO $ do-                 let res@(Matrix f_c) = create (3,3)+                 res@(Matrix f_c) <- create (3,3)                  withForeignPtr f_m $ \c_m ->                   withForeignPtr f_c $ \c_c -> c'cvRodrigues2 c_m c_c nullPtr                  return res@@ -142,7 +142,7 @@ mxm m1@(Matrix a_m) m2@(Matrix b_m) = unsafePerformIO $ do                  let (w1,h1) = getSize m1                      (w2,h2) = getSize m2-                     res@(Matrix f_c) = create (w1,h2)+                 res@(Matrix f_c) <-create (w1,h2)                  when (h1 /= w2) . error  $                     "Matrix dimensions do not match for multiplication: "                     ++show (w1,h1)
CV/Transforms.chs view
@@ -3,13 +3,14 @@ -- |Various image transformations from opencv and other sources. module CV.Transforms  where -import CV.Image+import CV.Image as I  import Foreign.Ptr import Foreign.C.Types import Foreign.Marshal.Array import System.IO.Unsafe {#import CV.Image#} import CV.ImageMathOp+import CV.Matrix as M  -- |Since DCT is valid only for even sized images, we provide a -- function to crop images to even sizes.@@ -46,7 +47,7 @@ -- |Mirror an image over a cardinal axis flip :: CreateImage (Image c d) => MirrorAxis -> Image c d -> Image c d flip axis img = unsafePerformIO $ do-                 let cl = emptyCopy img+                 cl <- I.create (getSize img)                  withGenImage img $ \cimg ->                    withGenImage cl $ \ccl -> do                     {#call cvFlip#} cimg ccl (if axis == Vertical then 0 else 1)@@ -66,7 +67,7 @@ -- |Simulate a radial distortion over an image radialDistort :: Image GrayScale D32 -> Double -> Image GrayScale D32 radialDistort img k = unsafePerformIO $ do-                       let target = emptyCopy img +                       target <- I.create (getSize img)                        withImage img $ \cimg ->                         withImage target $ \ctarget ->                          {#call radialRemap#} cimg ctarget (realToFrac k)@@ -79,7 +80,7 @@ -- |Scale an image with different ratios for axes scale :: (CreateImage (Image c D32), RealFloat a) => Interpolation -> (a,a) -> Image c D32 -> Image c D32 scale tpe (x,y) img = unsafePerformIO $ do-                    target <- create (w',h') +                    target <- I.create (w',h')                      withGenImage img $ \i ->                       withGenImage target $ \t ->                          {#call cvResize#} i t @@ -94,7 +95,7 @@ scaleToSize :: (CreateImage (Image c D32)) =>      Interpolation -> Bool -> (Int,Int) -> Image c D32 -> Image c D32 scaleToSize tpe retainRatio (w,h) img = unsafePerformIO $ do-                    target <- create (w',h') +                    target <- I.create (w',h')                      withGenImage img $ \i ->                       withGenImage target $ \t ->                          {#call cvResize#} i t @@ -128,7 +129,31 @@      src = flatten srcPts      dst = flatten dstPts +#c+enum HomographyMethod {+     Default = 0,+     Ransac  = CV_RANSAC,+     LMeds   = CV_LMEDS+     };+#endc+{#enum HomographyMethod {}#} +getHomography' :: Matrix Float -> Matrix Float -> HomographyMethod -> Float -> Matrix Float+getHomography' srcPts dstPts method ransacThreshold = +    unsafePerformIO $ do+    hmg <- M.create (3,3) :: IO (Matrix Float)+    withMatPtr srcPts  $ \c_src ->+     withMatPtr dstPts $ \c_dst ->+     withMatPtr hmg    $ \c_hmg -> do+                          {#call cvFindHomography#} +                           (castPtr c_src) +                           (castPtr c_dst) +                           (castPtr c_hmg)+                           (fromIntegral $ fromEnum method)+                           (realToFrac ransacThreshold)+                           nullPtr+                          return hmg+ --- Pyramid transforms -- |Return a copy of an image with an even size evenize :: Image channels depth -> Image channels depth@@ -176,7 +201,7 @@ -- |Downsize image by 50% efficiently. Image dimensions must be even. pyrDown ::(CreateImage (Image GrayScale a)) => Image GrayScale a -> Image GrayScale a pyrDown image = unsafePerformIO $ do-                 res <- create size +                 res <- I.create size                   withGenImage image $ \cImg ->                     withGenImage res $ \cResImg ->                       {#call cvPyrDown#} cImg cResImg cv_Gaussian@@ -188,7 +213,7 @@ -- |Enlarge image to double in each dimension. Used to recover pyramidal layers pyrUp :: (CreateImage (Image GrayScale a)) => Image GrayScale a -> Image GrayScale a pyrUp image = unsafePerformIO $ do-                 res <- create size +                 res <- I.create size                   withGenImage image $ \cImg ->                     withGenImage res $ \cResImg ->                       {#call cvPyrUp#} cImg cResImg cv_Gaussian@@ -225,7 +250,7 @@ -- |Enlarge image so, that it's size is divisible by 2^n  enlarge :: Int -> Image GrayScale D32 -> Image GrayScale D32 enlarge n img =  unsafePerformIO $ do-                   i <- create (w2,h2)+                   i <- I.create (w2,h2)                    blit i img (0,0)                    return i     where@@ -243,32 +268,19 @@ #endc {#enum DistanceType {}#} -#ifdef OpenCV24-#c-enum LabelType {-     DIST_LABEL_CCOMP = CV_DIST_LABEL_CCOMP-    ,DIST_LABEL_PIXEL = CV_DIST_LABEL_PIXEL-};-#endc-{#enum LabelType {}#}-#endif- -- |Mask sizes accepted by distanceTransform data MaskSize = M3 | M5 deriving (Eq,Ord,Enum,Show)  -- |Perform a distance transform on the image distanceTransform :: DistanceType -> MaskSize -> Image GrayScale D8 -> Image GrayScale D32 --TODO: Input should be a black and white image distanceTransform dtype maskSize source = unsafePerformIO $ do-    result :: Image GrayScale D32 <- create (getSize source)+    result :: Image GrayScale D32 <- I.create (getSize source)     withGenImage source $ \c_source ->      withGenImage result $ \c_result ->         {#call cvDistTransform #} c_source c_result                                    (fromIntegral . fromEnum $ dtype)                                    (fromIntegral . fromEnum $ maskSize)                                    nullPtr nullPtr-#ifdef OpenCV24-                                   (fromIntegral . fromEnum $ DIST_LABEL_CCOMP)-#endif     return result     -- TODO: Add handling for labels     -- TODO: Add handling for custom masks
Utils/GeometryClass.hs view
@@ -1,4 +1,4 @@-{-#LANGUAGE TypeFamilies,FlexibleInstances#-}+{-#LANGUAGE TypeFamilies,FlexibleInstances, FlexibleContexts#-} module Utils.GeometryClass where  import Utils.Rectangle@@ -14,10 +14,19 @@    pt = id    toPt = id +instance Point2D (Float,Float) where+   type ELP (Float,Float) = Float+   pt = id+   toPt = id+ instance Point2D (Double,Double) where    type ELP (Double,Double) = Double    pt = id    toPt = id++-- | Extract integer coordinates of a point+ipt :: (Point2D a,RealFrac (ELP a)) => a -> (Int,Int)+ipt = (\(x,y) -> (round x, round y)) . pt  convertPt :: (Point2D a, Point2D b, ELP a ~ ELP b) => a -> b convertPt = toPt . pt
cbits/cvWrapLEO.c view
@@ -889,8 +889,8 @@ {   CvSize imageSize = cvGetSize(dst);   double r=0; int i; int j;-  for(i=0; i<imageSize.width; ++i)-    for(j=0; j<imageSize.height; ++j) {+  for(j=0; j<imageSize.width; ++j)+    for(i=0; i<imageSize.height; ++i) {           r = FGET(src,j,i); //// cvGetReal2D(src,j,i);           FGET(dst,j,i) = atan(r);           //cvSet2D(dst,j,i,cvScalarAll(atan(r)));@@ -900,8 +900,8 @@ void calculateAtan2(IplImage *src1,IplImage *src2, IplImage *dst) {   CvSize imageSize = cvGetSize(dst);-  for(int i=0; i<imageSize.width; ++i)-    for(int j=0; j<imageSize.height; ++j) {+  for(int j=0; j<imageSize.width; ++j)+    for(int i=0; i<imageSize.height; ++i) {           double a = FGET(src1,j,i);           double b = FGET(src2,j,i);           FGET(dst,j,i) = atan2(a,b);@@ -2385,7 +2385,11 @@     CV_NEXT_SEQ_ELEM( seq->elem_size, reader ); }} -+#ifndef OpenCV24+void wrapExtractMSER( CvArr* _img, CvArr* _mask, CvSeq** contours, CvMemStorage* storage, CvMSERParams *params ){+cvExtractMSER( _img, _mask, contours, storage, *params );+};+#endif // //@-node:aleator.20051220091717:Matrix multiplication //@-all
cbits/cvWrapLEO.h view
@@ -293,9 +293,7 @@ };  #ifndef OpenCV24-void wrapExtractMSER( CvArr* _img, CvArr* _mask, CvSeq** contours, CvMemStorage* storage, CvMSERParams *params ){-cvExtractMSER( _img, _mask, contours, storage, *params );-};+void wrapExtractMSER( CvArr* _img, CvArr* _mask, CvSeq** contours, CvMemStorage* storage, CvMSERParams *params ); #endif  void wrapEllipseBox(CvArr* img, CvBox2D *box, CvScalar *color
+ examples/homography.hs view
@@ -0,0 +1,20 @@+{-# LANGUAGE ScopedTypeVariables #-}+module Main where+import qualified CV.Matrix as M+import CV.Transforms++main = do+  let source = M.fromList (5,2) [1,1+                                ,1,2+                                ,2,1+                                ,5,5+                                ,2,4]+      target = M.fromList (5,2) [1,1+                                ,1,2+                                ,2,1+                                ,5,5+                                ,1900,4]++  print (getHomography' source target Default 0.1)+  print (getHomography' source target Ransac 0.001)+  print (getHomography' source target LMeds 0.001)
+ examples/newContours.hs view
@@ -0,0 +1,11 @@+module Main where+import CV.Image+import CV.ConnectedComponents+import CV.Bindings.Types+++main = do+   Just x <- loadImage "Circle.png" >>= return . fmap unsafeImageTo8Bit+   cs <- contours x (C'CvPoint 0 0) 0 0 0+   print cs+   print "done"
examples/surf.hs view
@@ -11,9 +11,17 @@ import Utils.GeometryClass import System.Environment import System.IO.Unsafe+import CV.ColourUtils+import CV.Filters+import CV.ImageMathOp +delit i = i #- gaussian (41,41) i+ main = do-   Just x <- getArgs >>= loadImage . head+   Just x <- getArgs >>= loadImage . head >>= return +    . fmap stretchHistogram +    . fmap (gaussian (13,13))+    . fmap delit    let y = scale Area (2.2,2) . rotate (pi/2) $ x        lst  = getSURF defaultSURFParams (unsafeImageTo8Bit x) Nothing        lsty = getSURF defaultSURFParams (unsafeImageTo8Bit y) Nothing@@ -22,10 +30,12 @@   --                    | (C'CvSURFPoint c l s d h,_) <- lst   --                    , let size = C'CvSize2D32f (fromIntegral s) (fromIntegral $ s`div`2)   --                    ]-   saveImage "surf_result.png" $ montage (2,1) 2 [padToSize (getSize y) (result lst x) ,result lsty y]+   saveImage "surf_result.png" $ montage (1,2) 2 [x, (result lst x)] -- ,result lsty y]    mapM_ print (take 5 lst) -padToSize :: (CreateImage (Image c d)) =>  (Int,Int) -> Image c d -> Image c d+padToSize :: (CreateImage (Image GrayScale D32)) =>  (Int,Int) +                                                    -> Image GrayScale D32 +                                                    -> Image GrayScale D32  padToSize size img = unsafePerformIO $ do     let r = empty size     blit r img (0,0)