Haskell Other
dukedave and roelvandijk Add SIFT (#120)
Heavily insipired by existing SURF implementation.
Latest commit 5fe41ff Jun 28, 2018


Build Status

opencv Hackage

opencv-extra Hackage

Haskell OpenCV-3.x binding

Haskell OpenCV-3.x logo

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.

Test Coverage

HPC Coverage Report


The documenation includes example programs that are automatically extracted from the source code and run as part of the test-suite. See the opencv-doc-images test-suite. The resulting images are referenced from the Haddock documentation.

Internal modules

OpenCV exports a number of modules named OpenCV.Internal. They are provided in case of urgent need for access to the internals, but they are not intended to be used by API consumers and if you find yourself repeatedly accessing them this is a sign that either you or OpenCV are doing something wrong. In such a case please file a bug.

The interface of Internal modules does not follow the PVP and may break between minor releases, so be careful.

Development using nix

To get into an environment that contains all the needed dependencies we use Nix. The following commands work both on Linux and OS X:

curl https://nixos.org/nix/install | sh   # Only execute this if you haven't installed Nix yet.
cd opencv[-extra]

Then you should be able to use cabal as normal.

Development using Stack's Docker integration

Ensure you have followed Stack's prerequisites for Docker integration.

Build the image using:

docker build -t stack-build:lts-10.1-opencv -f Dockerfile.stack-opencv .

Uncomment the docker: section in stack.yaml, and you should be able to use stack as normal.


We love to get contributions! Please send us your pull requests. Do make sure your PR comes with Haddock documentation and preferably with an example program. If you include your example program in the following way:

{- | ...


myExampleImg :: Mat (ShapeT [200, 300]) ('S 4) ('S Word8)
myExampleImg = ...

<<doc/generated/examples/myExampleImg.png myExampleImg>>

then run cabal test, now your Haddock documentation will include a nice picture with the output of your program. Not only that, but your example program will at the same time function as a test for the function you just documented!


In haskell-opencv we use the most precise types for integer arguments. OpenCV uses int which is a 32-bit integer. So in Haskell we have to use Int32 instead of Int for, eg. width and height.