Skip to content

Commit cf9753b

Browse files
committed
Drop opencv4 Cabal flag since it's now the only choice
1 parent 4bcb408 commit cf9753b

14 files changed

+2
-142
lines changed

opencv-extra/opencv-extra.cabal

+1-9
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ source-repository head
3838
location: git://github.com/LumiGuide/haskell-opencv.git
3939
subdir: opencv-extra
4040

41-
flag opencv4
42-
description: Use OpenCV >= 4.0.0
43-
default: True
44-
manual: True
45-
4641
flag enable-nonfree
4742
description: Builds modules that only work if the system OpenCV was built with the OPENCV_ENABLE_NONFREE option (most OpenCV installations lack this by default).
4843
default: False
@@ -80,10 +75,7 @@ library
8075

8176
ghc-options: -Wall -fwarn-incomplete-patterns -funbox-strict-fields
8277

83-
if flag(opencv4)
84-
pkgconfig-depends: opencv4 >= 4.0.0
85-
else
86-
pkgconfig-depends: opencv >= 3.0.0
78+
pkgconfig-depends: opencv4 >= 4.0.0
8779

8880
if flag(internal-documentation)
8981
cpp-options: -DENABLE_INTERNAL_DOCUMENTATION

opencv/opencv.cabal

+1-12
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ source-repository head
4343
location: git://github.com/LumiGuide/haskell-opencv.git
4444
subdir: opencv
4545

46-
flag opencv4
47-
description: Use OpenCV >= 4.0.0
48-
default: True
49-
manual: True
50-
5146
flag internal-documentation
5247
description: Enables documentation generation for internal modules.
5348
default: False
@@ -80,13 +75,7 @@ library
8075

8176
ghc-options: -Wall -fwarn-incomplete-patterns -funbox-strict-fields
8277

83-
if flag(opencv4)
84-
cpp-options: -DOPENCV4
85-
ghc-options: -optc-DOPENCV4
86-
pkgconfig-depends: opencv4 >= 4.0.0
87-
else
88-
pkgconfig-depends: opencv >= 3.0.0
89-
build-depends: base64-bytestring >= 1.0.0.1
78+
pkgconfig-depends: opencv4 >= 4.0.0
9079

9180
if flag(internal-documentation)
9281
cpp-options: -DENABLE_INTERNAL_DOCUMENTATION

opencv/src/OpenCV/Features2d.hs

