never executed always true always false
    1 {-# language CPP #-}
    2 {-# language MultiParamTypeClasses #-}
    3 
    4 #ifndef ENABLE_INTERNAL_DOCUMENTATION
    5 {-# OPTIONS_HADDOCK hide #-}
    6 #endif
    7 
    8 #if __GLASGOW_HASKELL__ >= 800
    9 {-# options_ghc -Wno-redundant-constraints #-}
   10 #endif
   11 
   12 module OpenCV.Internal.ImgProc.MiscImgTransform.ColorCodes where
   13 
   14 import "base" Data.Int ( Int32 )
   15 import "base" Data.Proxy ( Proxy(..) )
   16 import "base" Data.Word
   17 import "base" GHC.TypeLits
   18 import "this" OpenCV.Internal.ImgProc.MiscImgTransform
   19 import "this" OpenCV.TypeLevel
   20 
   21 --------------------------------------------------------------------------------
   22 
   23 {- | Valid color conversions described by the following graph:
   24 
   25 <<doc/color_conversions.png>>
   26 -}
   27 class ColorConversion (fromColor :: ColorCode) (toColor :: ColorCode) where
   28     colorConversionCode :: Proxy fromColor -> Proxy toColor -> Int32
   29 
   30 -- | Names of color encodings
   31 data ColorCode
   32     = BayerBG   -- ^ ('bayerBG') Bayer pattern with BG in the second row, second and third column
   33     | BayerGB   -- ^ ('bayerGB') Bayer pattern with GB in the second row, second and third column
   34     | BayerGR   -- ^ ('bayerGR') Bayer pattern with GR in the second row, second and third column
   35     | BayerRG   -- ^ ('bayerRG') Bayer pattern with RG in the second row, second and third column
   36 
   37     | BGR       -- ^ ('bgr') 24 bit RGB color space with channels: (B8:G8:R8)
   38     | BGR555    -- ^ ('bgr555') 15 bit RGB color space
   39     | BGR565    -- ^ ('bgr565') 16 bit RGB color space
   40 
   41     | BGRA      -- ^ ('bgra') 32 bit RGBA color space with channels: (B8:G8:R8:A8)
   42     | BGRA_I420 -- ^ ('bgra_I420')
   43     | BGRA_IYUV -- ^ ('bgra_IYUV')
   44     | BGRA_NV12 -- ^ ('bgra_NV12')
   45     | BGRA_NV21 -- ^ ('bgra_NV21')
   46     | BGRA_UYNV -- ^ ('bgra_UYNV')
   47     | BGRA_UYVY -- ^ ('bgra_UYVY')
   48     | BGRA_Y422 -- ^ ('bgra_Y422')
   49     | BGRA_YUNV -- ^ ('bgra_YUNV')
   50     | BGRA_YUY2 -- ^ ('bgra_YUY2')
   51     | BGRA_YUYV -- ^ ('bgra_YUYV')
   52     | BGRA_YV12 -- ^ ('bgra_YV12')
   53     | BGRA_YVYU -- ^ ('bgra_YVYU')
   54 
   55     | BGR_EA    -- ^ ('bgr_EA') Edge-Aware
   56     | BGR_FULL  -- ^ ('bgr_FULL')
   57     | BGR_I420  -- ^ ('bgr_I420')
   58     | BGR_IYUV  -- ^ ('bgr_IYUV')
   59     | BGR_NV12  -- ^ ('bgr_NV12')
   60     | BGR_NV21  -- ^ ('bgr_NV21')
   61     | BGR_UYNV  -- ^ ('bgr_UYNV')
   62     | BGR_UYVY  -- ^ ('bgr_UYVY')
   63     | BGR_VNG   -- ^ ('bgr_VNG')
   64     | BGR_Y422  -- ^ ('bgr_Y422')
   65     | BGR_YUNV  -- ^ ('bgr_YUNV')
   66     | BGR_YUY2  -- ^ ('bgr_YUY2')
   67     | BGR_YUYV  -- ^ ('bgr_YUYV')
   68     | BGR_YV12  -- ^ ('bgr_YV12')
   69     | BGR_YVYU  -- ^ ('bgr_YVYU')
   70 
   71     | GRAY      -- ^ ('gray') 8 bit single channel color space
   72     | GRAY_420  -- ^ ('gray_420')
   73     | GRAY_I420 -- ^ ('gray_I420')
   74     | GRAY_IYUV -- ^ ('gray_IYUV')
   75     | GRAY_NV12 -- ^ ('gray_NV12')
   76     | GRAY_NV21 -- ^ ('gray_NV21')
   77     | GRAY_UYNV -- ^ ('gray_UYNV')
   78     | GRAY_UYVY -- ^ ('gray_UYVY')
   79     | GRAY_Y422 -- ^ ('gray_Y422')
   80     | GRAY_YUNV -- ^ ('gray_YUNV')
   81     | GRAY_YUY2 -- ^ ('gray_YUY2')
   82     | GRAY_YUYV -- ^ ('gray_YUYV')
   83     | GRAY_YV12 -- ^ ('gray_YV12')
   84     | GRAY_YVYU -- ^ ('gray_YVYU')
   85 
   86     | HLS       -- ^ ('hls')
   87     | HLS_FULL  -- ^ ('hls_FULL')
   88     | HSV       -- ^ ('hsv')
   89     | HSV_FULL  -- ^ ('hsv_FULL')
   90     | Lab       -- ^ ('lab')
   91     | LBGR      -- ^ ('lbgr')
   92     | LRGB      -- ^ ('lrgb')
   93     | Luv       -- ^ ('luv')
   94     | MRGBA     -- ^ ('mrgba')
   95     | RGB       -- ^ ('rgb') 24 bit RGB color space with channels: (R8:G8:B8)
   96 
   97     | RGBA      -- ^ ('rgba')
   98     | RGBA_I420 -- ^ ('rgba_I420')
   99     | RGBA_IYUV -- ^ ('rgba_IYUV')
  100     | RGBA_NV12 -- ^ ('rgba_NV12')
  101     | RGBA_NV21 -- ^ ('rgba_NV21')
  102     | RGBA_UYNV -- ^ ('rgba_UYNV')
  103     | RGBA_UYVY -- ^ ('rgba_UYVY')
  104     | RGBA_Y422 -- ^ ('rgba_Y422')
  105     | RGBA_YUNV -- ^ ('rgba_YUNV')
  106     | RGBA_YUY2 -- ^ ('rgba_YUY2')
  107     | RGBA_YUYV -- ^ ('rgba_YUYV')
  108     | RGBA_YV12 -- ^ ('rgba_YV12')
  109     | RGBA_YVYU -- ^ ('rgba_YVYU')
  110 
  111     | RGB_EA    -- ^ ('rgb_EA') Edge-Aware
  112     | RGB_FULL  -- ^ ('rgb_FULL')
  113     | RGB_I420  -- ^ ('rgb_I420')
  114     | RGB_IYUV  -- ^ ('rgb_IYUV')
  115     | RGB_NV12  -- ^ ('rgb_NV12')
  116     | RGB_NV21  -- ^ ('rgb_NV21')
  117     | RGB_UYNV  -- ^ ('rgb_UYNV')
  118     | RGB_UYVY  -- ^ ('rgb_UYVY')
  119     | RGB_VNG   -- ^ ('rgb_VNG')
  120     | RGB_Y422  -- ^ ('rgb_Y422')
  121     | RGB_YUNV  -- ^ ('rgb_YUNV')
  122     | RGB_YUY2  -- ^ ('rgb_YUY2')
  123     | RGB_YUYV  -- ^ ('rgb_YUYV')
  124     | RGB_YV12  -- ^ ('rgb_YV12')
  125     | RGB_YVYU  -- ^ ('rgb_YVYU')
  126 
  127     | XYZ       -- ^ ('xyz')
  128     | YCrCb     -- ^ ('yCrCb')
  129 
  130     | YUV       -- ^ ('yuv')
  131     | YUV420p   -- ^ ('yuv420p')
  132     | YUV420sp  -- ^ ('yuv420sp')
  133     | YUV_I420  -- ^ ('yuv_I420')
  134     | YUV_IYUV  -- ^ ('yuv_IYUV')
  135     | YUV_YV12  -- ^ ('yuv_YV12')
  136 
  137 --------------------------------------------------------------------------------
  138 
  139 bayerBG    :: Proxy 'BayerBG  ; bayerBG    = Proxy
  140 bayerGB    :: Proxy 'BayerGB  ; bayerGB    = Proxy
  141 bayerGR    :: Proxy 'BayerGR  ; bayerGR    = Proxy
  142 bayerRG    :: Proxy 'BayerRG  ; bayerRG    = Proxy
  143 bgr        :: Proxy 'BGR      ; bgr        = Proxy
  144 bgr555     :: Proxy 'BGR555   ; bgr555     = Proxy
  145 bgr565     :: Proxy 'BGR565   ; bgr565     = Proxy
  146 bgra       :: Proxy 'BGRA     ; bgra       = Proxy
  147 bgra_I420  :: Proxy 'BGRA_I420; bgra_I420  = Proxy
  148 bgra_IYUV  :: Proxy 'BGRA_IYUV; bgra_IYUV  = Proxy
  149 bgra_NV12  :: Proxy 'BGRA_NV12; bgra_NV12  = Proxy
  150 bgra_NV21  :: Proxy 'BGRA_NV21; bgra_NV21  = Proxy
  151 bgra_UYNV  :: Proxy 'BGRA_UYNV; bgra_UYNV  = Proxy
  152 bgra_UYVY  :: Proxy 'BGRA_UYVY; bgra_UYVY  = Proxy
  153 bgra_Y422  :: Proxy 'BGRA_Y422; bgra_Y422  = Proxy
  154 bgra_YUNV  :: Proxy 'BGRA_YUNV; bgra_YUNV  = Proxy
  155 bgra_YUY2  :: Proxy 'BGRA_YUY2; bgra_YUY2  = Proxy
  156 bgra_YUYV  :: Proxy 'BGRA_YUYV; bgra_YUYV  = Proxy
  157 bgra_YV12  :: Proxy 'BGRA_YV12; bgra_YV12  = Proxy
  158 bgra_YVYU  :: Proxy 'BGRA_YVYU; bgra_YVYU  = Proxy
  159 bgr_EA     :: Proxy 'BGR_EA   ; bgr_EA     = Proxy
  160 bgr_FULL   :: Proxy 'BGR_FULL ; bgr_FULL   = Proxy
  161 bgr_I420   :: Proxy 'BGR_I420 ; bgr_I420   = Proxy
  162 bgr_IYUV   :: Proxy 'BGR_IYUV ; bgr_IYUV   = Proxy
  163 bgr_NV12   :: Proxy 'BGR_NV12 ; bgr_NV12   = Proxy
  164 bgr_NV21   :: Proxy 'BGR_NV21 ; bgr_NV21   = Proxy
  165 bgr_UYNV   :: Proxy 'BGR_UYNV ; bgr_UYNV   = Proxy
  166 bgr_UYVY   :: Proxy 'BGR_UYVY ; bgr_UYVY   = Proxy
  167 bgr_VNG    :: Proxy 'BGR_VNG  ; bgr_VNG    = Proxy
  168 bgr_Y422   :: Proxy 'BGR_Y422 ; bgr_Y422   = Proxy
  169 bgr_YUNV   :: Proxy 'BGR_YUNV ; bgr_YUNV   = Proxy
  170 bgr_YUY2   :: Proxy 'BGR_YUY2 ; bgr_YUY2   = Proxy
  171 bgr_YUYV   :: Proxy 'BGR_YUYV ; bgr_YUYV   = Proxy
  172 bgr_YV12   :: Proxy 'BGR_YV12 ; bgr_YV12   = Proxy
  173 bgr_YVYU   :: Proxy 'BGR_YVYU ; bgr_YVYU   = Proxy
  174 gray       :: Proxy 'GRAY     ; gray       = Proxy
  175 gray_420   :: Proxy 'GRAY_420 ; gray_420   = Proxy
  176 gray_I420  :: Proxy 'GRAY_I420; gray_I420  = Proxy
  177 gray_IYUV  :: Proxy 'GRAY_IYUV; gray_IYUV  = Proxy
  178 gray_NV12  :: Proxy 'GRAY_NV12; gray_NV12  = Proxy
  179 gray_NV21  :: Proxy 'GRAY_NV21; gray_NV21  = Proxy
  180 gray_UYNV  :: Proxy 'GRAY_UYNV; gray_UYNV  = Proxy
  181 gray_UYVY  :: Proxy 'GRAY_UYVY; gray_UYVY  = Proxy
  182 gray_Y422  :: Proxy 'GRAY_Y422; gray_Y422  = Proxy
  183 gray_YUNV  :: Proxy 'GRAY_YUNV; gray_YUNV  = Proxy
  184 gray_YUY2  :: Proxy 'GRAY_YUY2; gray_YUY2  = Proxy
  185 gray_YUYV  :: Proxy 'GRAY_YUYV; gray_YUYV  = Proxy
  186 gray_YV12  :: Proxy 'GRAY_YV12; gray_YV12  = Proxy
  187 gray_YVYU  :: Proxy 'GRAY_YVYU; gray_YVYU  = Proxy
  188 hls        :: Proxy 'HLS      ; hls        = Proxy
  189 hls_FULL   :: Proxy 'HLS_FULL ; hls_FULL   = Proxy
  190 hsv        :: Proxy 'HSV      ; hsv        = Proxy
  191 hsv_FULL   :: Proxy 'HSV_FULL ; hsv_FULL   = Proxy
  192 lab        :: Proxy 'Lab      ; lab        = Proxy
  193 lbgr       :: Proxy 'LBGR     ; lbgr       = Proxy
  194 lrgb       :: Proxy 'LRGB     ; lrgb       = Proxy
  195 luv        :: Proxy 'Luv      ; luv        = Proxy
  196 mrgba      :: Proxy 'MRGBA    ; mrgba      = Proxy
  197 rgb        :: Proxy 'RGB      ; rgb        = Proxy
  198 rgba       :: Proxy 'RGBA     ; rgba       = Proxy
  199 rgba_I420  :: Proxy 'RGBA_I420; rgba_I420  = Proxy
  200 rgba_IYUV  :: Proxy 'RGBA_IYUV; rgba_IYUV  = Proxy
  201 rgba_NV12  :: Proxy 'RGBA_NV12; rgba_NV12  = Proxy
  202 rgba_NV21  :: Proxy 'RGBA_NV21; rgba_NV21  = Proxy
  203 rgba_UYNV  :: Proxy 'RGBA_UYNV; rgba_UYNV  = Proxy
  204 rgba_UYVY  :: Proxy 'RGBA_UYVY; rgba_UYVY  = Proxy
  205 rgba_Y422  :: Proxy 'RGBA_Y422; rgba_Y422  = Proxy
  206 rgba_YUNV  :: Proxy 'RGBA_YUNV; rgba_YUNV  = Proxy
  207 rgba_YUY2  :: Proxy 'RGBA_YUY2; rgba_YUY2  = Proxy
  208 rgba_YUYV  :: Proxy 'RGBA_YUYV; rgba_YUYV  = Proxy
  209 rgba_YV12  :: Proxy 'RGBA_YV12; rgba_YV12  = Proxy
  210 rgba_YVYU  :: Proxy 'RGBA_YVYU; rgba_YVYU  = Proxy
  211 rgb_EA     :: Proxy 'RGB_EA   ; rgb_EA     = Proxy
  212 rgb_FULL   :: Proxy 'RGB_FULL ; rgb_FULL   = Proxy
  213 rgb_I420   :: Proxy 'RGB_I420 ; rgb_I420   = Proxy
  214 rgb_IYUV   :: Proxy 'RGB_IYUV ; rgb_IYUV   = Proxy
  215 rgb_NV12   :: Proxy 'RGB_NV12 ; rgb_NV12   = Proxy
  216 rgb_NV21   :: Proxy 'RGB_NV21 ; rgb_NV21   = Proxy
  217 rgb_UYNV   :: Proxy 'RGB_UYNV ; rgb_UYNV   = Proxy
  218 rgb_UYVY   :: Proxy 'RGB_UYVY ; rgb_UYVY   = Proxy
  219 rgb_VNG    :: Proxy 'RGB_VNG  ; rgb_VNG    = Proxy
  220 rgb_Y422   :: Proxy 'RGB_Y422 ; rgb_Y422   = Proxy
  221 rgb_YUNV   :: Proxy 'RGB_YUNV ; rgb_YUNV   = Proxy
  222 rgb_YUY2   :: Proxy 'RGB_YUY2 ; rgb_YUY2   = Proxy
  223 rgb_YUYV   :: Proxy 'RGB_YUYV ; rgb_YUYV   = Proxy
  224 rgb_YV12   :: Proxy 'RGB_YV12 ; rgb_YV12   = Proxy
  225 rgb_YVYU   :: Proxy 'RGB_YVYU ; rgb_YVYU   = Proxy
  226 xyz        :: Proxy 'XYZ      ; xyz        = Proxy
  227 yCrCb      :: Proxy 'YCrCb    ; yCrCb      = Proxy
  228 yuv        :: Proxy 'YUV      ; yuv        = Proxy
  229 yuv420p    :: Proxy 'YUV420p  ; yuv420p    = Proxy
  230 yuv420sp   :: Proxy 'YUV420sp ; yuv420sp   = Proxy
  231 yuv_I420   :: Proxy 'YUV_I420 ; yuv_I420   = Proxy
  232 yuv_IYUV   :: Proxy 'YUV_IYUV ; yuv_IYUV   = Proxy
  233 yuv_YV12   :: Proxy 'YUV_YV12 ; yuv_YV12   = Proxy
  234 
  235 --------------------------------------------------------------------------------
  236 
  237 instance ColorConversion 'BGR      'BGRA      where colorConversionCode _ _ = c'COLOR_BGR2BGRA
  238 instance ColorConversion 'RGB      'RGBA      where colorConversionCode _ _ = c'COLOR_RGB2RGBA
  239 instance ColorConversion 'BGRA     'BGR       where colorConversionCode _ _ = c'COLOR_BGRA2BGR
  240 instance ColorConversion 'RGBA     'RGB       where colorConversionCode _ _ = c'COLOR_RGBA2RGB
  241 instance ColorConversion 'BGR      'RGBA      where colorConversionCode _ _ = c'COLOR_BGR2RGBA
  242 instance ColorConversion 'RGB      'BGRA      where colorConversionCode _ _ = c'COLOR_RGB2BGRA
  243 instance ColorConversion 'RGBA     'BGR       where colorConversionCode _ _ = c'COLOR_RGBA2BGR
  244 instance ColorConversion 'BGRA     'RGB       where colorConversionCode _ _ = c'COLOR_BGRA2RGB
  245 instance ColorConversion 'BGR      'RGB       where colorConversionCode _ _ = c'COLOR_BGR2RGB
  246 instance ColorConversion 'RGB      'BGR       where colorConversionCode _ _ = c'COLOR_RGB2BGR
  247 instance ColorConversion 'BGRA     'RGBA      where colorConversionCode _ _ = c'COLOR_BGRA2RGBA
  248 instance ColorConversion 'RGBA     'BGRA      where colorConversionCode _ _ = c'COLOR_RGBA2BGRA
  249 instance ColorConversion 'BGR      'GRAY      where colorConversionCode _ _ = c'COLOR_BGR2GRAY
  250 instance ColorConversion 'RGB      'GRAY      where colorConversionCode _ _ = c'COLOR_RGB2GRAY
  251 instance ColorConversion 'GRAY     'BGR       where colorConversionCode _ _ = c'COLOR_GRAY2BGR
  252 instance ColorConversion 'GRAY     'RGB       where colorConversionCode _ _ = c'COLOR_GRAY2RGB
  253 instance ColorConversion 'GRAY     'BGRA      where colorConversionCode _ _ = c'COLOR_GRAY2BGRA
  254 instance ColorConversion 'GRAY     'RGBA      where colorConversionCode _ _ = c'COLOR_GRAY2RGBA
  255 instance ColorConversion 'BGRA     'GRAY      where colorConversionCode _ _ = c'COLOR_BGRA2GRAY
  256 instance ColorConversion 'RGBA     'GRAY      where colorConversionCode _ _ = c'COLOR_RGBA2GRAY
  257 instance ColorConversion 'BGR      'BGR565    where colorConversionCode _ _ = c'COLOR_BGR2BGR565
  258 instance ColorConversion 'RGB      'BGR565    where colorConversionCode _ _ = c'COLOR_RGB2BGR565
  259 instance ColorConversion 'BGR565   'BGR       where colorConversionCode _ _ = c'COLOR_BGR5652BGR
  260 instance ColorConversion 'BGR565   'RGB       where colorConversionCode _ _ = c'COLOR_BGR5652RGB
  261 instance ColorConversion 'BGRA     'BGR565    where colorConversionCode _ _ = c'COLOR_BGRA2BGR565
  262 instance ColorConversion 'RGBA     'BGR565    where colorConversionCode _ _ = c'COLOR_RGBA2BGR565
  263 instance ColorConversion 'BGR565   'BGRA      where colorConversionCode _ _ = c'COLOR_BGR5652BGRA
  264 instance ColorConversion 'BGR565   'RGBA      where colorConversionCode _ _ = c'COLOR_BGR5652RGBA
  265 instance ColorConversion 'GRAY     'BGR565    where colorConversionCode _ _ = c'COLOR_GRAY2BGR565
  266 instance ColorConversion 'BGR565   'GRAY      where colorConversionCode _ _ = c'COLOR_BGR5652GRAY
  267 instance ColorConversion 'BGR      'BGR555    where colorConversionCode _ _ = c'COLOR_BGR2BGR555
  268 instance ColorConversion 'RGB      'BGR555    where colorConversionCode _ _ = c'COLOR_RGB2BGR555
  269 instance ColorConversion 'BGR555   'BGR       where colorConversionCode _ _ = c'COLOR_BGR5552BGR
  270 instance ColorConversion 'BGR555   'RGB       where colorConversionCode _ _ = c'COLOR_BGR5552RGB
  271 instance ColorConversion 'BGRA     'BGR555    where colorConversionCode _ _ = c'COLOR_BGRA2BGR555
  272 instance ColorConversion 'RGBA     'BGR555    where colorConversionCode _ _ = c'COLOR_RGBA2BGR555
  273 instance ColorConversion 'BGR555   'BGRA      where colorConversionCode _ _ = c'COLOR_BGR5552BGRA
  274 instance ColorConversion 'BGR555   'RGBA      where colorConversionCode _ _ = c'COLOR_BGR5552RGBA
  275 instance ColorConversion 'GRAY     'BGR555    where colorConversionCode _ _ = c'COLOR_GRAY2BGR555
  276 instance ColorConversion 'BGR555   'GRAY      where colorConversionCode _ _ = c'COLOR_BGR5552GRAY
  277 instance ColorConversion 'BGR      'XYZ       where colorConversionCode _ _ = c'COLOR_BGR2XYZ
  278 instance ColorConversion 'RGB      'XYZ       where colorConversionCode _ _ = c'COLOR_RGB2XYZ
  279 instance ColorConversion 'XYZ      'BGR       where colorConversionCode _ _ = c'COLOR_XYZ2BGR
  280 instance ColorConversion 'XYZ      'RGB       where colorConversionCode _ _ = c'COLOR_XYZ2RGB
  281 instance ColorConversion 'BGR      'YCrCb     where colorConversionCode _ _ = c'COLOR_BGR2YCrCb
  282 instance ColorConversion 'RGB      'YCrCb     where colorConversionCode _ _ = c'COLOR_RGB2YCrCb
  283 instance ColorConversion 'YCrCb    'BGR       where colorConversionCode _ _ = c'COLOR_YCrCb2BGR
  284 instance ColorConversion 'YCrCb    'RGB       where colorConversionCode _ _ = c'COLOR_YCrCb2RGB
  285 instance ColorConversion 'BGR      'HSV       where colorConversionCode _ _ = c'COLOR_BGR2HSV
  286 instance ColorConversion 'RGB      'HSV       where colorConversionCode _ _ = c'COLOR_RGB2HSV
  287 instance ColorConversion 'BGR      'Lab       where colorConversionCode _ _ = c'COLOR_BGR2Lab
  288 instance ColorConversion 'RGB      'Lab       where colorConversionCode _ _ = c'COLOR_RGB2Lab
  289 instance ColorConversion 'BGR      'Luv       where colorConversionCode _ _ = c'COLOR_BGR2Luv
  290 instance ColorConversion 'RGB      'Luv       where colorConversionCode _ _ = c'COLOR_RGB2Luv
  291 instance ColorConversion 'BGR      'HLS       where colorConversionCode _ _ = c'COLOR_BGR2HLS
  292 instance ColorConversion 'RGB      'HLS       where colorConversionCode _ _ = c'COLOR_RGB2HLS
  293 instance ColorConversion 'HSV      'BGR       where colorConversionCode _ _ = c'COLOR_HSV2BGR
  294 instance ColorConversion 'HSV      'RGB       where colorConversionCode _ _ = c'COLOR_HSV2RGB
  295 instance ColorConversion 'Lab      'BGR       where colorConversionCode _ _ = c'COLOR_Lab2BGR
  296 instance ColorConversion 'Lab      'RGB       where colorConversionCode _ _ = c'COLOR_Lab2RGB
  297 instance ColorConversion 'Luv      'BGR       where colorConversionCode _ _ = c'COLOR_Luv2BGR
  298 instance ColorConversion 'Luv      'RGB       where colorConversionCode _ _ = c'COLOR_Luv2RGB
  299 instance ColorConversion 'HLS      'BGR       where colorConversionCode _ _ = c'COLOR_HLS2BGR
  300 instance ColorConversion 'HLS      'RGB       where colorConversionCode _ _ = c'COLOR_HLS2RGB
  301 instance ColorConversion 'BGR      'HSV_FULL  where colorConversionCode _ _ = c'COLOR_BGR2HSV_FULL
  302 instance ColorConversion 'RGB      'HSV_FULL  where colorConversionCode _ _ = c'COLOR_RGB2HSV_FULL
  303 instance ColorConversion 'BGR      'HLS_FULL  where colorConversionCode _ _ = c'COLOR_BGR2HLS_FULL
  304 instance ColorConversion 'RGB      'HLS_FULL  where colorConversionCode _ _ = c'COLOR_RGB2HLS_FULL
  305 instance ColorConversion 'HSV      'BGR_FULL  where colorConversionCode _ _ = c'COLOR_HSV2BGR_FULL
  306 instance ColorConversion 'HSV      'RGB_FULL  where colorConversionCode _ _ = c'COLOR_HSV2RGB_FULL
  307 instance ColorConversion 'HLS      'BGR_FULL  where colorConversionCode _ _ = c'COLOR_HLS2BGR_FULL
  308 instance ColorConversion 'HLS      'RGB_FULL  where colorConversionCode _ _ = c'COLOR_HLS2RGB_FULL
  309 instance ColorConversion 'LBGR     'Lab       where colorConversionCode _ _ = c'COLOR_LBGR2Lab
  310 instance ColorConversion 'LRGB     'Lab       where colorConversionCode _ _ = c'COLOR_LRGB2Lab
  311 instance ColorConversion 'LBGR     'Luv       where colorConversionCode _ _ = c'COLOR_LBGR2Luv
  312 instance ColorConversion 'LRGB     'Luv       where colorConversionCode _ _ = c'COLOR_LRGB2Luv
  313 instance ColorConversion 'Lab      'LBGR      where colorConversionCode _ _ = c'COLOR_Lab2LBGR
  314 instance ColorConversion 'Lab      'LRGB      where colorConversionCode _ _ = c'COLOR_Lab2LRGB
  315 instance ColorConversion 'Luv      'LBGR      where colorConversionCode _ _ = c'COLOR_Luv2LBGR
  316 instance ColorConversion 'Luv      'LRGB      where colorConversionCode _ _ = c'COLOR_Luv2LRGB
  317 instance ColorConversion 'BGR      'YUV       where colorConversionCode _ _ = c'COLOR_BGR2YUV
  318 instance ColorConversion 'RGB      'YUV       where colorConversionCode _ _ = c'COLOR_RGB2YUV
  319 instance ColorConversion 'YUV      'BGR       where colorConversionCode _ _ = c'COLOR_YUV2BGR
  320 instance ColorConversion 'YUV      'RGB       where colorConversionCode _ _ = c'COLOR_YUV2RGB
  321 instance ColorConversion 'YUV      'RGB_NV12  where colorConversionCode _ _ = c'COLOR_YUV2RGB_NV12
  322 instance ColorConversion 'YUV      'BGR_NV12  where colorConversionCode _ _ = c'COLOR_YUV2BGR_NV12
  323 instance ColorConversion 'YUV      'RGB_NV21  where colorConversionCode _ _ = c'COLOR_YUV2RGB_NV21
  324 instance ColorConversion 'YUV      'BGR_NV21  where colorConversionCode _ _ = c'COLOR_YUV2BGR_NV21
  325 instance ColorConversion 'YUV420sp 'RGB       where colorConversionCode _ _ = c'COLOR_YUV420sp2RGB
  326 instance ColorConversion 'YUV420sp 'BGR       where colorConversionCode _ _ = c'COLOR_YUV420sp2BGR
  327 instance ColorConversion 'YUV      'RGBA_NV12 where colorConversionCode _ _ = c'COLOR_YUV2RGBA_NV12
  328 instance ColorConversion 'YUV      'BGRA_NV12 where colorConversionCode _ _ = c'COLOR_YUV2BGRA_NV12
  329 instance ColorConversion 'YUV      'RGBA_NV21 where colorConversionCode _ _ = c'COLOR_YUV2RGBA_NV21
  330 instance ColorConversion 'YUV      'BGRA_NV21 where colorConversionCode _ _ = c'COLOR_YUV2BGRA_NV21
  331 instance ColorConversion 'YUV420sp 'RGBA      where colorConversionCode _ _ = c'COLOR_YUV420sp2RGBA
  332 instance ColorConversion 'YUV420sp 'BGRA      where colorConversionCode _ _ = c'COLOR_YUV420sp2BGRA
  333 instance ColorConversion 'YUV      'RGB_YV12  where colorConversionCode _ _ = c'COLOR_YUV2RGB_YV12
  334 instance ColorConversion 'YUV      'BGR_YV12  where colorConversionCode _ _ = c'COLOR_YUV2BGR_YV12
  335 instance ColorConversion 'YUV      'RGB_IYUV  where colorConversionCode _ _ = c'COLOR_YUV2RGB_IYUV
  336 instance ColorConversion 'YUV      'BGR_IYUV  where colorConversionCode _ _ = c'COLOR_YUV2BGR_IYUV
  337 instance ColorConversion 'YUV      'RGB_I420  where colorConversionCode _ _ = c'COLOR_YUV2RGB_I420
  338 instance ColorConversion 'YUV      'BGR_I420  where colorConversionCode _ _ = c'COLOR_YUV2BGR_I420
  339 instance ColorConversion 'YUV420p  'RGB       where colorConversionCode _ _ = c'COLOR_YUV420p2RGB
  340 instance ColorConversion 'YUV420p  'BGR       where colorConversionCode _ _ = c'COLOR_YUV420p2BGR
  341 instance ColorConversion 'YUV      'RGBA_YV12 where colorConversionCode _ _ = c'COLOR_YUV2RGBA_YV12
  342 instance ColorConversion 'YUV      'BGRA_YV12 where colorConversionCode _ _ = c'COLOR_YUV2BGRA_YV12
  343 instance ColorConversion 'YUV      'RGBA_IYUV where colorConversionCode _ _ = c'COLOR_YUV2RGBA_IYUV
  344 instance ColorConversion 'YUV      'BGRA_IYUV where colorConversionCode _ _ = c'COLOR_YUV2BGRA_IYUV
  345 instance ColorConversion 'YUV      'RGBA_I420 where colorConversionCode _ _ = c'COLOR_YUV2RGBA_I420
  346 instance ColorConversion 'YUV      'BGRA_I420 where colorConversionCode _ _ = c'COLOR_YUV2BGRA_I420
  347 instance ColorConversion 'YUV420p  'RGBA      where colorConversionCode _ _ = c'COLOR_YUV420p2RGBA
  348 instance ColorConversion 'YUV420p  'BGRA      where colorConversionCode _ _ = c'COLOR_YUV420p2BGRA
  349 instance ColorConversion 'YUV      'GRAY_420  where colorConversionCode _ _ = c'COLOR_YUV2GRAY_420
  350 instance ColorConversion 'YUV      'GRAY_NV21 where colorConversionCode _ _ = c'COLOR_YUV2GRAY_NV21
  351 instance ColorConversion 'YUV      'GRAY_NV12 where colorConversionCode _ _ = c'COLOR_YUV2GRAY_NV12
  352 instance ColorConversion 'YUV      'GRAY_YV12 where colorConversionCode _ _ = c'COLOR_YUV2GRAY_YV12
  353 instance ColorConversion 'YUV      'GRAY_IYUV where colorConversionCode _ _ = c'COLOR_YUV2GRAY_IYUV
  354 instance ColorConversion 'YUV      'GRAY_I420 where colorConversionCode _ _ = c'COLOR_YUV2GRAY_I420
  355 instance ColorConversion 'YUV420sp 'GRAY      where colorConversionCode _ _ = c'COLOR_YUV420sp2GRAY
  356 instance ColorConversion 'YUV420p  'GRAY      where colorConversionCode _ _ = c'COLOR_YUV420p2GRAY
  357 instance ColorConversion 'YUV      'RGB_UYVY  where colorConversionCode _ _ = c'COLOR_YUV2RGB_UYVY
  358 instance ColorConversion 'YUV      'BGR_UYVY  where colorConversionCode _ _ = c'COLOR_YUV2BGR_UYVY
  359 instance ColorConversion 'YUV      'RGB_Y422  where colorConversionCode _ _ = c'COLOR_YUV2RGB_Y422
  360 instance ColorConversion 'YUV      'BGR_Y422  where colorConversionCode _ _ = c'COLOR_YUV2BGR_Y422
  361 instance ColorConversion 'YUV      'RGB_UYNV  where colorConversionCode _ _ = c'COLOR_YUV2RGB_UYNV
  362 instance ColorConversion 'YUV      'BGR_UYNV  where colorConversionCode _ _ = c'COLOR_YUV2BGR_UYNV
  363 instance ColorConversion 'YUV      'RGBA_UYVY where colorConversionCode _ _ = c'COLOR_YUV2RGBA_UYVY
  364 instance ColorConversion 'YUV      'BGRA_UYVY where colorConversionCode _ _ = c'COLOR_YUV2BGRA_UYVY
  365 instance ColorConversion 'YUV      'RGBA_Y422 where colorConversionCode _ _ = c'COLOR_YUV2RGBA_Y422
  366 instance ColorConversion 'YUV      'BGRA_Y422 where colorConversionCode _ _ = c'COLOR_YUV2BGRA_Y422
  367 instance ColorConversion 'YUV      'RGBA_UYNV where colorConversionCode _ _ = c'COLOR_YUV2RGBA_UYNV
  368 instance ColorConversion 'YUV      'BGRA_UYNV where colorConversionCode _ _ = c'COLOR_YUV2BGRA_UYNV
  369 instance ColorConversion 'YUV      'RGB_YUY2  where colorConversionCode _ _ = c'COLOR_YUV2RGB_YUY2
  370 instance ColorConversion 'YUV      'BGR_YUY2  where colorConversionCode _ _ = c'COLOR_YUV2BGR_YUY2
  371 instance ColorConversion 'YUV      'RGB_YVYU  where colorConversionCode _ _ = c'COLOR_YUV2RGB_YVYU
  372 instance ColorConversion 'YUV      'BGR_YVYU  where colorConversionCode _ _ = c'COLOR_YUV2BGR_YVYU
  373 instance ColorConversion 'YUV      'RGB_YUYV  where colorConversionCode _ _ = c'COLOR_YUV2RGB_YUYV
  374 instance ColorConversion 'YUV      'BGR_YUYV  where colorConversionCode _ _ = c'COLOR_YUV2BGR_YUYV
  375 instance ColorConversion 'YUV      'RGB_YUNV  where colorConversionCode _ _ = c'COLOR_YUV2RGB_YUNV
  376 instance ColorConversion 'YUV      'BGR_YUNV  where colorConversionCode _ _ = c'COLOR_YUV2BGR_YUNV
  377 instance ColorConversion 'YUV      'RGBA_YUY2 where colorConversionCode _ _ = c'COLOR_YUV2RGBA_YUY2
  378 instance ColorConversion 'YUV      'BGRA_YUY2 where colorConversionCode _ _ = c'COLOR_YUV2BGRA_YUY2
  379 instance ColorConversion 'YUV      'RGBA_YVYU where colorConversionCode _ _ = c'COLOR_YUV2RGBA_YVYU
  380 instance ColorConversion 'YUV      'BGRA_YVYU where colorConversionCode _ _ = c'COLOR_YUV2BGRA_YVYU
  381 instance ColorConversion 'YUV      'RGBA_YUYV where colorConversionCode _ _ = c'COLOR_YUV2RGBA_YUYV
  382 instance ColorConversion 'YUV      'BGRA_YUYV where colorConversionCode _ _ = c'COLOR_YUV2BGRA_YUYV
  383 instance ColorConversion 'YUV      'RGBA_YUNV where colorConversionCode _ _ = c'COLOR_YUV2RGBA_YUNV
  384 instance ColorConversion 'YUV      'BGRA_YUNV where colorConversionCode _ _ = c'COLOR_YUV2BGRA_YUNV
  385 instance ColorConversion 'YUV      'GRAY_UYVY where colorConversionCode _ _ = c'COLOR_YUV2GRAY_UYVY
  386 instance ColorConversion 'YUV      'GRAY_YUY2 where colorConversionCode _ _ = c'COLOR_YUV2GRAY_YUY2
  387 instance ColorConversion 'YUV      'GRAY_Y422 where colorConversionCode _ _ = c'COLOR_YUV2GRAY_Y422
  388 instance ColorConversion 'YUV      'GRAY_UYNV where colorConversionCode _ _ = c'COLOR_YUV2GRAY_UYNV
  389 instance ColorConversion 'YUV      'GRAY_YVYU where colorConversionCode _ _ = c'COLOR_YUV2GRAY_YVYU
  390 instance ColorConversion 'YUV      'GRAY_YUYV where colorConversionCode _ _ = c'COLOR_YUV2GRAY_YUYV
  391 instance ColorConversion 'YUV      'GRAY_YUNV where colorConversionCode _ _ = c'COLOR_YUV2GRAY_YUNV
  392 instance ColorConversion 'RGBA     'MRGBA     where colorConversionCode _ _ = c'COLOR_RGBA2mRGBA
  393 instance ColorConversion 'MRGBA    'RGBA      where colorConversionCode _ _ = c'COLOR_mRGBA2RGBA
  394 instance ColorConversion 'RGB      'YUV_I420  where colorConversionCode _ _ = c'COLOR_RGB2YUV_I420
  395 instance ColorConversion 'BGR      'YUV_I420  where colorConversionCode _ _ = c'COLOR_BGR2YUV_I420
  396 instance ColorConversion 'RGB      'YUV_IYUV  where colorConversionCode _ _ = c'COLOR_RGB2YUV_IYUV
  397 instance ColorConversion 'BGR      'YUV_IYUV  where colorConversionCode _ _ = c'COLOR_BGR2YUV_IYUV
  398 instance ColorConversion 'RGBA     'YUV_I420  where colorConversionCode _ _ = c'COLOR_RGBA2YUV_I420
  399 instance ColorConversion 'BGRA     'YUV_I420  where colorConversionCode _ _ = c'COLOR_BGRA2YUV_I420
  400 instance ColorConversion 'RGBA     'YUV_IYUV  where colorConversionCode _ _ = c'COLOR_RGBA2YUV_IYUV
  401 instance ColorConversion 'BGRA     'YUV_IYUV  where colorConversionCode _ _ = c'COLOR_BGRA2YUV_IYUV
  402 instance ColorConversion 'RGB      'YUV_YV12  where colorConversionCode _ _ = c'COLOR_RGB2YUV_YV12
  403 instance ColorConversion 'BGR      'YUV_YV12  where colorConversionCode _ _ = c'COLOR_BGR2YUV_YV12
  404 instance ColorConversion 'RGBA     'YUV_YV12  where colorConversionCode _ _ = c'COLOR_RGBA2YUV_YV12
  405 instance ColorConversion 'BGRA     'YUV_YV12  where colorConversionCode _ _ = c'COLOR_BGRA2YUV_YV12
  406 instance ColorConversion 'BayerBG  'BGR       where colorConversionCode _ _ = c'COLOR_BayerBG2BGR
  407 instance ColorConversion 'BayerGB  'BGR       where colorConversionCode _ _ = c'COLOR_BayerGB2BGR
  408 instance ColorConversion 'BayerRG  'BGR       where colorConversionCode _ _ = c'COLOR_BayerRG2BGR
  409 instance ColorConversion 'BayerGR  'BGR       where colorConversionCode _ _ = c'COLOR_BayerGR2BGR
  410 instance ColorConversion 'BayerBG  'RGB       where colorConversionCode _ _ = c'COLOR_BayerBG2RGB
  411 instance ColorConversion 'BayerGB  'RGB       where colorConversionCode _ _ = c'COLOR_BayerGB2RGB
  412 instance ColorConversion 'BayerRG  'RGB       where colorConversionCode _ _ = c'COLOR_BayerRG2RGB
  413 instance ColorConversion 'BayerGR  'RGB       where colorConversionCode _ _ = c'COLOR_BayerGR2RGB
  414 instance ColorConversion 'BayerBG  'GRAY      where colorConversionCode _ _ = c'COLOR_BayerBG2GRAY
  415 instance ColorConversion 'BayerGB  'GRAY      where colorConversionCode _ _ = c'COLOR_BayerGB2GRAY
  416 instance ColorConversion 'BayerRG  'GRAY      where colorConversionCode _ _ = c'COLOR_BayerRG2GRAY
  417 instance ColorConversion 'BayerGR  'GRAY      where colorConversionCode _ _ = c'COLOR_BayerGR2GRAY
  418 instance ColorConversion 'BayerBG  'BGR_VNG   where colorConversionCode _ _ = c'COLOR_BayerBG2BGR_VNG
  419 instance ColorConversion 'BayerGB  'BGR_VNG   where colorConversionCode _ _ = c'COLOR_BayerGB2BGR_VNG
  420 instance ColorConversion 'BayerRG  'BGR_VNG   where colorConversionCode _ _ = c'COLOR_BayerRG2BGR_VNG
  421 instance ColorConversion 'BayerGR  'BGR_VNG   where colorConversionCode _ _ = c'COLOR_BayerGR2BGR_VNG
  422 instance ColorConversion 'BayerBG  'RGB_VNG   where colorConversionCode _ _ = c'COLOR_BayerBG2RGB_VNG
  423 instance ColorConversion 'BayerGB  'RGB_VNG   where colorConversionCode _ _ = c'COLOR_BayerGB2RGB_VNG
  424 instance ColorConversion 'BayerRG  'RGB_VNG   where colorConversionCode _ _ = c'COLOR_BayerRG2RGB_VNG
  425 instance ColorConversion 'BayerGR  'RGB_VNG   where colorConversionCode _ _ = c'COLOR_BayerGR2RGB_VNG
  426 instance ColorConversion 'BayerBG  'BGR_EA    where colorConversionCode _ _ = c'COLOR_BayerBG2BGR_EA
  427 instance ColorConversion 'BayerGB  'BGR_EA    where colorConversionCode _ _ = c'COLOR_BayerGB2BGR_EA
  428 instance ColorConversion 'BayerRG  'BGR_EA    where colorConversionCode _ _ = c'COLOR_BayerRG2BGR_EA
  429 instance ColorConversion 'BayerGR  'BGR_EA    where colorConversionCode _ _ = c'COLOR_BayerGR2BGR_EA
  430 instance ColorConversion 'BayerBG  'RGB_EA    where colorConversionCode _ _ = c'COLOR_BayerBG2RGB_EA
  431 instance ColorConversion 'BayerGB  'RGB_EA    where colorConversionCode _ _ = c'COLOR_BayerGB2RGB_EA
  432 instance ColorConversion 'BayerRG  'RGB_EA    where colorConversionCode _ _ = c'COLOR_BayerRG2RGB_EA
  433 instance ColorConversion 'BayerGR  'RGB_EA    where colorConversionCode _ _ = c'COLOR_BayerGR2RGB_EA
  434 
  435 -- | Gives the number of channels associated with a particular color encoding
  436 type family ColorCodeChannels (cc :: ColorCode) :: Nat where
  437   ColorCodeChannels 'BayerBG   = 1
  438   ColorCodeChannels 'BayerGB   = 1
  439   ColorCodeChannels 'BayerGR   = 1
  440   ColorCodeChannels 'BayerRG   = 1
  441   ColorCodeChannels 'BGR       = 3
  442   ColorCodeChannels 'BGR555    = 2
  443   ColorCodeChannels 'BGR565    = 2
  444   ColorCodeChannels 'BGRA      = 4
  445   ColorCodeChannels 'BGRA_I420 = 4
  446   ColorCodeChannels 'BGRA_IYUV = 4
  447   ColorCodeChannels 'BGRA_NV12 = 4
  448   ColorCodeChannels 'BGRA_NV21 = 4
  449   ColorCodeChannels 'BGRA_UYNV = 4
  450   ColorCodeChannels 'BGRA_UYVY = 4
  451   ColorCodeChannels 'BGRA_Y422 = 4
  452   ColorCodeChannels 'BGRA_YUNV = 4
  453   ColorCodeChannels 'BGRA_YUY2 = 4
  454   ColorCodeChannels 'BGRA_YUYV = 4
  455   ColorCodeChannels 'BGRA_YV12 = 4
  456   ColorCodeChannels 'BGRA_YVYU = 4
  457   ColorCodeChannels 'BGR_EA    = 3
  458   ColorCodeChannels 'BGR_FULL  = 3
  459   ColorCodeChannels 'BGR_I420  = 3
  460   ColorCodeChannels 'BGR_IYUV  = 3
  461   ColorCodeChannels 'BGR_NV12  = 3
  462   ColorCodeChannels 'BGR_NV21  = 3
  463   ColorCodeChannels 'BGR_UYNV  = 3
  464   ColorCodeChannels 'BGR_UYVY  = 3
  465   ColorCodeChannels 'BGR_VNG   = 3
  466   ColorCodeChannels 'BGR_Y422  = 3
  467   ColorCodeChannels 'BGR_YUNV  = 3
  468   ColorCodeChannels 'BGR_YUY2  = 3
  469   ColorCodeChannels 'BGR_YUYV  = 3
  470   ColorCodeChannels 'BGR_YV12  = 3
  471   ColorCodeChannels 'BGR_YVYU  = 3
  472   ColorCodeChannels 'GRAY      = 1
  473   ColorCodeChannels 'GRAY_420  = 1
  474   ColorCodeChannels 'GRAY_I420 = 1
  475   ColorCodeChannels 'GRAY_IYUV = 1
  476   ColorCodeChannels 'GRAY_NV12 = 1
  477   ColorCodeChannels 'GRAY_NV21 = 1
  478   ColorCodeChannels 'GRAY_UYNV = 1
  479   ColorCodeChannels 'GRAY_UYVY = 1
  480   ColorCodeChannels 'GRAY_Y422 = 1
  481   ColorCodeChannels 'GRAY_YUNV = 1
  482   ColorCodeChannels 'GRAY_YUY2 = 1
  483   ColorCodeChannels 'GRAY_YUYV = 1
  484   ColorCodeChannels 'GRAY_YV12 = 1
  485   ColorCodeChannels 'GRAY_YVYU = 1
  486   ColorCodeChannels 'HLS       = 3
  487   ColorCodeChannels 'HLS_FULL  = 3
  488   ColorCodeChannels 'HSV       = 3
  489   ColorCodeChannels 'HSV_FULL  = 3
  490   ColorCodeChannels 'Lab       = 3
  491   ColorCodeChannels 'LBGR      = 3
  492   ColorCodeChannels 'LRGB      = 3
  493   ColorCodeChannels 'Luv       = 3
  494   ColorCodeChannels 'MRGBA     = 4
  495   ColorCodeChannels 'RGB       = 3
  496   ColorCodeChannels 'RGBA      = 4
  497   ColorCodeChannels 'RGBA_I420 = 4
  498   ColorCodeChannels 'RGBA_IYUV = 4
  499   ColorCodeChannels 'RGBA_NV12 = 4
  500   ColorCodeChannels 'RGBA_NV21 = 4
  501   ColorCodeChannels 'RGBA_UYNV = 4
  502   ColorCodeChannels 'RGBA_UYVY = 4
  503   ColorCodeChannels 'RGBA_Y422 = 4
  504   ColorCodeChannels 'RGBA_YUNV = 4
  505   ColorCodeChannels 'RGBA_YUY2 = 4
  506   ColorCodeChannels 'RGBA_YUYV = 4
  507   ColorCodeChannels 'RGBA_YV12 = 4
  508   ColorCodeChannels 'RGBA_YVYU = 4
  509   ColorCodeChannels 'RGB_EA    = 3
  510   ColorCodeChannels 'RGB_FULL  = 3
  511   ColorCodeChannels 'RGB_I420  = 3
  512   ColorCodeChannels 'RGB_IYUV  = 3
  513   ColorCodeChannels 'RGB_NV12  = 3
  514   ColorCodeChannels 'RGB_NV21  = 3
  515   ColorCodeChannels 'RGB_UYNV  = 3
  516   ColorCodeChannels 'RGB_UYVY  = 3
  517   ColorCodeChannels 'RGB_VNG   = 3
  518   ColorCodeChannels 'RGB_Y422  = 3
  519   ColorCodeChannels 'RGB_YUNV  = 3
  520   ColorCodeChannels 'RGB_YUY2  = 3
  521   ColorCodeChannels 'RGB_YUYV  = 3
  522   ColorCodeChannels 'RGB_YV12  = 3
  523   ColorCodeChannels 'RGB_YVYU  = 3
  524   ColorCodeChannels 'XYZ       = 3
  525   ColorCodeChannels 'YCrCb     = 3
  526   ColorCodeChannels 'YUV       = 3
  527   ColorCodeChannels 'YUV420p   = 3
  528   ColorCodeChannels 'YUV420sp  = 3
  529   ColorCodeChannels 'YUV_I420  = 1
  530   ColorCodeChannels 'YUV_IYUV  = 1
  531   ColorCodeChannels 'YUV_YV12  = 1
  532 
  533 class ColorCodeMatchesChannels (code :: ColorCode) (channels :: DS Nat)
  534 
  535 instance ColorCodeMatchesChannels code 'D
  536 instance (ColorCodeChannels code ~ channels) => ColorCodeMatchesChannels code ('S channels)
  537 
  538 type family ColorCodeDepth (srcCode :: ColorCode) (dstCode :: ColorCode) (srcDepth :: DS *) :: DS * where
  539   ColorCodeDepth 'BGR     'BGRA       ('S depth)  = 'S depth
  540   ColorCodeDepth 'RGB     'BGRA       ('S depth)  = 'S depth
  541   ColorCodeDepth 'BGRA    'BGR        ('S depth)  = 'S depth
  542   ColorCodeDepth 'RGBA    'BGR        ('S depth)  = 'S depth
  543   ColorCodeDepth 'RGB     'BGR        ('S depth)  = 'S depth
  544   ColorCodeDepth 'BGR     'RGB        ('S depth)  = 'S depth
  545   ColorCodeDepth 'BGRA    'RGBA       ('S depth)  = 'S depth
  546   ColorCodeDepth 'BGRA    'RGB        ('S depth)  = 'S depth
  547 
  548   ColorCodeDepth 'BGR     'BGR565     ('S Word8)  = 'S Word8
  549   ColorCodeDepth 'BGR     'BGR555     ('S Word8)  = 'S Word8
  550   ColorCodeDepth 'RGB     'BGR565     ('S Word8)  = 'S Word8
  551   ColorCodeDepth 'RGB     'BGR555     ('S Word8)  = 'S Word8
  552   ColorCodeDepth 'BGRA    'BGR565     ('S Word8)  = 'S Word8
  553   ColorCodeDepth 'BGRA    'BGR555     ('S Word8)  = 'S Word8
  554   ColorCodeDepth 'RGBA    'BGR565     ('S Word8)  = 'S Word8
  555   ColorCodeDepth 'RGBA    'BGR555     ('S Word8)  = 'S Word8
  556 
  557   ColorCodeDepth 'BGR565  'BGR        ('S Word8)  = 'S Word8
  558   ColorCodeDepth 'BGR555  'BGR        ('S Word8)  = 'S Word8
  559   ColorCodeDepth 'BGR565  'RGB        ('S Word8)  = 'S Word8
  560   ColorCodeDepth 'BGR555  'RGB        ('S Word8)  = 'S Word8
  561   ColorCodeDepth 'BGR565  'BGRA       ('S Word8)  = 'S Word8
  562   ColorCodeDepth 'BGR555  'BGRA       ('S Word8)  = 'S Word8
  563   ColorCodeDepth 'BGR565  'RGBA       ('S Word8)  = 'S Word8
  564   ColorCodeDepth 'BGR555  'RGBA       ('S Word8)  = 'S Word8
  565 
  566   ColorCodeDepth 'BGR     'GRAY       ('S depth)  = 'S depth
  567   ColorCodeDepth 'BGRA    'GRAY       ('S depth)  = 'S depth
  568   ColorCodeDepth 'RGB     'GRAY       ('S depth)  = 'S depth
  569   ColorCodeDepth 'RGBA    'GRAY       ('S depth)  = 'S depth
  570 
  571   ColorCodeDepth 'BGR565  'GRAY       ('S Word8)  = 'S Word8
  572   ColorCodeDepth 'BGR555  'GRAY       ('S Word8)  = 'S Word8
  573 
  574   ColorCodeDepth 'GRAY    'RGB        ('S depth)  = 'S depth
  575   ColorCodeDepth 'GRAY    'BGR        ('S depth)  = 'S depth
  576   ColorCodeDepth 'GRAY    'BGRA       ('S depth)  = 'S depth
  577 
  578   ColorCodeDepth 'GRAY    'BGR565     ('S Word8)  = 'S Word8
  579   ColorCodeDepth 'GRAY    'BGR555     ('S Word8)  = 'S Word8
  580 
  581   ColorCodeDepth 'BGR     'YCrCb      ('S depth)  = 'S depth
  582   ColorCodeDepth 'BGR     'YUV        ('S depth)  = 'S depth
  583   ColorCodeDepth 'RGB     'YCrCb      ('S depth)  = 'S depth
  584   ColorCodeDepth 'RGB     'YUV        ('S depth)  = 'S depth
  585 
  586   ColorCodeDepth 'YCrCb   'BGR        ('S depth)  = 'S depth
  587   ColorCodeDepth 'YCrCb   'RGB        ('S depth)  = 'S depth
  588   ColorCodeDepth 'YUV     'BGR        ('S depth)  = 'S depth
  589   ColorCodeDepth 'YUV     'RGB        ('S depth)  = 'S depth
  590 
  591   ColorCodeDepth 'BGR     'XYZ        ('S depth)  = 'S depth
  592   ColorCodeDepth 'RGB     'XYZ        ('S depth)  = 'S depth
  593 
  594   ColorCodeDepth 'XYZ     'BGR        ('S depth)  = 'S depth
  595   ColorCodeDepth 'XYZ     'RGB        ('S depth)  = 'S depth
  596 
  597   ColorCodeDepth 'BGR     'HSV        ('S Word8)  = 'S Word8
  598   ColorCodeDepth 'RGB     'HSV        ('S Word8)  = 'S Word8
  599   ColorCodeDepth 'BGR     'HSV_FULL   ('S Word8)  = 'S Word8
  600   ColorCodeDepth 'RGB     'HSV_FULL   ('S Word8)  = 'S Word8
  601   ColorCodeDepth 'BGR     'HLS        ('S Word8)  = 'S Word8
  602   ColorCodeDepth 'RGB     'HLS        ('S Word8)  = 'S Word8
  603   ColorCodeDepth 'BGR     'HLS_FULL   ('S Word8)  = 'S Word8
  604   ColorCodeDepth 'RGB     'HLS_FULL   ('S Word8)  = 'S Word8
  605 
  606   ColorCodeDepth 'BGR     'HSV        ('S Float)  = 'S Float
  607   ColorCodeDepth 'RGB     'HSV        ('S Float)  = 'S Float
  608   ColorCodeDepth 'BGR     'HSV_FULL   ('S Float)  = 'S Float
  609   ColorCodeDepth 'RGB     'HSV_FULL   ('S Float)  = 'S Float
  610   ColorCodeDepth 'BGR     'HLS        ('S Float)  = 'S Float
  611   ColorCodeDepth 'RGB     'HLS        ('S Float)  = 'S Float
  612   ColorCodeDepth 'BGR     'HLS_FULL   ('S Float)  = 'S Float
  613   ColorCodeDepth 'RGB     'HLS_FULL   ('S Float)  = 'S Float
  614 
  615   ColorCodeDepth 'HSV     'BGR        ('S Word8)  = 'S Word8
  616   ColorCodeDepth 'HSV     'RGB        ('S Word8)  = 'S Word8
  617   ColorCodeDepth 'HSV     'BGR_FULL   ('S Word8)  = 'S Word8
  618   ColorCodeDepth 'HSV     'RGB_FULL   ('S Word8)  = 'S Word8
  619   ColorCodeDepth 'HLS     'BGR        ('S Word8)  = 'S Word8
  620   ColorCodeDepth 'HLS     'RGB        ('S Word8)  = 'S Word8
  621   ColorCodeDepth 'HLS     'BGR_FULL   ('S Word8)  = 'S Word8
  622   ColorCodeDepth 'HLS     'RGB_FULL   ('S Word8)  = 'S Word8
  623 
  624   ColorCodeDepth 'HSV     'BGR        ('S Float)  = 'S Float
  625   ColorCodeDepth 'HSV     'RGB        ('S Float)  = 'S Float
  626   ColorCodeDepth 'HSV     'BGR_FULL   ('S Float)  = 'S Float
  627   ColorCodeDepth 'HSV     'RGB_FULL   ('S Float)  = 'S Float
  628   ColorCodeDepth 'HLS     'BGR        ('S Float)  = 'S Float
  629   ColorCodeDepth 'HLS     'RGB        ('S Float)  = 'S Float
  630   ColorCodeDepth 'HLS     'BGR_FULL   ('S Float)  = 'S Float
  631   ColorCodeDepth 'HLS     'RGB_FULL   ('S Float)  = 'S Float
  632 
  633   ColorCodeDepth 'BGR     'Lab        ('S Word8)  = 'S Word8
  634   ColorCodeDepth 'RGB     'Lab        ('S Word8)  = 'S Word8
  635   ColorCodeDepth 'LBGR    'Lab        ('S Word8)  = 'S Word8
  636   ColorCodeDepth 'LRGB    'Lab        ('S Word8)  = 'S Word8
  637   ColorCodeDepth 'BGR     'Luv        ('S Word8)  = 'S Word8
  638   ColorCodeDepth 'RGB     'Luv        ('S Word8)  = 'S Word8
  639   ColorCodeDepth 'LBGR    'Luv        ('S Word8)  = 'S Word8
  640   ColorCodeDepth 'LRGB    'Luv        ('S Word8)  = 'S Word8
  641 
  642   ColorCodeDepth 'BGR     'Lab        ('S Float)  = 'S Float
  643   ColorCodeDepth 'RGB     'Lab        ('S Float)  = 'S Float
  644   ColorCodeDepth 'LBGR    'Lab        ('S Float)  = 'S Float
  645   ColorCodeDepth 'LRGB    'Lab        ('S Float)  = 'S Float
  646   ColorCodeDepth 'BGR     'Luv        ('S Float)  = 'S Float
  647   ColorCodeDepth 'RGB     'Luv        ('S Float)  = 'S Float
  648   ColorCodeDepth 'LBGR    'Luv        ('S Float)  = 'S Float
  649   ColorCodeDepth 'LRGB    'Luv        ('S Float)  = 'S Float
  650 
  651   ColorCodeDepth 'Lab     'BGR        ('S Word8)  = 'S Word8
  652   ColorCodeDepth 'Lab     'RGB        ('S Word8)  = 'S Word8
  653   ColorCodeDepth 'Lab     'LBGR       ('S Word8)  = 'S Word8
  654   ColorCodeDepth 'Lab     'LRGB       ('S Word8)  = 'S Word8
  655   ColorCodeDepth 'Luv     'BGR        ('S Word8)  = 'S Word8
  656   ColorCodeDepth 'Luv     'RGB        ('S Word8)  = 'S Word8
  657   ColorCodeDepth 'Luv     'LBGR       ('S Word8)  = 'S Word8
  658   ColorCodeDepth 'Luv     'LRGB       ('S Word8)  = 'S Word8
  659 
  660   ColorCodeDepth 'Lab     'BGR        ('S Float)  = 'S Float
  661   ColorCodeDepth 'Lab     'RGB        ('S Float)  = 'S Float
  662   ColorCodeDepth 'Lab     'LBGR       ('S Float)  = 'S Float
  663   ColorCodeDepth 'Lab     'LRGB       ('S Float)  = 'S Float
  664   ColorCodeDepth 'Luv     'BGR        ('S Float)  = 'S Float
  665   ColorCodeDepth 'Luv     'RGB        ('S Float)  = 'S Float
  666   ColorCodeDepth 'Luv     'LBGR       ('S Float)  = 'S Float
  667   ColorCodeDepth 'Luv     'LRGB       ('S Float)  = 'S Float
  668 
  669   ColorCodeDepth 'BayerBG 'GRAY       ('S Word8)  = 'S Word8
  670   ColorCodeDepth 'BayerBG 'GRAY       ('S Word16) = 'S Word16
  671   ColorCodeDepth 'BayerGB 'GRAY       ('S Word8)  = 'S Word8
  672   ColorCodeDepth 'BayerGB 'GRAY       ('S Word16) = 'S Word16
  673   ColorCodeDepth 'BayerGR 'GRAY       ('S Word8)  = 'S Word8
  674   ColorCodeDepth 'BayerGR 'GRAY       ('S Word16) = 'S Word16
  675   ColorCodeDepth 'BayerRG 'GRAY       ('S Word8)  = 'S Word8
  676   ColorCodeDepth 'BayerRG 'GRAY       ('S Word16) = 'S Word16
  677 
  678   ColorCodeDepth 'BayerBG 'BGR        ('S Word8)  = 'S Word8
  679   ColorCodeDepth 'BayerBG 'BGR        ('S Word16) = 'S Word16
  680   ColorCodeDepth 'BayerGB 'BGR        ('S Word8)  = 'S Word8
  681   ColorCodeDepth 'BayerGB 'BGR        ('S Word16) = 'S Word16
  682   ColorCodeDepth 'BayerGR 'BGR        ('S Word8)  = 'S Word8
  683   ColorCodeDepth 'BayerGR 'BGR        ('S Word16) = 'S Word16
  684   ColorCodeDepth 'BayerRG 'BGR        ('S Word8)  = 'S Word8
  685   ColorCodeDepth 'BayerRG 'BGR        ('S Word16) = 'S Word16
  686 
  687   ColorCodeDepth 'BayerBG 'BGR_VNG    ('S Word8)  = 'S Word8
  688   ColorCodeDepth 'BayerBG 'BGR_VNG    ('S Word16) = 'S Word16
  689   ColorCodeDepth 'BayerGB 'BGR_VNG    ('S Word8)  = 'S Word8
  690   ColorCodeDepth 'BayerGB 'BGR_VNG    ('S Word16) = 'S Word16
  691   ColorCodeDepth 'BayerGR 'BGR_VNG    ('S Word8)  = 'S Word8
  692   ColorCodeDepth 'BayerGR 'BGR_VNG    ('S Word16) = 'S Word16
  693   ColorCodeDepth 'BayerRG 'BGR_VNG    ('S Word8)  = 'S Word8
  694   ColorCodeDepth 'BayerRG 'BGR_VNG    ('S Word16) = 'S Word16
  695 
  696   ColorCodeDepth 'BayerBG 'BGR_EA     ('S Word8)  = 'S Word8
  697   ColorCodeDepth 'BayerBG 'BGR_EA     ('S Word16) = 'S Word16
  698   ColorCodeDepth 'BayerGB 'BGR_EA     ('S Word8)  = 'S Word8
  699   ColorCodeDepth 'BayerGB 'BGR_EA     ('S Word16) = 'S Word16
  700   ColorCodeDepth 'BayerGR 'BGR_EA     ('S Word8)  = 'S Word8
  701   ColorCodeDepth 'BayerGR 'BGR_EA     ('S Word16) = 'S Word16
  702   ColorCodeDepth 'BayerRG 'BGR_EA     ('S Word8)  = 'S Word8
  703   ColorCodeDepth 'BayerRG 'BGR_EA     ('S Word16) = 'S Word16
  704 
  705   ColorCodeDepth 'YUV     'BGR_NV21   ('S Word8)  = 'S Word8
  706   ColorCodeDepth 'YUV     'RGB_NV21   ('S Word8)  = 'S Word8
  707   ColorCodeDepth 'YUV     'BGR_NV12   ('S Word8)  = 'S Word8
  708   ColorCodeDepth 'YUV     'RGB_NV12   ('S Word8)  = 'S Word8
  709   ColorCodeDepth 'YUV     'BGRA_NV21  ('S Word8)  = 'S Word8
  710   ColorCodeDepth 'YUV     'RGBA_NV21  ('S Word8)  = 'S Word8
  711   ColorCodeDepth 'YUV     'BGRA_NV12  ('S Word8)  = 'S Word8
  712   ColorCodeDepth 'YUV     'RGBA_NV12  ('S Word8)  = 'S Word8
  713 
  714   ColorCodeDepth 'YUV     'BGR_YV12   ('S Word8)  = 'S Word8
  715   ColorCodeDepth 'YUV     'RGB_YV12   ('S Word8)  = 'S Word8
  716   ColorCodeDepth 'YUV     'BGRA_YV12  ('S Word8)  = 'S Word8
  717   ColorCodeDepth 'YUV     'RGBA_YV12  ('S Word8)  = 'S Word8
  718   ColorCodeDepth 'YUV     'BGR_IYUV   ('S Word8)  = 'S Word8
  719   ColorCodeDepth 'YUV     'RGB_IYUV   ('S Word8)  = 'S Word8
  720   ColorCodeDepth 'YUV     'BGRA_IYUV  ('S Word8)  = 'S Word8
  721   ColorCodeDepth 'YUV     'RGBA_IYUV  ('S Word8)  = 'S Word8
  722 
  723   ColorCodeDepth 'YUV     'GRAY_420   ('S Word8)  = 'S Word8
  724 
  725   ColorCodeDepth 'RGB     'YUV_YV12   ('S Word8)  = 'S Word8
  726   ColorCodeDepth 'BGR     'YUV_YV12   ('S Word8)  = 'S Word8
  727   ColorCodeDepth 'RGBA    'YUV_YV12   ('S Word8)  = 'S Word8
  728   ColorCodeDepth 'BGRA    'YUV_YV12   ('S Word8)  = 'S Word8
  729   ColorCodeDepth 'RGB     'YUV_IYUV   ('S Word8)  = 'S Word8
  730   ColorCodeDepth 'BGR     'YUV_IYUV   ('S Word8)  = 'S Word8
  731   ColorCodeDepth 'RGBA    'YUV_IYUV   ('S Word8)  = 'S Word8
  732   ColorCodeDepth 'BGRA    'YUV_IYUV   ('S Word8)  = 'S Word8
  733 
  734   ColorCodeDepth 'YUV     'RGB_UYVY   ('S Word8)  = 'S Word8
  735   ColorCodeDepth 'YUV     'BGR_UYVY   ('S Word8)  = 'S Word8
  736   ColorCodeDepth 'YUV     'RGBA_UYVY  ('S Word8)  = 'S Word8
  737   ColorCodeDepth 'YUV     'BGRA_UYVY  ('S Word8)  = 'S Word8
  738   ColorCodeDepth 'YUV     'RGB_YUY2   ('S Word8)  = 'S Word8
  739   ColorCodeDepth 'YUV     'BGR_YUY2   ('S Word8)  = 'S Word8
  740   ColorCodeDepth 'YUV     'RGB_YVYU   ('S Word8)  = 'S Word8
  741   ColorCodeDepth 'YUV     'BGR_YVYU   ('S Word8)  = 'S Word8
  742   ColorCodeDepth 'YUV     'RGBA_YUY2  ('S Word8)  = 'S Word8
  743   ColorCodeDepth 'YUV     'BGRA_YUY2  ('S Word8)  = 'S Word8
  744   ColorCodeDepth 'YUV     'RGBA_YVYU  ('S Word8)  = 'S Word8
  745   ColorCodeDepth 'YUV     'BGRA_YVYU  ('S Word8)  = 'S Word8
  746 
  747   ColorCodeDepth 'YUV     'GRAY_UYVY  ('S Word8)  = 'S Word8
  748   ColorCodeDepth 'YUV     'GRAY_YUY2  ('S Word8)  = 'S Word8
  749 
  750   ColorCodeDepth 'RGBA    'MRGBA      ('S Word8)  = 'S Word8
  751   ColorCodeDepth 'MRGBA   'RGBA       ('S Word8)  = 'S Word8
  752 
  753   ColorCodeDepth srcCode  dstCode      'D         = 'D