packages feed

opencv 0.0.0.0 → 0.0.1.0

raw patch · 16 files changed

+347/−49 lines, 16 filesdep ~opencvsetup-changedbinary-addedPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: opencv

API changes (from Hackage documentation)

+ OpenCV.Calib3d: FindHomographyMethod_0 :: FindHomographyMethod
+ OpenCV.Calib3d: FindHomographyMethod_LMEDS :: FindHomographyMethod
+ OpenCV.Calib3d: FindHomographyMethod_RANSAC :: FindHomographyMethod
+ OpenCV.Calib3d: FindHomographyMethod_RHO :: FindHomographyMethod
+ OpenCV.Calib3d: FindHomographyParams :: !FindHomographyMethod -> !Double -> !Int -> !Double -> FindHomographyParams
+ OpenCV.Calib3d: [fhpConfidence] :: FindHomographyParams -> !Double
+ OpenCV.Calib3d: [fhpMaxIters] :: FindHomographyParams -> !Int
+ OpenCV.Calib3d: [fhpMethod] :: FindHomographyParams -> !FindHomographyMethod
+ OpenCV.Calib3d: [fhpRansacReprojThreshold] :: FindHomographyParams -> !Double
+ OpenCV.Calib3d: data FindHomographyMethod
+ OpenCV.Calib3d: data FindHomographyParams
+ OpenCV.Calib3d: findHomography :: (IsPoint2 point2 CDouble) => Vector (point2 CDouble) -> Vector (point2 CDouble) -> FindHomographyParams -> CvExcept (Maybe (Mat (S '[S 3, S 3]) (S 1) (S Double), Mat (S '[D, D]) (S 1) (S Word8)))
+ OpenCV.Calib3d: instance Data.Default.Class.Default OpenCV.Calib3d.FindHomographyParams
+ OpenCV.Calib3d: instance GHC.Show.Show OpenCV.Calib3d.FindHomographyMethod
+ OpenCV.Calib3d: instance GHC.Show.Show OpenCV.Calib3d.FindHomographyParams
+ OpenCV.Core.ArrayOps: hconcat :: Vector (Mat (S '[rows, D]) channels depth) -> CvExcept (Mat (S '[rows, D]) channels depth)
+ OpenCV.Core.ArrayOps: vconcat :: Vector (Mat (S '[D, cols]) channels depth) -> CvExcept (Mat (S '[D, cols]) channels depth)
- OpenCV.Features2d: class DescriptorMatcher a where add dm trainDescriptors = withPtr (upcast dm) $ \ dmPtr -> withArrayPtr trainDescriptors $ \ trainVecPtr -> (((\ cont_a2S29 -> cont_a2S29 (trainVecPtr :: Ptr C'Mat)) $ (\ arg_a2S2d -> ((\ cont_a2S2a -> cont_a2S2a (trainVecPtr :: Ptr C'Mat)) $ (\ arg_a2S2e -> ((\ cont_a2S2b -> cont_a2S2b (c'trainVecLength :: Int32)) $ (\ arg_a2S2f -> ((\ cont_a2S2c -> cont_a2S2c (dmPtr :: Ptr C'DescriptorMatcher)) $ (\ arg_a2S2g -> inline_c_ffi_6989586621679694165_a2S2i arg_a2S2d arg_a2S2e arg_a2S2f arg_a2S2g))))))))) where c'trainVecLength = fromIntegral $ length trainDescriptors train dm = withPtr (upcast dm) $ \ dmPtr -> (((\ cont_a2S2p -> cont_a2S2p (dmPtr :: Ptr C'DescriptorMatcher)) $ (\ arg_a2S2q -> inline_c_ffi_6989586621679694175_a2S2s arg_a2S2q))) match dm queryDescriptors trainDescriptors mbMask = withPtr (upcast dm) $ \ dmPtr -> withPtr queryDescriptors $ \ queryPtr -> withPtr trainDescriptors $ \ trainPtr -> withPtr mbMask $ \ maskPtr -> alloca $ \ (numMatchesPtr :: Ptr Int32) -> alloca $ \ (arrayPtrPtr :: Ptr (Ptr (Ptr C'DMatch))) -> mask_ $ do { (((\ cont_a2S2H -> cont_a2S2H (maskPtr :: Ptr C'Mat)) $ (\ arg_a2S2N -> ((\ cont_a2S2I -> cont_a2S2I (dmPtr :: Ptr C'DescriptorMatcher)) $ (\ arg_a2S2O -> ((\ cont_a2S2J -> cont_a2S2J (queryPtr :: Ptr C'Mat)) $ (\ arg_a2S2P -> ((\ cont_a2S2K -> cont_a2S2K (trainPtr :: Ptr C'Mat)) $ (\ arg_a2S2Q -> ((\ cont_a2S2L -> cont_a2S2L (numMatchesPtr :: Ptr Int32)) $ (\ arg_a2S2R -> ((\ cont_a2S2M -> cont_a2S2M (arrayPtrPtr :: Ptr (Ptr (Ptr C'DMatch)))) $ (\ arg_a2S2S -> inline_c_ffi_6989586621679694203_a2S2U arg_a2S2N arg_a2S2O arg_a2S2P arg_a2S2Q arg_a2S2R arg_a2S2S))))))))))))); (numMatches :: Int) <- fromIntegral <$> peek numMatchesPtr; arrayPtr <- peek arrayPtrPtr; matches <- mapM (fromPtr . pure) =<< peekArray numMatches arrayPtr; (((\ cont_a2S32 -> cont_a2S32 (arrayPtrPtr :: Ptr (Ptr (Ptr C'DMatch)))) $ (\ arg_a2S33 -> inline_c_ffi_6989586621679694214_a2S35 arg_a2S33))); pure $ fromList matches } match' dm queryDescriptors mbMask = withPtr (upcast dm) $ \ dmPtr -> withPtr queryDescriptors $ \ queryPtr -> withPtr mbMask $ \ maskPtr -> alloca $ \ (numMatchesPtr :: Ptr Int32) -> alloca $ \ (arrayPtrPtr :: Ptr (Ptr (Ptr C'DMatch))) -> mask_ $ do { (((\ cont_a2S3i -> cont_a2S3i (maskPtr :: Ptr C'Mat)) $ (\ arg_a2S3n -> ((\ cont_a2S3j -> cont_a2S3j (dmPtr :: Ptr C'DescriptorMatcher)) $ (\ arg_a2S3o -> ((\ cont_a2S3k -> cont_a2S3k (queryPtr :: Ptr C'Mat)) $ (\ arg_a2S3p -> ((\ cont_a2S3l -> cont_a2S3l (numMatchesPtr :: Ptr Int32)) $ (\ arg_a2S3q -> ((\ cont_a2S3m -> cont_a2S3m (arrayPtrPtr :: Ptr (Ptr (Ptr C'DMatch)))) $ (\ arg_a2S3r -> inline_c_ffi_6989586621679694238_a2S3t arg_a2S3n arg_a2S3o arg_a2S3p arg_a2S3q arg_a2S3r))))))))))); (numMatches :: Int) <- fromIntegral <$> peek numMatchesPtr; arrayPtr <- peek arrayPtrPtr; matches <- mapM (fromPtr . pure) =<< peekArray numMatches arrayPtr; (((\ cont_a2S3B -> cont_a2S3B (arrayPtrPtr :: Ptr (Ptr (Ptr C'DMatch)))) $ (\ arg_a2S3C -> inline_c_ffi_6989586621679694249_a2S3E arg_a2S3C))); pure $ fromList matches }
+ OpenCV.Features2d: class DescriptorMatcher a where add dm trainDescriptors = withPtr (upcast dm) $ \ dmPtr -> withArrayPtr trainDescriptors $ \ trainVecPtr -> (((\ cont_a2OyE -> cont_a2OyE (trainVecPtr :: Ptr C'Mat)) $ (\ arg_a2OyI -> ((\ cont_a2OyF -> cont_a2OyF (trainVecPtr :: Ptr C'Mat)) $ (\ arg_a2OyJ -> ((\ cont_a2OyG -> cont_a2OyG (c'trainVecLength :: Int32)) $ (\ arg_a2OyK -> ((\ cont_a2OyH -> cont_a2OyH (dmPtr :: Ptr C'DescriptorMatcher)) $ (\ arg_a2OyL -> inline_c_ffi_6989586621679680804_a2OyN arg_a2OyI arg_a2OyJ arg_a2OyK arg_a2OyL))))))))) where c'trainVecLength = fromIntegral $ length trainDescriptors train dm = withPtr (upcast dm) $ \ dmPtr -> (((\ cont_a2OyU -> cont_a2OyU (dmPtr :: Ptr C'DescriptorMatcher)) $ (\ arg_a2OyV -> inline_c_ffi_6989586621679680814_a2OyX arg_a2OyV))) match dm queryDescriptors trainDescriptors mbMask = withPtr (upcast dm) $ \ dmPtr -> withPtr queryDescriptors $ \ queryPtr -> withPtr trainDescriptors $ \ trainPtr -> withPtr mbMask $ \ maskPtr -> alloca $ \ (numMatchesPtr :: Ptr Int32) -> alloca $ \ (arrayPtrPtr :: Ptr (Ptr (Ptr C'DMatch))) -> mask_ $ do { (((\ cont_a2Ozc -> cont_a2Ozc (maskPtr :: Ptr C'Mat)) $ (\ arg_a2Ozi -> ((\ cont_a2Ozd -> cont_a2Ozd (dmPtr :: Ptr C'DescriptorMatcher)) $ (\ arg_a2Ozj -> ((\ cont_a2Oze -> cont_a2Oze (queryPtr :: Ptr C'Mat)) $ (\ arg_a2Ozk -> ((\ cont_a2Ozf -> cont_a2Ozf (trainPtr :: Ptr C'Mat)) $ (\ arg_a2Ozl -> ((\ cont_a2Ozg -> cont_a2Ozg (numMatchesPtr :: Ptr Int32)) $ (\ arg_a2Ozm -> ((\ cont_a2Ozh -> cont_a2Ozh (arrayPtrPtr :: Ptr (Ptr (Ptr C'DMatch)))) $ (\ arg_a2Ozn -> inline_c_ffi_6989586621679680842_a2Ozp arg_a2Ozi arg_a2Ozj arg_a2Ozk arg_a2Ozl arg_a2Ozm arg_a2Ozn))))))))))))); (numMatches :: Int) <- fromIntegral <$> peek numMatchesPtr; arrayPtr <- peek arrayPtrPtr; matches <- mapM (fromPtr . pure) =<< peekArray numMatches arrayPtr; (((\ cont_a2Ozx -> cont_a2Ozx (arrayPtrPtr :: Ptr (Ptr (Ptr C'DMatch)))) $ (\ arg_a2Ozy -> inline_c_ffi_6989586621679680853_a2OzA arg_a2Ozy))); pure $ fromList matches } match' dm queryDescriptors mbMask = withPtr (upcast dm) $ \ dmPtr -> withPtr queryDescriptors $ \ queryPtr -> withPtr mbMask $ \ maskPtr -> alloca $ \ (numMatchesPtr :: Ptr Int32) -> alloca $ \ (arrayPtrPtr :: Ptr (Ptr (Ptr C'DMatch))) -> mask_ $ do { (((\ cont_a2OzN -> cont_a2OzN (maskPtr :: Ptr C'Mat)) $ (\ arg_a2OzS -> ((\ cont_a2OzO -> cont_a2OzO (dmPtr :: Ptr C'DescriptorMatcher)) $ (\ arg_a2OzT -> ((\ cont_a2OzP -> cont_a2OzP (queryPtr :: Ptr C'Mat)) $ (\ arg_a2OzU -> ((\ cont_a2OzQ -> cont_a2OzQ (numMatchesPtr :: Ptr Int32)) $ (\ arg_a2OzV -> ((\ cont_a2OzR -> cont_a2OzR (arrayPtrPtr :: Ptr (Ptr (Ptr C'DMatch)))) $ (\ arg_a2OzW -> inline_c_ffi_6989586621679680877_a2OzY arg_a2OzS arg_a2OzT arg_a2OzU arg_a2OzV arg_a2OzW))))))))))); (numMatches :: Int) <- fromIntegral <$> peek numMatchesPtr; arrayPtr <- peek arrayPtrPtr; matches <- mapM (fromPtr . pure) =<< peekArray numMatches arrayPtr; (((\ cont_a2OA6 -> cont_a2OA6 (arrayPtrPtr :: Ptr (Ptr (Ptr C'DMatch)))) $ (\ arg_a2OA7 -> inline_c_ffi_6989586621679680888_a2OA9 arg_a2OA7))); pure $ fromList matches }

Files

+ CHANGELOG.md view
@@ -0,0 +1,21 @@+## [0.0.1.0] - 2017-06-20++### Added++- OpenCV.Calib3d: findHomography.+- OpenCV.Core.ArrayOps: hconcat, vconcat.+- include/hsc_macros.hpp: #alignof macro.++### Changed++- Fix build on OS X.+- Add source repo to cabal file.+- Reference opencv-extra and the examples from the Cabal package description.+++## 0.0.0.0 - 2017-06-11++- Initial version+++[0.0.1.0]: https://github.com/LumiGuide/haskell-opencv/compare/opencv-0.0.0.0...opencv-0.0.1.0
LICENSE view
@@ -1,4 +1,4 @@-Copyright 2015—2016 Lumi Guide Fietsdetectie B.V.+Copyright 2015–2017 Lumi Guide Fietsdetectie B.V.  All rights reserved. 
Setup.hs view
@@ -3,6 +3,6 @@  main = do     args <- getArgs-    let args' | "configure" `elem` args = args ++ ["--with-gcc","g++", "--with-ld","g++"]+    let args' | "configure" `elem` args = args ++ ["--with-gcc","c++", "--with-ld","c++"]               | otherwise               = args     defaultMainArgs args'
+ data/haskell-opencv-logo-200x82.png view

binary file changed (absent → 4281 bytes)

+ doc/generated/examples/car.gif view

file too large to diff

+ doc/generated/examples/drawChArUcoBoardImg.png view

binary file changed (absent → 5132 bytes)

+ doc/generated/examples/hconcatImg.png view

binary file changed (absent → 522730 bytes)

+ doc/generated/examples/mog2.gif view

binary file changed (absent → 91038 bytes)

+ doc/generated/examples/vconcatImg.png view

binary file changed (absent → 506751 bytes)

include/hsc_macros.hpp view
@@ -10,6 +10,8 @@  #define bc_sizeof_varid(name) {printf("c'sizeof_");bc_word(name);}; \ +#define bc_alignof_varid(name) {printf("c'alignof_");bc_word(name);}; \+ /* The #sizeof macro outputs a Haskell constant with the size of the C/C++ type in bytes. @@ -25,6 +27,25 @@ #define hsc_sizeof(name) \   { bc_sizeof_varid(# name);printf(" :: Int\n"); \     bc_sizeof_varid(# name);printf(" = %lu\n", sizeof(name)); \+  }; \++/*+The #alignof macro outputs a Haskell constant with the alignment off the C/C++ type in bytes.++For example the following:++  #alignof Point2i++Results in the following Haskell code:++  c'alignof_Point2i :: Int+  c'alignof_Point2i = 4++The specific alignment that is calculated is platform dependent.+*/+#define hsc_alignof(name) \+  { bc_alignof_varid(# name);printf(" :: Int\n"); \+    bc_alignof_varid(# name);printf(" = %lu\n", alignof(name)); \   }; \  #endif /* __HSC_MACROS_H__ */
opencv.cabal view
@@ -1,6 +1,7 @@ name:          opencv-version:       0.0.0.0+version:       0.0.1.0 homepage:      https://github.com/LumiGuide/haskell-opencv+bug-reports:   https://github.com/LumiGuide/haskell-opencv/issues license:       BSD3 license-file:  LICENSE author:        Roel van Dijk <roel@lambdacube.nl>, Bas van Dijk <v.dijk.bas@gmail.com>@@ -9,13 +10,22 @@ cabal-version: >=1.23 category:      AI, Graphics synopsis:      Haskell binding to OpenCV-3.x-description:   This is a Haskell library providing a binding to OpenCV-3.x.+description:   <<https://raw.githubusercontent.com/LumiGuide/haskell-opencv/master/data/haskell-opencv-logo-200x82.png>>+               .+               This is a Haskell library providing a binding to OpenCV-3.x.                It binds directly with the C++ API using the @inline-c@ Haskell library.                .                The library is far from complete but the framework is there to easily                bind missing functionality.+               .+               Note that the OpenCV contrib modules are provided by+               <http://hackage.haskell.org/package/opencv-extra opencv-extra>.+               .+               Make sure to checkout the+               <https://github.com/LumiGuide/haskell-opencv/tree/master/opencv-examples opencv-examples>.  extra-source-files:+    CHANGELOG.md     data/*.png     data/*.jpg @@ -25,6 +35,11 @@     doc/generated/examples/*.gif     doc/color_conversions.png +source-repository head+  type:     git+  location: git://github.com/LumiGuide/haskell-opencv.git+  subdir:   opencv+ flag internal-documentation     description: Enables documentation generation for internal modules.     default: False@@ -37,46 +52,46 @@     hs-source-dirs: src     include-dirs: include     install-includes:-      haskell_opencv_matx_typedefs.hpp-      hsc_macros.hpp-      namespace.hpp-      orb.hpp-      simple_blob_detector.hpp-      termcriteria.hpp-      video_motion_analysis.hpp+        haskell_opencv_matx_typedefs.hpp+        hsc_macros.hpp+        namespace.hpp+        orb.hpp+        simple_blob_detector.hpp+        termcriteria.hpp+        video_motion_analysis.hpp      c-sources:         src/OpenCV/Calib3d.cpp-      , src/OpenCV/Core/ArrayOps.cpp-      , src/OpenCV/Core/Types.cpp-      , src/OpenCV/Core/Types/Mat.cpp-      , src/OpenCV/Core/Types/Mat/Repa.cpp-      , src/OpenCV/Core/Types/Matx.cpp-      , src/OpenCV/Core/Types/Point.cpp-      , src/OpenCV/Core/Types/Rect.cpp-      , src/OpenCV/Core/Types/Size.cpp-      , src/OpenCV/Core/Types/Vec.cpp-      , src/OpenCV/Features2d.cpp-      , src/OpenCV/HighGui.cpp-      , src/OpenCV/ImgCodecs.cpp-      , src/OpenCV/ImgProc/ColorMaps.cpp-      , src/OpenCV/ImgProc/Drawing.cpp-      , src/OpenCV/ImgProc/FeatureDetection.cpp-      , src/OpenCV/ImgProc/GeometricImgTransform.cpp-      , src/OpenCV/ImgProc/ImgFiltering.cpp-      , src/OpenCV/ImgProc/MiscImgTransform.cpp-      , src/OpenCV/ImgProc/ObjectDetection.cpp-      , src/OpenCV/ImgProc/StructuralAnalysis.cpp-      , src/OpenCV/ImgProc/CascadeClassifier.cpp-      , src/OpenCV/Internal/Core/Types.cpp-      , src/OpenCV/Internal/Core/Types/Mat.cpp-      , src/OpenCV/Internal/Core/Types/Mat/ToFrom.cpp-      , src/OpenCV/Internal/Exception.cpp-      , src/OpenCV/Photo.cpp-      , src/OpenCV/Video.cpp-      , src/OpenCV/VideoIO/VideoCapture.cpp-      , src/OpenCV/VideoIO/VideoWriter.cpp-      , src/OpenCV/Video/MotionAnalysis.cpp+        src/OpenCV/Core/ArrayOps.cpp+        src/OpenCV/Core/Types.cpp+        src/OpenCV/Core/Types/Mat.cpp+        src/OpenCV/Core/Types/Mat/Repa.cpp+        src/OpenCV/Core/Types/Matx.cpp+        src/OpenCV/Core/Types/Point.cpp+        src/OpenCV/Core/Types/Rect.cpp+        src/OpenCV/Core/Types/Size.cpp+        src/OpenCV/Core/Types/Vec.cpp+        src/OpenCV/Features2d.cpp+        src/OpenCV/HighGui.cpp+        src/OpenCV/ImgCodecs.cpp+        src/OpenCV/ImgProc/ColorMaps.cpp+        src/OpenCV/ImgProc/Drawing.cpp+        src/OpenCV/ImgProc/FeatureDetection.cpp+        src/OpenCV/ImgProc/GeometricImgTransform.cpp+        src/OpenCV/ImgProc/ImgFiltering.cpp+        src/OpenCV/ImgProc/MiscImgTransform.cpp+        src/OpenCV/ImgProc/ObjectDetection.cpp+        src/OpenCV/ImgProc/StructuralAnalysis.cpp+        src/OpenCV/ImgProc/CascadeClassifier.cpp+        src/OpenCV/Internal/Core/Types.cpp+        src/OpenCV/Internal/Core/Types/Mat.cpp+        src/OpenCV/Internal/Core/Types/Mat/ToFrom.cpp+        src/OpenCV/Internal/Exception.cpp+        src/OpenCV/Photo.cpp+        src/OpenCV/Video.cpp+        src/OpenCV/VideoIO/VideoCapture.cpp+        src/OpenCV/VideoIO/VideoWriter.cpp+        src/OpenCV/Video/MotionAnalysis.cpp      cc-options: -Wall -std=c++11     ghc-options: -Wall -fwarn-incomplete-patterns -funbox-strict-fields -O2@@ -199,8 +214,9 @@     type: exitcode-stdio-1.0     hs-source-dirs: doc     main-is: images.hs-    other-modules: ExampleExtractor-                   Language.Haskell.Meta.Syntax.Translate+    other-modules:+        ExampleExtractor+        Language.Haskell.Meta.Syntax.Translate     default-language: Haskell2010     ghc-options: -Wall -fwarn-incomplete-patterns -threaded -funbox-strict-fields -O2 -rtsopts     build-depends:@@ -213,7 +229,7 @@       , haskell-src-exts  >= 1.18.2       , JuicyPixels       >= 3.2.8.1       , linear            >= 1.20.4-      , opencv            == 0.0.0+      , opencv       , primitive         >= 0.6.1       , template-haskell  >= 2.10       , text              >= 1.2.2.1@@ -243,7 +259,7 @@       , bytestring        >= 0.10.6       , lens              >= 4.13       , linear            >= 1.20.4-      , opencv            == 0.0.0+      , opencv       , QuickCheck        >= 2.8.2       , repa              >= 3.4.0.2       , tasty             >= 0.11.0.2@@ -270,7 +286,7 @@         base              >= 4.8 && < 5       , bytestring        >= 0.10.6       , criterion         >= 1.1.1-      , opencv            == 0.0.0+      , opencv       , repa              >= 3.4.0.2      default-extensions:
src/OpenCV/Calib3d.cpp view
@@ -34,7 +34,36 @@ }  extern "C" {-Exception * inline_c_OpenCV_Calib3d_1_6580eb89fe56557059d953009d36dacf9f92ae43(Point2d * pointsPtr_inline_c_0, int32_t cnumPoints_27_inline_c_1, int32_t cwhichImage_27_inline_c_2, Mat * fmPtr_inline_c_3, Mat * epilinesPtr_inline_c_4) {+Exception * inline_c_OpenCV_Calib3d_1_977ea2515e09e42791f45dfd690308962ddb21ad(Point2d * srcPtr_inline_c_0, int32_t cnumSrcPts_27_inline_c_1, Point2d * dstPtr_inline_c_2, int32_t cnumDstPts_27_inline_c_3, Mat * fmPtr_inline_c_4, int32_t cmethod_27_inline_c_5, double cransacReprojThreshold_27_inline_c_6, Mat * pointMaskPtr_inline_c_7, int32_t cmaxIters_27_inline_c_8, double cconfidence_27_inline_c_9) {++  try+  {   +            cv::_InputArray srcPts = cv::_InputArray(srcPtr_inline_c_0, cnumSrcPts_27_inline_c_1);+            cv::_InputArray dstPts = cv::_InputArray(dstPtr_inline_c_2, cnumDstPts_27_inline_c_3);+            *fmPtr_inline_c_4 =+              cv::findHomography+                  ( srcPts+                  , dstPts+                  , cmethod_27_inline_c_5+                  , cransacReprojThreshold_27_inline_c_6+                  , *pointMaskPtr_inline_c_7+                  , cmaxIters_27_inline_c_8+                  , cconfidence_27_inline_c_9+                  );+          +    return NULL;+  }+  catch (const cv::Exception & e)+  {+    return new cv::Exception(e);+  }++}++}++extern "C" {+Exception * inline_c_OpenCV_Calib3d_2_6580eb89fe56557059d953009d36dacf9f92ae43(Point2d * pointsPtr_inline_c_0, int32_t cnumPoints_27_inline_c_1, int32_t cwhichImage_27_inline_c_2, Mat * fmPtr_inline_c_3, Mat * epilinesPtr_inline_c_4) {    try   {   
src/OpenCV/Calib3d.hs view
@@ -3,9 +3,12 @@  module OpenCV.Calib3d     ( FundamentalMatMethod(..)+    , FindHomographyMethod(..)+    , FindHomographyParams(..)     , WhichImage(..)     -- , calibrateCamera     , findFundamentalMat+    , findHomography     , computeCorrespondEpilines     ) where @@ -14,6 +17,7 @@ import "base" Foreign.C.Types import qualified "inline-c" Language.C.Inline as C import qualified "inline-c-cpp" Language.C.Inline.Cpp as C+import "data-default" Data.Default import "this" OpenCV.Internal.C.Inline ( openCvCtx ) import "this" OpenCV.Internal.C.Types import "this" OpenCV.Internal.Calib3d.Constants@@ -57,6 +61,24 @@     Image1 -> 1     Image2 -> 2 +data FindHomographyMethod+   = FindHomographyMethod_0+     -- ^ A regular method using all the points.+   | FindHomographyMethod_RANSAC+     -- ^ RANSAC-based robust method.+   | FindHomographyMethod_LMEDS+     -- ^ Least-Median robust method.+   | FindHomographyMethod_RHO+     -- ^ PROSAC-based robust method.+     deriving (Show)++marshalFindHomographyMethod :: FindHomographyMethod -> Int32+marshalFindHomographyMethod = \case+    FindHomographyMethod_0      -> 0+    FindHomographyMethod_RANSAC -> c'RANSAC+    FindHomographyMethod_LMEDS  -> c'LMEDS+    FindHomographyMethod_RHO    -> c'RHO+ --------------------------------------------------------------------------------  -- {- |@@ -110,7 +132,7 @@ findFundamentalMat pts1 pts2 method = do     (fm, pointMask) <- c'findFundamentalMat     -- If the c++ function can't find a fundamental matrix it will-    -- retrun an empty matrix. We check for this case by trying to+    -- return an empty matrix. We check for this case by trying to     -- coerce the result to the desired type.     catchE (Just . (, unsafeCoerceMat pointMask) <$> coerceMat fm)            (\case CoerceMatError _msgs -> pure Nothing@@ -118,7 +140,7 @@            )   where     c'findFundamentalMat = unsafeWrapException $ do-      fm   <- newEmptyMat+      fm        <- newEmptyMat       pointMask <- newEmptyMat       handleCvException (pure (fm, pointMask)) $         withPtr fm $ \fmPtr ->@@ -142,6 +164,70 @@     c'numPts1 = fromIntegral $ V.length pts1     c'numPts2 = fromIntegral $ V.length pts2     (c'method, c'p1, c'p2) = marshalFundamentalMatMethod method++data FindHomographyParams+   = FindHomographyParams+     { fhpMethod                :: !FindHomographyMethod+     , fhpRansacReprojThreshold :: !Double+     , fhpMaxIters              :: !Int+     , fhpConfidence            :: !Double+     } deriving (Show)++instance Default FindHomographyParams where+    def = FindHomographyParams+          { fhpMethod                = FindHomographyMethod_0+          , fhpRansacReprojThreshold = 3+          , fhpMaxIters              = 2000+          , fhpConfidence            = 0.995+          }++findHomography+    :: (IsPoint2 point2 CDouble)+    => V.Vector (point2 CDouble) -- ^ Points from the first image.+    -> V.Vector (point2 CDouble) -- ^ Points from the second image.+    -> FindHomographyParams+    -> CvExcept ( Maybe ( Mat ('S '[ 'S 3, 'S 3 ]) ('S 1) ('S Double)+                        , Mat ('S '[ 'D, 'D   ]) ('S 1) ('S Word8 )+                        )+                )+findHomography srcPoints dstPoints fhp = do+    (fm, pointMask) <- c'findHomography+    -- If the c++ function can't find a fundamental matrix it will+    -- return an empty matrix. We check for this case by trying to+    -- coerce the result to the desired type.+    catchE (Just . (, unsafeCoerceMat pointMask) <$> coerceMat fm)+           (\case CoerceMatError _msgs -> pure Nothing+                  otherError           -> throwE otherError+           )+  where+    c'findHomography = unsafeWrapException $ do+      fm        <- newEmptyMat+      pointMask <- newEmptyMat+      handleCvException (pure (fm, pointMask)) $+        withPtr fm $ \fmPtr ->+        withPtr pointMask $ \pointMaskPtr ->+        withArrayPtr (V.map toPoint srcPoints) $ \srcPtr ->+        withArrayPtr (V.map toPoint dstPoints) $ \dstPtr ->+          [cvExcept|+            cv::_InputArray srcPts = cv::_InputArray($(Point2d * srcPtr), $(int32_t c'numSrcPts));+            cv::_InputArray dstPts = cv::_InputArray($(Point2d * dstPtr), $(int32_t c'numDstPts));+            *$(Mat * fmPtr) =+              cv::findHomography+                  ( srcPts+                  , dstPts+                  , $(int32_t c'method)+                  , $(double c'ransacReprojThreshold)+                  , *$(Mat * pointMaskPtr)+                  , $(int32_t c'maxIters)+                  , $(double c'confidence)+                  );+          |]+    c'numSrcPts = fromIntegral $ V.length srcPoints+    c'numDstPts = fromIntegral $ V.length dstPoints+    c'method = marshalFindHomographyMethod $ fhpMethod fhp+    c'ransacReprojThreshold = realToFrac $ fhpRansacReprojThreshold fhp+    c'maxIters = fromIntegral $ fhpMaxIters fhp+    c'confidence = realToFrac $ fhpConfidence fhp  {- | For points in an image of a stereo pair, computes the corresponding epilines in the other image 
src/OpenCV/Core/ArrayOps.cpp view
@@ -439,3 +439,47 @@ }  }++extern "C" {+Exception * inline_c_OpenCV_Core_ArrayOps_24_c4b844a405cfe807dac35ef495bd740db3789b10(Mat * matsPtr_inline_c_0, size_t cnumMats_27_inline_c_1, Mat * dstPtr_inline_c_2) {++  try+  {   +          cv::hconcat+            ( matsPtr_inline_c_0+            , cnumMats_27_inline_c_1+            , *dstPtr_inline_c_2+            );+        +    return NULL;+  }+  catch (const cv::Exception & e)+  {+    return new cv::Exception(e);+  }++}++}++extern "C" {+Exception * inline_c_OpenCV_Core_ArrayOps_25_f90bb8ea407f21af89dacdb7a4893fb6db43264c(Mat * matsPtr_inline_c_0, size_t cnumMats_27_inline_c_1, Mat * dstPtr_inline_c_2) {++  try+  {   +          cv::vconcat+            ( matsPtr_inline_c_0+            , cnumMats_27_inline_c_1+            , *dstPtr_inline_c_2+            );+        +    return NULL;+  }+  catch (const cv::Exception & e)+  {+    return new cv::Exception(e);+  }++}++}
src/OpenCV/Core/ArrayOps.hs view
@@ -44,6 +44,8 @@     , meanStdDev     , matFlip, FlipDirection(..)     , matTranspose+    , hconcat+    , vconcat     ) where  import "base" Data.Proxy ( Proxy(..) )@@ -922,3 +924,77 @@           cv::transpose(*$(Mat * srcPtr), *$(Mat * dstPtr));         }|]     pure $ unsafeCoerceMat dst++{- | Applies horizontal concatenation to given matrices.++Example:++@+hconcatImg :: Mat ('S '[ 'D, 'D ]) ('S 3) ('S Word8)+hconcatImg = exceptError $+    hconcat $ V.fromList+      [ halfSize birds_768x512+      , halfSize flower_768x512+      , halfSize sailboat_768x512+      ]+  where+    halfSize = exceptError . resize (ResizeRel 0.5) InterArea+@++<<doc/generated/examples/hconcatImg.png hconcatImg>>+-}+hconcat+    :: V.Vector (Mat ('S '[rows, 'D]) channels depth)+    -> CvExcept (Mat ('S '[rows, 'D]) channels depth)+hconcat mats = unsafeWrapException $ do+    dst <- unsafeCoerceMat <$> newEmptyMat+    handleCvException (pure dst) $+      withArrayPtr mats $ \matsPtr ->+      withPtr dst $ \dstPtr ->+        [cvExcept|+          cv::hconcat+            ( $(Mat * matsPtr)+            , $(size_t c'numMats)+            , *$(Mat * dstPtr)+            );+        |]+  where+    c'numMats :: C.CSize+    c'numMats = fromIntegral $ V.length mats++{- | Applies vertical concatenation to given matrices.++Example:++@+vconcatImg :: Mat ('S '[ 'D, 'D ]) ('S 3) ('S Word8)+vconcatImg = exceptError $+    vconcat $ V.fromList+      [ halfSize birds_768x512+      , halfSize flower_768x512+      , halfSize sailboat_768x512+      ]+  where+    halfSize = exceptError . resize (ResizeRel 0.5) InterArea+@++<<doc/generated/examples/vconcatImg.png vconcatImg>>+-}+vconcat+    :: V.Vector (Mat ('S '[ 'D, cols ]) channels depth)+    -> CvExcept (Mat ('S '[ 'D, cols ]) channels depth)+vconcat mats = unsafeWrapException $ do+    dst <- unsafeCoerceMat <$> newEmptyMat+    handleCvException (pure dst) $+      withArrayPtr mats $ \matsPtr ->+      withPtr dst $ \dstPtr ->+        [cvExcept|+          cv::vconcat+            ( $(Mat * matsPtr)+            , $(size_t c'numMats)+            , *$(Mat * dstPtr)+            );+        |]+  where+    c'numMats :: C.CSize+    c'numMats = fromIntegral $ V.length mats
src/OpenCV/Internal/Calib3d/Constants.hsc view
@@ -16,3 +16,8 @@ #num CV_FM_8POINT #num CV_FM_RANSAC #num CV_FM_LMEDS++#num LMEDS+#num RANSAC+#num RHO+