LumiGuide / haskell-opencv

Haskell binding to OpenCV-3.x
Other
154 stars 44 forks source link

Tutorial or 'quick start' #129

Closed davetapley closed 6 years ago

davetapley commented 6 years ago

I'm struggling with using the sift implementation I added (#120) because the types are (for me) very overwhelming.

I see a few comments in TypeLevel.hs, but it seems a lot of reading would be required to just use the function.

E.g: I tried copying the sample verbatim (including the definition of frog), but I get this horrendous type error:

    • Couldn't match type ‘DSNat channels0’ with ‘'S 3’
      Expected type: Mat
                       (ShapeT '[height, width]) ('S channels) ('S depth)
        Actual type: Mat
                       (ShapeT '[height0, width0]) (DSNat channels0) ('S Word8)
      The type variable ‘channels0’ is ambiguous
    • In the expression:
        exceptError
          $ do (kpts, _descs) <- siftDetectAndCompute sift frog Nothing
               withMatM
                 (Proxy :: Proxy [height, width])
                 (Proxy :: Proxy channels)
                 (Proxy :: Proxy depth)
                 white
                 $ \ imgM -> do ...
      In an equation for ‘startDetectAndComputeImg’:
          startDetectAndComputeImg
            = exceptError
                $ do (kpts, _descs) <- siftDetectAndCompute sift frog Nothing
                     withMatM
                       (Proxy :: Proxy [height, width])
                       (Proxy :: Proxy channels)
                       (Proxy :: Proxy depth)
                       white
                       $ \ imgM -> ...
            where
                sift = mkSift defaultSiftParams

I can try reading up, but I feel like it would be super helpful if there were a tutorial or 'quick start' guide (ideally with examples!) I'm happy to contribute, but I lack the knowledge 😞

davetapley commented 6 years ago

FYI, this is the file in question.

davetapley commented 6 years ago

I tracked it down to my not having the right language extensions enabled. Is it fair to say that to do anything really useful with this library, then there are a set of extensions which you should enable before you start? If so I think that'd be a good thing to put in the README 🤔 https://github.com/LumiGuide/haskell-opencv/blob/1e7f0b49b811bc845250f01a3d24d5ca007a1f76/opencv-extra/opencv-extra.cabal#L158-L168

davetapley commented 6 years ago

I found #1, which led me to the -examples/ directories, which should get me a little bit further!

Will close this and maybe make some PRs to -examples/ with that I learn 🤓