Skip to content
This repository was archived by the owner on Jun 26, 2025. It is now read-only.

Commit 0a2a989

Browse files
committed
search for headers in other locations
1 parent ece0e96 commit 0a2a989

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
BUILD=_build
22

3+
# By default (if left blank), the generator script searches for
4+
# the opencv4 headers in /usr/include/ and /usr/local/include/.
5+
# Set this variable if your opencv4 headers are located elsewhere.
6+
SYSTEM_INCLUDE_DIR=
7+
38
GEN=gen
49
GENERATOR=generator.py
510
GENERATOR_SRC=$(GENERATOR) hdr_parser.py type_manager.py incl/*
@@ -28,7 +33,7 @@ default: install
2833
$(GEN)/%: ${GENERATOR_SRC}
2934
@echo "Running generator script"
3035
mkdir -p $(GEN)
31-
./$(GENERATOR) $(GEN)
36+
./$(GENERATOR) $(GEN) $(SYSTEM_INCLUDE_DIR)
3237

3338
$(BUILD)/$(SHARED_LIB): $(CPP) $(HEADERS)
3439
@echo "Compiling shared library"

generator.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@
1111
import type_manager
1212

1313
src_files = [
14-
'/usr/include/opencv4/opencv2/core/types.hpp',
15-
'/usr/include/opencv4/opencv2/core/mat.hpp',
16-
'/usr/include/opencv4/opencv2/core.hpp',
17-
'/usr/include/opencv4/opencv2/imgproc.hpp',
18-
'/usr/include/opencv4/opencv2/videoio.hpp',
19-
'/usr/include/opencv4/opencv2/highgui.hpp',
14+
'opencv4/opencv2/core/types.hpp',
15+
'opencv4/opencv2/core/mat.hpp',
16+
'opencv4/opencv2/core.hpp',
17+
'opencv4/opencv2/imgproc.hpp',
18+
'opencv4/opencv2/videoio.hpp',
19+
'opencv4/opencv2/highgui.hpp',
20+
]
21+
22+
system_include_dir_search = [
23+
'/usr/include/',
24+
'/usr/local/include',
2025
]
2126

2227
c_reserved = {
@@ -343,9 +348,24 @@ def param_sub(match):
343348

344349

345350
if __name__ == '__main__':
351+
if len(sys.argv) < 2:
352+
print('No output folder specified!')
353+
exit(1)
354+
346355
dest = sys.argv[1]
347356
print('Output directory: {}'.format(dest))
348357

358+
if len(sys.argv) > 2:
359+
system_include_dir_search.insert(0, sys.argv[2])
360+
361+
system_include_dir = None
362+
for include_dir in system_include_dir_search:
363+
if os.path.exists(os.path.join(include_dir, src_files[0])):
364+
system_include_dir = include_dir
365+
break
366+
367+
print('Using include dir: {}'.format(system_include_dir))
368+
349369
# TODO enable UMat support, and make a wrapper for handling both Mat and UMat identically
350370
generate_umat = False
351371

@@ -475,7 +495,7 @@ def sanitize_param(param):
475495

476496
decls = []
477497
for hname in src_files:
478-
decls += parser.parse(hname, wmode=False)
498+
decls += parser.parse(os.path.join(system_include_dir, hname), wmode=False)
479499

480500
# first pass to collect classes and add types
481501
for decl in decls:

0 commit comments

Comments
 (0)