-4
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,7 @@ newOrb OrbParams{..} = fromPtr
197197
, $(int32_t orb_edgeThreshold)
198198
, $(int32_t orb_firstLevel)
199199
, $(int32_t c'WTA_K)
200-
#ifdef OPENCV4
201200
, cv::ORB::ScoreType($(int32_t c'scoreType))
202-
#else
203-
, $(int32_t c'scoreType)
204-
#endif
205201
, $(int32_t orb_patchSize)
206202
, $(int32_t orb_fastThreshold)
207203
);

opencv/src/OpenCV/ImgProc/FeatureDetection.hs

-4
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,7 @@ houghCircles dp minDist param1 param2 minRadius maxRadius src = unsafeWrapExcept
335335
cv::HoughCircles(
336336
*$(Mat * srcPtr),
337337
circles,
338-
#ifdef OPENCV4
339338
HOUGH_GRADIENT,
340-
#else
341-
CV_HOUGH_GRADIENT,
342-
#endif
343339
$(double c'dp),
344340
$(double c'minDist),
345341
$(double c'param1),

opencv/src/OpenCV/ImgProc/GeometricImgTransform.hsc

-2
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ C.context openCvCtx
9191

9292
C.include "opencv2/core.hpp"
9393
C.include "opencv2/imgproc.hpp"
94-
#ifdef OPENCV4
9594
C.include "opencv2/calib3d.hpp"
96-
#endif
9795
C.using "namespace cv"
9896

9997
#include <bindings.dsl.h>

opencv/src/OpenCV/ImgProc/ObjectDetection.hsc

-21
Original file line numberDiff line numberDiff line change
@@ -101,33 +101,12 @@ data MatchTemplateNormalisation
101101
| MatchTemplateNormed -- ^ Use normalization.
102102
deriving (Show, Eq)
103103

104-
#ifdef OPENCV4
105104
#num TM_SQDIFF
106105
#num TM_SQDIFF_NORMED
107106
#num TM_CCORR
108107
#num TM_CCORR_NORMED
109108
#num TM_CCOEFF
110109
#num TM_CCOEFF_NORMED
111-
#else
112-
#num CV_TM_SQDIFF
113-
#num CV_TM_SQDIFF_NORMED
114-
#num CV_TM_CCORR
115-
#num CV_TM_CCORR_NORMED
116-
#num CV_TM_CCOEFF
117-
#num CV_TM_CCOEFF_NORMED
118-
c'TM_SQDIFF :: Num a => a
119-
c'TM_SQDIFF_NORMED :: Num a => a
120-
c'TM_CCORR :: Num a => a
121-
c'TM_CCORR_NORMED :: Num a => a
122-
c'TM_CCOEFF :: Num a => a
123-
c'TM_CCOEFF_NORMED :: Num a => a
124-
c'TM_SQDIFF = c'CV_TM_SQDIFF
125-
c'TM_SQDIFF_NORMED = c'CV_TM_SQDIFF_NORMED
126-
c'TM_CCORR = c'CV_TM_CCORR
127-
c'TM_CCORR_NORMED = c'CV_TM_CCORR_NORMED
128-
c'TM_CCOEFF = c'CV_TM_CCOEFF
129-
c'TM_CCOEFF_NORMED = c'CV_TM_CCOEFF_NORMED
130-
#endif
131110

132111
marshalMatchTemplateMethod :: MatchTemplateMethod -> Bool -> Int32
133112
marshalMatchTemplateMethod m n =

opencv/src/OpenCV/ImgProc/StructuralAnalysis.hsc

-29
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ import qualified "vector" Data.Vector.Storable as VS
5757

5858
#include <bindings.dsl.h>
5959
#include "opencv2/imgproc.hpp"
60-
#ifdef OPENCV4
6160
#include "namespace.hpp"
62-
#endif
6361

6462
C.context openCvCtx
6563

@@ -109,7 +107,6 @@ data ContourApproximationMethod
109107
| ContourApproximationTC89L1
110108
| ContourApproximationTC89KCOS
111109

112-
#ifdef OPENCV4
113110
#num RETR_EXTERNAL
114111
#num RETR_LIST
115112
#num RETR_CCOMP
@@ -118,32 +115,6 @@ data ContourApproximationMethod
118115
#num CHAIN_APPROX_SIMPLE
119116
#num CHAIN_APPROX_TC89_L1
120117
#num CHAIN_APPROX_TC89_KCOS
121-
#else
122-
#num CV_RETR_EXTERNAL
123-
#num CV_RETR_LIST
124-
#num CV_RETR_CCOMP
125-
#num CV_RETR_TREE
126-
#num CV_CHAIN_APPROX_NONE
127-
#num CV_CHAIN_APPROX_SIMPLE
128-
#num CV_CHAIN_APPROX_TC89_L1
129-
#num CV_CHAIN_APPROX_TC89_KCOS
130-
c'RETR_EXTERNAL :: Num a => a
131-
c'RETR_LIST :: Num a => a
132-
c'RETR_CCOMP :: Num a => a
133-
c'RETR_TREE :: Num a => a
134-
c'CHAIN_APPROX_NONE :: Num a => a
135-
c'CHAIN_APPROX_SIMPLE :: Num a => a
136-
c'CHAIN_APPROX_TC89_L1 :: Num a => a
137-
c'CHAIN_APPROX_TC89_KCOS :: Num a => a
138-
c'RETR_EXTERNAL = c'CV_RETR_EXTERNAL
139-
c'RETR_LIST = c'CV_RETR_LIST
140-
c'RETR_CCOMP = c'CV_RETR_CCOMP
141-
c'RETR_TREE = c'CV_RETR_TREE
142-
c'CHAIN_APPROX_NONE = c'CV_CHAIN_APPROX_NONE
143-
c'CHAIN_APPROX_SIMPLE = c'CV_CHAIN_APPROX_SIMPLE
144-
c'CHAIN_APPROX_TC89_L1 = c'CV_CHAIN_APPROX_TC89_L1
145-
c'CHAIN_APPROX_TC89_KCOS = c'CV_CHAIN_APPROX_TC89_KCOS
146-
#endif
147118

148119
marshalContourRetrievalMode :: ContourRetrievalMode -> Int32
149120
marshalContourRetrievalMode = \case

opencv/src/OpenCV/Internal/Calib3d/Constants.hsc

-15
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,10 @@ module OpenCV.Internal.Calib3d.Constants where
1212

1313
#include "namespace.hpp"
1414

15-
#ifdef OPENCV4
1615
#num FM_7POINT
1716
#num FM_8POINT
1817
#num FM_RANSAC
1918
#num FM_LMEDS
20-
#else
21-
#num CV_FM_7POINT
22-
#num CV_FM_8POINT
23-
#num CV_FM_RANSAC
24-
#num CV_FM_LMEDS
25-
c'FM_7POINT :: Num a => a
26-
c'FM_8POINT :: Num a => a
27-
c'FM_RANSAC :: Num a => a
28-
c'FM_LMEDS :: Num a => a
29-
c'FM_7POINT = c'CV_FM_7POINT
30-
c'FM_8POINT = c'CV_FM_8POINT
31-
c'FM_RANSAC = c'CV_FM_RANSAC
32-
c'FM_LMEDS = c'CV_FM_LMEDS
33-
#endif
3419

3520
#num LMEDS
3621
#num RANSAC

opencv/src/OpenCV/Internal/Core/Types/Mat/Depth.hs

-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ data Depth =
2828
| Depth_32S
2929
| Depth_32F
3030
| Depth_64F
31-
#ifndef OPENCV4
32-
| Depth_USRTYPE1
33-
#endif
3431
deriving (Bounded, Enum, Eq, Show)
3532

3633
--------------------------------------------------------------------------------

opencv/src/OpenCV/Internal/Core/Types/Mat/HMat.hs

-18
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ import "base" Foreign.C.Types
2424
import "base" Foreign.Ptr ( Ptr )
2525
import "base" Foreign.Storable ( Storable(..), peekElemOff, pokeElemOff )
2626
import "base" System.IO.Unsafe ( unsafePerformIO )
27-
#ifndef OPENCV4
28-
import qualified "bytestring" Data.ByteString as B
29-
#endif
3027
import "linear" Linear.Vector ( zero )
3128
import "linear" Linear.V4 ( V4(..) )
3229
import "this" OpenCV.Core.Types
@@ -54,9 +51,6 @@ data HElems
5451
| HElems_32S !(VU.Vector Int32)
5552
| HElems_32F !(VU.Vector Float)
5653
| HElems_64F !(VU.Vector Double)
57-
#ifndef OPENCV4
58-
| HElems_USRTYPE1 !(V.Vector B.ByteString)
59-
#endif
6054
deriving (Show, Eq)
6155

6256
hElemsDepth :: HElems -> Depth
@@ -68,9 +62,6 @@ hElemsDepth = \case
6862
HElems_32S _v -> Depth_32S
6963
HElems_32F _v -> Depth_32F
7064
HElems_64F _v -> Depth_64F
71-
#ifndef OPENCV4
72-
HElems_USRTYPE1 _v -> Depth_USRTYPE1
73-
#endif
7465

7566
hElemsLength :: HElems -> Int
7667
hElemsLength = \case
@@ -81,9 +72,6 @@ hElemsLength = \case
8172
HElems_32S v -> VG.length v
8273
HElems_32F v -> VG.length v
8374
HElems_64F v -> VG.length v
84-
#ifndef OPENCV4
85-
HElems_USRTYPE1 v -> VG.length v
86-
#endif
8775

8876
class ToHElems a where
8977
toHElems :: VU.Vector a -> HElems
@@ -121,9 +109,6 @@ matToHMat mat = unsafePerformIO $ withMatData mat $ \step dataPtr -> do
121109
Depth_32S -> HElems_32S <$> copyToVec
122110
Depth_32F -> HElems_32F <$> copyToVec
123111
Depth_64F -> HElems_64F <$> copyToVec
124-
#ifndef OPENCV4
125-
Depth_USRTYPE1 -> HElems_USRTYPE1 <$> error "todo"
126-
#endif
127112
where
128113
copyToVec :: (Storable a, VU.Unbox a) => IO (VU.Vector a)
129114
copyToVec = do
@@ -159,9 +144,6 @@ hMatToMatIO (HMat shape channels elems) = do
159144
HElems_32S v -> copyFromVec v
160145
HElems_32F v -> copyFromVec v
161146
HElems_64F v -> copyFromVec v
162-
#ifndef OPENCV4
163-
HElems_USRTYPE1 _v -> error "todo"
164-
#endif
165147
where
166148
copyFromVec :: (Storable a, VU.Unbox a) => VU.Vector a -> IO ()
167149
copyFromVec v =

opencv/src/OpenCV/Internal/Core/Types/Mat/Marshal.hsc

-9
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ import "this" OpenCV.Internal.Core.Types.Mat.Depth
3232
#num CV_32S
3333
#num CV_32F
3434
#num CV_64F
35-
#ifndef OPENCV4
36-
#num CV_USRTYPE1
37-
#endif
3835

3936
marshalDepth :: Depth -> Int32
4037
marshalDepth = \case
@@ -45,9 +42,6 @@ marshalDepth = \case
4542
Depth_32S -> c'CV_32S
4643
Depth_32F -> c'CV_32F
4744
Depth_64F -> c'CV_64F
48-
#ifndef OPENCV4
49-
Depth_USRTYPE1 -> c'CV_USRTYPE1
50-
#endif
5145

5246
unmarshalDepth :: Int32 -> Depth
5347
unmarshalDepth n
@@ -58,9 +52,6 @@ unmarshalDepth n
5852
| n == c'CV_32S = Depth_32S
5953
| n == c'CV_32F = Depth_32F
6054
| n == c'CV_64F = Depth_64F
61-
#ifndef OPENCV4
62-
| n == c'CV_USRTYPE1 = Depth_USRTYPE1
63-
#endif
6455
| otherwise = error $ "unknown depth " <> show n
6556

6657
#num CV_CN_SHIFT

opencv/src/OpenCV/Internal/Exception.hs

-3
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,6 @@ displayDepth depth = show depth ++ " (" ++ haskellDepth ++ ")"
142142
Depth_32S -> "Int32"
143143
Depth_32F -> "Float"
144144
Depth_64F -> "Double"
145-
#ifndef OPENCV4
146-
Depth_USRTYPE1 -> "not supported in Haskell"
147-
#endif
148145

149146
newtype CvCppException = CvCppException { unCvCppException :: ForeignPtr (C CvCppException) }
150147

opencv/src/OpenCV/JSON.hs

-11
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ import "this" OpenCV.Core.Types.Mat.HMat
2121
import "this" OpenCV.TypeLevel
2222
import "transformers" Control.Monad.Trans.Except
2323

24-
#ifndef OPENCV4
25-
import qualified "base64-bytestring" Data.ByteString.Base64 as B64 ( encode, decode )
26-
import qualified "text" Data.Text.Encoding as TE ( encodeUtf8, decodeUtf8 )
27-
#endif
28-
2924
--------------------------------------------------------------------------------
3025

3126
newtype J a = J {unJ :: a}
@@ -91,9 +86,6 @@ instance ToJSON HElems where
9186
HElems_32S v -> f "32S" v
9287
HElems_32F v -> f "32F" v
9388
HElems_64F v -> f "64F" v
94-
#ifndef OPENCV4
95-
HElems_USRTYPE1 v -> f "USR" $ fmap (TE.decodeUtf8 . B64.encode) v
96-
#endif
9789
where
9890
f :: (ToJSON a) => Text -> a -> Value
9991
f typ v = object [ "type" .= typ
@@ -113,9 +105,6 @@ instance FromJSON HElems where
113105
"32S" -> HElems_32S <$> elems
114106
"32F" -> HElems_32F <$> elems
115107
"64F" -> HElems_64F <$> elems
116-
#ifndef OPENCV4
117-
"USR" -> HElems_USRTYPE1 <$> (mapM (either fail pure . B64.decode . TE.encodeUtf8) =<< elems)
118-
#endif
119108
_ -> fail $ "Unknown Helems type " <> T.unpack typ
120109

121110
--------------------------------------------------------------------------------

opencv/src/OpenCV/Video.hsc

-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ C.using "namespace cv"
3535

3636
--------------------------------------------------------------------------------
3737

38-
#ifdef OPENCV4
3938
{-# DEPRECATED estimateRigidTransform "Use estimateAffine2D or estimateAffinePartial2D instead" #-}
40-
#endif
4139

4240
-- | Computes an optimal affine transformation between two 2D point sets
4341
--

0 commit comments

Comments
 (0)