opencv-0.0.2.1: Haskell binding to OpenCV-3.x

Safe HaskellNone
LanguageHaskell2010

OpenCV.Juicy

Contents

Description

A thin JuicyPixels layer.

Synopsis

Types

type Mat2D h w channels depth = Mat (S '[h, w]) channels depth Source #

An OpenCV bidimensional matrix

type Filter m h w c d = Mat2D h w c d -> CvExceptT m (Mat2D h w c d) Source #

An OpenCV 2D-filter preserving the matrix type

Low level API

fromImage Source #

Arguments

:: (ToDepth (Proxy d), KnownNat c, Pixel a, Storable a, c ~ PixelChannels a, d ~ PixelDepth a) 
=> Image a

JuicyPixels image

-> Mat2D D D (S c) (S d) 

Compute an OpenCV 2D-matrix from a JuicyPixels image.

Example:

fromImageImg :: IO (Mat ('S '[ 'D, 'D]) ('S 3) ('S Word8))
fromImageImg = do
    r <- Codec.Picture.readImage "data/Lenna.png"
    case r of
      Left err -> error err
      Right (Codec.Picture.ImageRGB8 img) -> pure $ OpenCV.Juicy.fromImage img
      Right _ -> error "Unhandled JuicyPixels format!"

toImage Source #

Arguments

:: (KnownNat c, Pixel a, Storable a, c ~ PixelChannels a, d ~ PixelDepth a) 
=> Mat2D h w (S c) (S d)

OpenCV 2D-matrix

-> Image a 

Compute a JuicyPixels image from an OpenCV 2D-matrix

FIXME: There's a bug in the colour conversions in the example:

Example:

toImageImg :: IO (Mat ('S '[ 'D, 'D]) ('S 3) ('S Word8))
toImageImg = exceptError . cvtColor rgb bgr . from . to . exceptError . cvtColor bgr rgb <$> fromImageImg
  where
    to :: OpenCV.Juicy.Mat2D 'D 'D ('S 3) ('S Word8) -> Codec.Picture.Image Codec.Picture.PixelRGB8
    to = OpenCV.Juicy.toImage

    from :: Codec.Picture.Image Codec.Picture.PixelRGB8 -> OpenCV.Juicy.Mat2D 'D 'D ('S 3) ('S Word8)
    from = OpenCV.Juicy.fromImage

High level API

isoJuicy Source #

Arguments

:: PrimMonad m 
=> (forall c d h w. Filter m h w c d)

OpenCV 2D-filter

-> DynamicImage

JuicyPixels dynamic image

-> CvExceptT m DynamicImage 

Apply an OpenCV 2D-filter to a JuicyPixels dynamic matrix, preserving the Juicy pixel encoding

Orphan instances

Storable PixelYA8 Source # 
Storable PixelYA16 Source # 
Storable PixelRGB8 Source # 
Storable PixelRGB16 Source # 
Storable PixelRGBF Source # 
Storable PixelRGBA8 Source # 
Storable PixelRGBA16 Source #