CV-0.3.7: OpenCV based machine vision library

Safe HaskellNone




This module exposes opencv functions for camera calibration using a chessboard rig. This module follows opencv quite closely and the best documentation is probably found there. As quick example however, the following program detects and draws chessboard corners from an image.

 module Main where
 import CV.Image
 import CV.Calibration

main = do
     Just i <- loadColorImage "chess.png"
     let corners = findChessboardCorners (unsafeImageTo8Bit i) (4,5) (FastCheck:defaultFlags)
     let y = drawChessboardCorners (unsafeImageTo8Bit i) (4,5) corners
     mapM_ print (corners)
     saveImage "found_chessboard.png" y


Finding chessboard calibration rig

data FindFlags Source

 Flags for the chessboard corner detector. See opencv documentation for cvFindChessboardCorners.


defaultFlags :: [FindFlags]Source

Default flags for finding corners

findChessboardCorners :: Image RGB D8 -> (Int, Int) -> [FindFlags] -> [(Float, Float)]Source

Find the inner corners of a chessboard in a given image.

refineChessboardCorners :: Image GrayScale D8 -> [(Float, Float)] -> (Int, Int) -> (Int, Int) -> [(Float, Float)]Source

Given an estimate of chessboard corners, provide a subpixel estimation of actual corners.


drawChessboardCorners :: Image RGB D8 -> (Int, Int) -> [(Float, Float)] -> Image RGB D8Source

 Draw the found chessboard corners to an image

Camera calibration

calibrateCamera2 :: [[((Float, Float, Float), (Float, Float))]] -> (Int, Int) -> IO (Double, Matrix Float, [[Float]], [[Float]], [[Float]])Source

 See opencv function cvCalibrateCamera2. This function takes a list of world-screen coordinate pairs acquired with find-chessboard corners and attempts to find the camera parameters for the system. It returns the fitting error, the camera matrix, list of distortion co-efficients and rotation and translation vectors for each coordinate pair.