Skip to content

Commit 4d668c7

Browse files
committed
Refactored repository layout
Each package now lives in its own top level directory.
1 parent 5668244 commit 4d668c7

File tree

114 files changed

+287
-257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+287
-257
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
src/**/*.cpp
1+
opencv/src/**/*.cpp
22
opencv-extra/src/**/*.cpp
33
dist
44
.stack-work

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2015—2016 Lumi Guide Fietsdetectie B.V.
1+
Copyright 2015–2017 Lumi Guide Fietsdetectie B.V.
22

33
All rights reserved.
44

examples/lib/OpenCV/Example.hs

-60
This file was deleted.

examples/opencv-examples.cabal

-95
This file was deleted.

nixpkgs-config.nix

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
let
44
haskellOverrides = {
55
overrides = self: super: {
6-
opencv = self.callPackage (import ./haskell-opencv.nix) {};
7-
opencv-examples = self.callPackage (import ./examples/opencv-examples.nix) {};
6+
opencv = self.callPackage (import ./opencv/opencv.nix) {};
7+
opencv-examples = self.callPackage (import ./opencv-examples/opencv-examples.nix) {};
88
opencv-extra = self.callPackage (import ./opencv-extra/opencv-extra.nix) {};
9-
opencv-extra-examples = self.callPackage (import ./opencv-extra/examples/opencv-extra-examples.nix) {};
9+
opencv-extra-examples = self.callPackage (import ./opencv-extra-examples/opencv-extra-examples.nix) {};
1010
};
1111
};
1212
osx = builtins.currentSystem == "x86_64-darwin";

opencv-examples/LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE

examples/data opencv-examples/data

File renamed without changes.
File renamed without changes.

