never executed always true always false
    1 {-# language CPP #-}
    2 
    3 #ifndef ENABLE_INTERNAL_DOCUMENTATION
    4 {-# OPTIONS_HADDOCK hide #-}
    5 #endif
    6 
    7 module OpenCV.Internal.Core.ArrayOps
    8     ( CmpType(..)
    9     , marshalCmpType
   10     , NormType(..)
   11     , NormAbsRel(..)
   12     , marshalNormType
   13     )
   14     where
   15 
   16 import "base" Data.Bits ( (.|.) )
   17 import "base" Data.Int
   18 
   19 --------------------------------------------------------------------------------
   20 
   21 #include <bindings.dsl.h>
   22 #include "opencv2/core.hpp"
   23 
   24 #include "namespace.hpp"
   25 
   26 --------------------------------------------------------------------------------
   27 
   28 -- | Comparison type
   29 data CmpType
   30    = Cmp_Eq
   31    | Cmp_Gt
   32    | Cmp_Ge
   33    | Cmp_Lt
   34    | Cmp_Le
   35    | Cmp_Ne
   36      deriving (Show, Eq)
   37 
   38 #num CMP_EQ
   39 #num CMP_GT
   40 #num CMP_GE
   41 #num CMP_LT
   42 #num CMP_LE
   43 #num CMP_NE
   44 
   45 marshalCmpType :: CmpType -> Int32
   46 marshalCmpType cmpOp =
   47     case cmpOp of
   48       Cmp_Eq -> c'CMP_EQ
   49       Cmp_Gt -> c'CMP_GT
   50       Cmp_Ge -> c'CMP_GE
   51       Cmp_Lt -> c'CMP_LT
   52       Cmp_Le -> c'CMP_LE
   53       Cmp_Ne -> c'CMP_NE
   54 
   55 -- | Normalization type
   56 data NormType
   57    = Norm_Inf
   58    | Norm_L1
   59    | Norm_L2
   60    | Norm_L2SQR
   61    | Norm_Hamming
   62    | Norm_Hamming2
   63    | Norm_MinMax
   64      deriving (Show, Eq)
   65 
   66 data NormAbsRel
   67    = NormRelative
   68    | NormAbsolute
   69      deriving (Show, Eq)
   70 
   71 #num NORM_INF
   72 #num NORM_L1
   73 #num NORM_L2
   74 #num NORM_L2SQR
   75 #num NORM_HAMMING
   76 #num NORM_HAMMING2
   77 #num NORM_MINMAX 
   78 
   79 #num NORM_RELATIVE
   80 
   81 marshalNormType :: NormAbsRel -> NormType -> Int32
   82 marshalNormType absRel normType =
   83     case absRel of
   84       NormRelative -> c'normType .|. c'NORM_RELATIVE
   85       NormAbsolute -> c'normType
   86   where
   87     c'normType = case normType of
   88         Norm_Inf      -> c'NORM_INF
   89         Norm_L1       -> c'NORM_L1
   90         Norm_L2       -> c'NORM_L2
   91         Norm_L2SQR    -> c'NORM_L2SQR
   92         Norm_Hamming  -> c'NORM_HAMMING
   93         Norm_Hamming2 -> c'NORM_HAMMING2
   94         Norm_MinMax   -> c'NORM_MINMAX