opencv-0.0.1.0: 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

type family PixelChannels a :: Nat Source #

map Pixel types to a number of channels

Instances

type PixelChannels PixelYCbCr8 Source # 
type PixelChannels PixelYCbCr8 = 3
type PixelChannels PixelYA8 Source # 
type PixelChannels PixelYA8 = 2
type PixelChannels PixelYA16 Source # 
type PixelChannels PixelYA16 = 2
type PixelChannels PixelRGBF Source # 
type PixelChannels PixelRGBF = 3
type PixelChannels PixelRGBA8 Source # 
type PixelChannels PixelRGBA8 = 4
type PixelChannels PixelRGBA16 Source # 
type PixelChannels PixelRGBA16 = 4
type PixelChannels PixelRGB8 Source # 
type PixelChannels PixelRGB8 = 3
type PixelChannels PixelRGB16 Source # 
type PixelChannels PixelRGB16 = 3
type PixelChannels PixelF Source # 
type PixelChannels PixelF = 1
type PixelChannels PixelCMYK8 Source # 
type PixelChannels PixelCMYK8 = 4
type PixelChannels PixelCMYK16 Source # 
type PixelChannels PixelCMYK16 = 4
type PixelChannels Pixel8 Source # 
type PixelChannels Pixel8 = 1
type PixelChannels Pixel16 Source # 
type PixelChannels Pixel16 = 1

type family PixelDepth a Source #

map Pixel types to a depth

Instances

type PixelDepth PixelYCbCr8 Source # 
type PixelDepth PixelYCbCr8 = Word8
type PixelDepth PixelYA8 Source # 
type PixelDepth PixelYA8 = Word8
type PixelDepth PixelYA16 Source # 
type PixelDepth PixelYA16 = Word16
type PixelDepth PixelRGBF Source # 
type PixelDepth PixelRGBF = Float
type PixelDepth PixelRGBA8 Source # 
type PixelDepth PixelRGBA8 = Word8
type PixelDepth PixelRGBA16 Source # 
type PixelDepth PixelRGBA16 = Word16
type PixelDepth PixelRGB8 Source # 
type PixelDepth PixelRGB8 = Word8
type PixelDepth PixelRGB16 Source # 
type PixelDepth PixelRGB16 = Word16
type PixelDepth PixelF Source # 
type PixelDepth PixelF = Float
type PixelDepth PixelCMYK8 Source # 
type PixelDepth PixelCMYK8 = Word8
type PixelDepth PixelCMYK16 Source # 
type PixelDepth PixelCMYK16 = Word16
type PixelDepth Pixel8 Source # 
type PixelDepth Pixel8 = Word8
type PixelDepth Pixel16 Source # 
type PixelDepth Pixel16 = Word16

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 # 

Methods

sizeOf :: PixelYA8 -> Int #

alignment :: PixelYA8 -> Int #

peekElemOff :: Ptr PixelYA8 -> Int -> IO PixelYA8 #

pokeElemOff :: Ptr PixelYA8 -> Int -> PixelYA8 -> IO () #

peekByteOff :: Ptr b -> Int -> IO PixelYA8 #

pokeByteOff :: Ptr b -> Int -> PixelYA8 -> IO () #

peek :: Ptr PixelYA8 -> IO PixelYA8 #

poke :: Ptr PixelYA8 -> PixelYA8 -> IO () #

Storable PixelYA16 Source # 

Methods

sizeOf :: PixelYA16 -> Int #

alignment :: PixelYA16 -> Int #

peekElemOff :: Ptr PixelYA16 -> Int -> IO PixelYA16 #

pokeElemOff :: Ptr PixelYA16 -> Int -> PixelYA16 -> IO () #

peekByteOff :: Ptr b -> Int -> IO PixelYA16 #

pokeByteOff :: Ptr b -> Int -> PixelYA16 -> IO () #

peek :: Ptr PixelYA16 -> IO PixelYA16 #

poke :: Ptr PixelYA16 -> PixelYA16 -> IO () #

Storable PixelRGBF Source # 

Methods

sizeOf :: PixelRGBF -> Int #

alignment :: PixelRGBF -> Int #

peekElemOff :: Ptr PixelRGBF -> Int -> IO PixelRGBF #

pokeElemOff :: Ptr PixelRGBF -> Int -> PixelRGBF -> IO () #

peekByteOff :: Ptr b -> Int -> IO PixelRGBF #

pokeByteOff :: Ptr b -> Int -> PixelRGBF -> IO () #

peek :: Ptr PixelRGBF -> IO PixelRGBF #

poke :: Ptr PixelRGBF -> PixelRGBF -> IO () #

Storable PixelRGBA8 Source # 

Methods

sizeOf :: PixelRGBA8 -> Int #

alignment :: PixelRGBA8 -> Int #

peekElemOff :: Ptr PixelRGBA8 -> Int -> IO PixelRGBA8 #

pokeElemOff :: Ptr PixelRGBA8 -> Int -> PixelRGBA8 -> IO () #

peekByteOff :: Ptr b -> Int -> IO PixelRGBA8 #

pokeByteOff :: Ptr b -> Int -> PixelRGBA8 -> IO () #

peek :: Ptr PixelRGBA8 -> IO PixelRGBA8 #

poke :: Ptr PixelRGBA8 -> PixelRGBA8 -> IO () #

Storable PixelRGBA16 Source # 

Methods

sizeOf :: PixelRGBA16 -> Int #

alignment :: PixelRGBA16 -> Int #

peekElemOff :: Ptr PixelRGBA16 -> Int -> IO PixelRGBA16 #

pokeElemOff :: Ptr PixelRGBA16 -> Int -> PixelRGBA16 -> IO () #

peekByteOff :: Ptr b -> Int -> IO PixelRGBA16 #

pokeByteOff :: Ptr b -> Int -> PixelRGBA16 -> IO () #

peek :: Ptr PixelRGBA16 -> IO PixelRGBA16 #

poke :: Ptr PixelRGBA16 -> PixelRGBA16 -> IO () #

Storable PixelRGB8 Source # 

Methods

sizeOf :: PixelRGB8 -> Int #

alignment :: PixelRGB8 -> Int #

peekElemOff :: Ptr PixelRGB8 -> Int -> IO PixelRGB8 #

pokeElemOff :: Ptr PixelRGB8 -> Int -> PixelRGB8 -> IO () #

peekByteOff :: Ptr b -> Int -> IO PixelRGB8 #

pokeByteOff :: Ptr b -> Int -> PixelRGB8 -> IO () #

peek :: Ptr PixelRGB8 -> IO PixelRGB8 #

poke :: Ptr PixelRGB8 -> PixelRGB8 -> IO () #

Storable PixelRGB16 Source # 

Methods

sizeOf :: PixelRGB16 -> Int #

alignment :: PixelRGB16 -> Int #

peekElemOff :: Ptr PixelRGB16 -> Int -> IO PixelRGB16 #

pokeElemOff :: Ptr PixelRGB16 -> Int -> PixelRGB16 -> IO () #

peekByteOff :: Ptr b -> Int -> IO PixelRGB16 #

pokeByteOff :: Ptr b -> Int -> PixelRGB16 -> IO () #

peek :: Ptr PixelRGB16 -> IO PixelRGB16 #

poke :: Ptr PixelRGB16 -> PixelRGB16 -> IO () #