opencv-examples/lib/OpenCV/Example.hs

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{-# language LambdaCase #-}
2+
{-# language OverloadedStrings #-}
3+
{-# language PackageImports #-}
4+
{-# language TemplateHaskell #-}
5+
6+
module OpenCV.Example
7+
( createCapture
8+
, createCaptureArg
9+
, withEmbededFile
10+
) where
11+
12+
import "base" System.Environment
13+
import "base" System.Exit
14+
import qualified "bytestring" Data.ByteString as B
15+
import "file-embed" Data.FileEmbed
16+
import "filepath" System.FilePath.Posix
17+
import qualified "opencv" OpenCV as CV
18+
import "template-haskell" Language.Haskell.TH.Syntax
19+
import "temporary" System.IO.Temp
20+
21+
createCapture :: String -> IO (Maybe CV.VideoCapture)
22+
createCapture input = do
23+
cap <- CV.newVideoCapture
24+
let openSource src = CV.exceptErrorIO $ CV.videoCaptureOpen cap src
25+
if input `elem` ["0","1","2","3","4","5","6","7","8","9"]
26+
then openSource $ CV.VideoDeviceSource (read input) Nothing
27+
else openSource $ CV.VideoFileSource input Nothing
28+
isOpened <- CV.videoCaptureIsOpened cap
29+
if isOpened
30+
then return $ Just cap
31+
else return Nothing
32+
33+
-- | Use first argument to the program to create capture device
34+
-- it should be usefull for creating demos. Numbers are for cameras and
35+
-- files for videos
36+
createCaptureArg :: IO CV.VideoCapture
37+
createCaptureArg =
38+
getArgs >>= \case
39+
[] -> createCapture "0"
40+
(inp:_) -> createCapture inp
41+
>>= maybe (die "could not open capture input ") return
42+
43+
embedCallHelp :: B.ByteString -> FilePath -> (FilePath -> IO a) -> IO a
44+
embedCallHelp ef templ f =
45+
withSystemTempFile templ $ \fn fh -> do
46+
B.hPutStr fh ef
47+
f fn
48+
49+
-- | Embedder for strictly used files, it allows to embed a file, and still allow
50+
-- some method to use filename
51+
withEmbededFile :: FilePath -> Q Exp
52+
withEmbededFile filePath = do
53+
templ <- [| $(lift $ takeFileName filePath) |]
54+
ef <- embedFile filePath
55+
var <- newName "f"
56+
return $ LamE [VarP var] $
57+
AppE (AppE ( AppE (VarE 'embedCallHelp) ef ) templ ) (VarE var)

opencv-examples/opencv-examples.cabal

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: opencv-examples
2+
version: 0.0.0.0
3+
homepage: lumiguide.eu
4+
bug-reports: https://github.com/LumiGuide/haskell-opencv/issues
5+
license: BSD3
6+
license-file: LICENSE
7+
author: Roel van Dijk <roel@lambdacube.nl>, Bas van Dijk <v.dijk.bas@gmail.com>
8+
maintainer: Roel van Dijk <roel@lambdacube.nl>, Bas van Dijk <v.dijk.bas@gmail.com>
9+
build-type: Simple
10+
cabal-version: >=1.10
11+
12+
extra-source-files:
13+
data/*.png
14+
data/*.jpg
15+
data/*.xml
16+
17+
library
18+
hs-source-dirs: lib
19+
exposed-modules:
20+
OpenCV.Example
21+
build-depends:
22+
base >= 4.8 && < 4.10
23+
, opencv
24+
, temporary >= 1.2
25+
, bytestring >= 0.10.6
26+
, filepath >= 1.4
27+
, file-embed >= 0.0
28+
, template-haskell >= 2.10
29+
30+
default-language: Haskell2010
31+
32+
executable highgui
33+
main-is: highgui.hs
34+
hs-source-dirs: src
35+
ghc-options: -Wall -O2
36+
37+
build-depends:
38+
base >= 4.8 && < 4.10
39+
, bytestring >= 0.10.6
40+
, opencv
41+
42+
default-language: Haskell2010
43+
44+
executable videoio
45+
main-is: videoio.hs
46+
hs-source-dirs: src
47+
ghc-options: -Wall -O2
48+
49+
build-depends:
50+
base >= 4.8 && < 4.10
51+
, opencv
52+
53+
default-language: Haskell2010
54+
55+
executable videoio-noise-multi
56+
main-is: videoio-noise-multi.hs
57+
hs-source-dirs: src
58+
ghc-options: -Wall -O2
59+
60+
build-depends:
61+
base >= 4.8 && < 4.10
62+
, opencv
63+
, opencv-examples
64+
, vector >= 0.11
65+
66+
default-language: Haskell2010
67+
68+
executable videoio-decolor
69+
main-is: videoio-decolor.hs
70+
hs-source-dirs: src
71+
ghc-options: -Wall -O2
72+
73+
build-depends:
74+
base >= 4.8 && < 4.10
75+
, opencv
76+
, opencv-examples
77+
78+
default-language: Haskell2010
79+
80+
executable videoio-background-sub
81+
main-is: videoio-background-sub.hs
82+
hs-source-dirs: src
83+
ghc-options: -Wall -O2
84+
85+
build-depends:
86+
base >= 4.8 && < 4.10
87+
, opencv
88+
, opencv-examples
89+
90+
default-language: Haskell2010
91+
92+
executable face-detect
93+
main-is: face-detect.hs
94+
hs-source-dirs: src
95+
ghc-options: -Wall -O2
96+
97+
build-depends:
98+
base >= 4.8 && < 4.10
99+
, opencv
100+
, opencv-examples
101+
, linear >= 1.20.4
102+
, vector >= 0.11
103+
, transformers >= 0.4.2
104+
105+
default-language: Haskell2010

examples/opencv-examples.nix opencv-examples/opencv-examples.nix

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ mkDerivation {
2727
"^opencv-examples.cabal$"
2828
];
2929
data = ../data;
30-
} ''
30+
LICENSE = ../LICENSE;
31+
} ''
3132
mkdir -p $out
3233
cp -r $files/* $out #*/
3334
cp -r $data $out/data
35+
cp $LICENSE $out/LICENSE
3436
'';
3537
isLibrary = true;
3638
isExecutable = true;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

opencv-extra-examples/LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE
File renamed without changes.

opencv-extra/examples/default.nix opencv-extra-examples/default.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ nixpkgs ? import (import ../../nixpkgs.nix) {config = import ../../nixpkgs-config.nix;}
1+
{ nixpkgs ? import (import ../nixpkgs.nix) {config = import ../nixpkgs-config.nix;}
22
, compiler ? "default"
33
}:
44

0 commit comments

Comments
 (0)