-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
conanfile.py
1760 lines (1600 loc) · 80.6 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from conan import ConanFile
from conan.errors import ConanException, ConanInvalidConfiguration
from conan.tools.apple import is_apple_os
from conan.tools.build import check_min_cppstd, valid_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv, VirtualRunEnv
from conan.tools.files import apply_conandata_patches, collect_libs, copy, export_conandata_patches, get, rename, replace_in_file, rmdir, save
from conan.tools.gnu import PkgConfigDeps
from conan.tools.microsoft import msvc_runtime_flag
from conan.tools.scm import Version
import os
import re
import textwrap
required_conan_version = ">=1.60.0 <2.0 || >=2.0.5"
OPENCV_MAIN_MODULES_OPTIONS = (
"calib3d",
"dnn",
"features2d",
"flann",
"gapi",
"highgui",
"imgcodecs",
"imgproc",
"ml",
"objdetect",
"photo",
"stitching",
"video",
"videoio",
)
OPENCV_EXTRA_MODULES_OPTIONS = (
"alphamat",
"aruco",
"barcode",
"bgsegm",
"bioinspired",
"ccalib",
"cudaarithm",
"cudabgsegm",
"cudacodec",
"cudafeatures2d",
"cudafilters",
"cudaimgproc",
"cudalegacy",
"cudaobjdetect",
"cudaoptflow",
"cudastereo",
"cudawarping",
"cvv",
"datasets",
"dnn_objdetect",
"dnn_superres",
"dpm",
"face",
"freetype",
"fuzzy",
"hdf",
"hfs",
"img_hash",
"intensity_transform",
"line_descriptor",
"mcc",
"optflow",
"ovis",
"phase_unwrapping",
"plot",
"quality",
"rapid",
"reg",
"rgbd",
"saliency",
"sfm",
"shape",
"stereo",
"structured_light",
"superres",
"surface_matching",
"text",
"tracking",
"videostab",
"viz",
"wechat_qrcode",
"xfeatures2d",
"ximgproc",
"xobjdetect",
"xphoto",
)
class OpenCVConan(ConanFile):
name = "opencv"
license = "Apache-2.0"
homepage = "https://opencv.org"
description = "OpenCV (Open Source Computer Vision Library)"
url = "https://github.com/conan-io/conan-center-index"
topics = ("computer-vision", "deep-learning", "image-processing")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
# global options
"parallel": [False, "tbb", "openmp"],
"with_ipp": [False, "intel-ipp", "opencv-icv"],
"with_eigen": [True, False],
"neon": [True, False],
"with_opencl": [True, False],
"with_cuda": [True, False],
"with_cublas": [True, False],
"with_cufft": [True, False],
"with_cudnn": [True, False],
"cuda_arch_bin": [None, "ANY"],
"cpu_baseline": [None, "ANY"],
"cpu_dispatch": [None, "ANY"],
"world": [True, False],
"nonfree": [True, False],
# dnn module options
"with_flatbuffers": [True, False],
"with_protobuf": [True, False],
"with_vulkan": [True, False],
"dnn_cuda": [True, False],
# highgui module options
"with_gtk": [True, False],
"with_qt": [True, False],
"with_wayland": [True, False],
# imgcodecs module options
"with_avif": [True, False],
"with_jpeg": [False, "libjpeg", "libjpeg-turbo", "mozjpeg"],
"with_png": [True, False],
"with_tiff": [True, False],
"with_jpeg2000": [False, "jasper", "openjpeg"],
"with_openexr": [True, False],
"with_webp": [True, False],
"with_gdal": [True, False],
"with_gdcm": [True, False],
"with_imgcodec_hdr": [True, False],
"with_imgcodec_pfm": [True, False],
"with_imgcodec_pxm": [True, False],
"with_imgcodec_sunraster": [True, False],
"with_msmf": [True, False],
"with_msmf_dxva": [True, False],
# objdetect module options
"with_quirc": [True, False],
# videoio module options
"with_ffmpeg": [True, False],
"with_v4l": [True, False],
# text module options
"with_tesseract": [True, False],
# TODO: deprecated options to remove in few months
"contrib": [True, False, "deprecated"],
"contrib_freetype": [True, False, "deprecated"],
"contrib_sfm": [True, False, "deprecated"],
"with_ade": [True, False, "deprecated"],
}
options.update({_name: [True, False] for _name in OPENCV_MAIN_MODULES_OPTIONS})
options.update({_name: [True, False] for _name in OPENCV_EXTRA_MODULES_OPTIONS})
default_options = {
"shared": False,
"fPIC": True,
# global options
"parallel": False,
"with_ipp": False,
"with_eigen": True,
"neon": True,
"with_opencl": False,
"with_cuda": False,
"with_cublas": False,
"with_cufft": False,
"with_cudnn": False,
"cuda_arch_bin": None,
"cpu_baseline": None,
"cpu_dispatch": None,
"world": False,
"nonfree": False,
# dnn module options
"with_flatbuffers": True,
"with_protobuf": True,
"with_vulkan": False,
"dnn_cuda": False,
# highgui module options
"with_gtk": False,
"with_qt": False,
"with_wayland": True,
# imgcodecs module options
"with_avif": False,
"with_jpeg": "libjpeg",
"with_png": True,
"with_tiff": True,
"with_jpeg2000": "openjpeg",
"with_openexr": True,
"with_webp": True,
"with_gdal": False,
"with_gdcm": False,
"with_imgcodec_hdr": True,
"with_imgcodec_pfm": True,
"with_imgcodec_pxm": True,
"with_imgcodec_sunraster": True,
"with_msmf": True,
"with_msmf_dxva": True,
# objdetect module options
"with_quirc": True,
# videoio module options
"with_ffmpeg": True,
"with_v4l": False,
# text module options
"with_tesseract": True,
# TODO: deprecated options to remove in few months
"contrib": "deprecated",
"contrib_freetype": "deprecated",
"contrib_sfm": "deprecated",
"with_ade": "deprecated",
}
default_options.update({_name: True for _name in OPENCV_MAIN_MODULES_OPTIONS})
default_options.update({_name: False for _name in OPENCV_EXTRA_MODULES_OPTIONS})
short_paths = True
@property
def _is_cl_like(self):
return self.settings.compiler.get_safe("runtime") is not None
@property
def _is_cl_like_static_runtime(self):
return self._is_cl_like and "MT" in msvc_runtime_flag(self)
@property
def _is_mingw(self):
return self.settings.os == "Windows" and self.settings.compiler == "gcc"
@property
def _is_legacy_one_profile(self):
return not hasattr(self, "settings_build")
@property
def _contrib_folder(self):
return os.path.join(self.source_folder, "contrib")
@property
def _extra_modules_folder(self):
return os.path.join(self._contrib_folder, "modules")
@property
def _has_with_jpeg2000_option(self):
return self.settings.os != "iOS"
@property
def _has_with_tiff_option(self):
return self.settings.os != "iOS"
@property
def _has_with_ffmpeg_option(self):
return self.settings.os != "iOS" and self.settings.os != "WindowsStore"
@property
def _has_superres_option(self):
return self.settings.os != "iOS"
@property
def _has_alphamat_option(self):
return Version(self.version) >= "4.3.0"
@property
def _has_intensity_transform_option(self):
return Version(self.version) >= "4.3.0"
@property
def _has_rapid_option(self):
return Version(self.version) >= "4.3.0"
@property
def _has_mcc_option(self):
return Version(self.version) >= "4.5.0"
@property
def _has_wechat_qrcode_option(self):
return Version(self.version) >= "4.5.2"
@property
def _has_barcode_option(self):
return Version(self.version) >= "4.5.3" and Version(self.version) < "4.8.0"
@property
def _has_with_wayland_option(self):
return Version(self.version) >= "4.7.0" and self.settings.os in ["Linux", "FreeBSD"]
@property
def _has_with_avif_option(self):
return Version(self.version) >= "4.8.0"
@property
def _has_with_flatbuffers_option(self):
return Version(self.version) >= "4.8.0"
def export_sources(self):
export_conandata_patches(self)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if self.settings.os != "Linux":
del self.options.with_gtk
del self.options.with_v4l
if self.settings.os in ["iOS", "Android"]:
del self.options.with_opencl
if self.settings.os != "Windows":
del self.options.with_msmf
del self.options.with_msmf_dxva
if self._has_with_ffmpeg_option:
# Following the packager choice, ffmpeg is enabled by default when
# supported, except on Android. See
# https://github.com/opencv/opencv/blob/39c3334147ec02761b117f180c9c4518be18d1fa/CMakeLists.txt#L266-L268
self.options.with_ffmpeg = self.settings.os != "Android"
else:
del self.options.with_ffmpeg
if not self._has_with_jpeg2000_option:
del self.options.with_jpeg2000
elif Version(self.version) < "4.3.0":
self.options.with_jpeg2000 = "jasper"
if "arm" not in self.settings.arch:
del self.options.neon
if not self._has_with_tiff_option:
del self.options.with_tiff
if not self._has_superres_option:
del self.options.superres
if not self._has_alphamat_option:
del self.options.alphamat
if not self._has_intensity_transform_option:
del self.options.intensity_transform
if not self._has_rapid_option:
del self.options.rapid
if not self._has_mcc_option:
del self.options.mcc
if not self._has_wechat_qrcode_option:
del self.options.wechat_qrcode
if not self._has_barcode_option:
del self.options.barcode
if not self._has_with_wayland_option:
del self.options.with_wayland
if not self._has_with_avif_option:
del self.options.with_avif
if not self._has_with_flatbuffers_option:
del self.options.with_flatbuffers
# Conditional default options
if self._is_mingw:
# These options are visible for Windows, but upstream disables them
# by default for MinGW (actually it would fail otherwise)
self.options.with_msmf = False
self.options.with_msmf_dxva = False
if self.settings.os == "Linux":
# Use Wayland by default, but fallback to GTK for old OpenCV versions.
# gtk/system is problematic for this recpe, there might be side effects
# in a big dependency graph
if not self._has_with_wayland_option:
self.options.with_gtk = True
@property
def _opencv_modules(self):
def imageformats_deps():
components = []
if self.options.get_safe("with_avif"):
components.append("libavif::libavif")
if self.options.get_safe("with_jpeg2000"):
components.append("{0}::{0}".format(self.options.with_jpeg2000))
if self.options.get_safe("with_png"):
components.append("libpng::libpng")
if self.options.get_safe("with_jpeg") == "libjpeg":
components.append("libjpeg::libjpeg")
elif self.options.get_safe("with_jpeg") == "libjpeg-turbo":
components.append("libjpeg-turbo::jpeg")
elif self.options.get_safe("with_jpeg") == "mozjpeg":
components.append("mozjpeg::libjpeg")
if self.options.get_safe("with_tiff"):
components.append("libtiff::libtiff")
if self.options.get_safe("with_openexr"):
components.append("openexr::openexr")
if self.options.get_safe("with_webp"):
components.append("libwebp::libwebp")
if self.options.get_safe("with_gdal"):
components.append("gdal::gdal")
if self.options.get_safe("with_gdcm"):
components.append("gdcm::gdcm")
return components
def eigen():
return ["eigen::eigen"] if self.options.with_eigen else []
def ffmpeg():
components = []
if self.options.get_safe("with_ffmpeg"):
components = ["ffmpeg::avcodec", "ffmpeg::avformat", "ffmpeg::avutil", "ffmpeg::swscale"]
return components
def gtk():
return ["gtk::gtk"] if self.options.get_safe("with_gtk") else []
def ipp():
if self.options.with_ipp == "intel-ipp":
return ["intel-ipp::intel-ipp"]
elif self.options.with_ipp == "opencv-icv" and not self.options.shared:
return ["ippiw"]
return []
def parallel():
return ["onetbb::onetbb"] if self.options.parallel == "tbb" else []
def protobuf():
return ["protobuf::protobuf"] if self.options.get_safe("with_protobuf") else []
def qt():
return ["qt::qt"] if self.options.get_safe("with_qt") else []
def quirc():
return ["quirc::quirc"] if self.options.get_safe("with_quirc") else []
def tesseract():
return ["tesseract::tesseract"] if self.options.get_safe("with_tesseract") else []
def vulkan():
return ["vulkan-headers::vulkan-headers"] if self.options.get_safe("with_vulkan") else []
def wayland():
return ["wayland::wayland-client", "wayland::wayland-cursor"] if self.options.get_safe("with_wayland") else []
def xkbcommon():
return ["xkbcommon::libxkbcommon"] if self.options.get_safe("with_wayland") else []
def opencv_calib3d():
return ["opencv_calib3d"] if self.options.calib3d else []
def opencv_cudaarithm():
return ["opencv_cudaarithm"] if self.options.cudaarithm else []
def opencv_cudacodec():
return ["opencv_cudacodec"] if self.options.cudacodec else []
def opencv_cudafeatures2d():
return ["opencv_cudafeatures2d"] if self.options.cudafeatures2d else []
def opencv_cudafilters():
return ["opencv_cudafilters"] if self.options.cudafilters else []
def opencv_cudaimgproc():
return ["opencv_cudaimgproc"] if self.options.cudaimgproc else []
def opencv_cudalegacy():
return ["opencv_cudalegacy"] if self.options.cudalegacy else []
def opencv_cudaoptflow():
return ["opencv_cudaoptflow"] if self.options.cudaoptflow else []
def opencv_cudawarping():
return ["opencv_cudawarping"] if self.options.cudawarping else []
def opencv_dnn():
return ["opencv_dnn"] if self.options.dnn else []
def opencv_flann():
return ["opencv_flann"] if self.options.flann else []
def opencv_imgcodecs():
return ["opencv_imgcodecs"] if self.options.imgcodecs else []
def opencv_imgproc():
return ["opencv_imgproc"] if self.options.imgproc else []
def opencv_objdetect():
return ["opencv_objdetect"] if self.options.objdetect else []
def opencv_video():
return ["opencv_video"] if self.options.video else []
def opencv_videoio():
return ["opencv_videoio"] if self.options.videoio else []
def opencv_xfeatures2d():
return ["opencv_xfeatures2d"] if self.options.xfeatures2d else []
opencv_modules = {
# Main modules
"calib3d": {
"is_built": self.options.calib3d,
"mandatory_options": ["features2d", "flann", "imgproc"],
"requires": ["opencv_core", "opencv_features2d", "opencv_flann", "opencv_imgproc"] + eigen() + ipp(),
},
"core": {
"is_built": True,
"no_option": True,
"requires": ["zlib::zlib"] + parallel() + eigen() + ipp(),
"system_libs": [
(self.settings.os == "Android", ["dl", "m", "log"]),
(self.settings.os == "FreeBSD", ["m", "pthread"]),
(self.settings.os == "Linux", ["dl", "m", "pthread", "rt"]),
],
"frameworks": [
(self.settings.os == "Macos" and self.options.get_safe("with_opencl"), ["OpenCL"]),
],
},
"dnn": {
"is_built": self.options.dnn,
"mandatory_options": ["imgproc"],
"requires": ["opencv_core", "opencv_imgproc"] + protobuf() + vulkan() + ipp(),
},
"features2d": {
"is_built": self.options.features2d,
"mandatory_options": ["imgproc"],
"requires": ["opencv_imgproc"] + opencv_flann() + eigen() + ipp(),
},
"flann": {
"is_built": self.options.flann,
"requires": ["opencv_core"] + ipp(),
},
"gapi": {
"is_built": self.options.gapi,
"mandatory_options": ["imgproc"],
"requires": ["opencv_imgproc", "ade::ade"],
"system_libs": [
(self.settings.os == "Windows", ["ws2_32", "wsock32"]),
],
},
"highgui": {
"is_built": self.options.highgui,
"mandatory_options": ["imgproc"],
"requires": ["opencv_core", "opencv_imgproc"] + opencv_imgcodecs() +
opencv_videoio() + gtk() + qt() + xkbcommon() + wayland() + ipp(),
"system_libs": [
(self.settings.os == "Windows", ["comctl32", "gdi32", "ole32", "setupapi", "ws2_32", "vfw32"]),
],
"frameworks": [
(self.settings.os == "Macos", ["Cocoa"]),
],
},
"imgcodecs": {
"is_built": self.options.imgcodecs,
"mandatory_options": ["imgproc"],
"requires": ["opencv_imgproc", "zlib::zlib"] + imageformats_deps() + ipp(),
"frameworks": [
(is_apple_os(self), ["CoreFoundation", "CoreGraphics"]),
(self.settings.os == "iOS", ["UIKit"]),
(self.settings.os == "Macos", ["AppKit"]),
],
},
"imgproc": {
"is_built": self.options.imgproc,
"requires": ["opencv_core"] + ipp(),
},
"ml": {
"is_built": self.options.ml,
"requires": ["opencv_core"] + ipp(),
},
"objdetect": {
"is_built": self.options.objdetect,
"mandatory_options": ["calib3d", "imgproc"],
"requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc"] + quirc() + ipp(),
},
"photo": {
"is_built": self.options.photo,
"mandatory_options": ["imgproc"],
"requires": ["opencv_imgproc"] + opencv_cudaarithm() + opencv_cudaimgproc() + ipp(),
},
"stitching": {
"is_built": self.options.stitching,
"mandatory_options": ["calib3d", "features2d", "flann", "imgproc"],
"requires": ["opencv_calib3d", "opencv_features2d", "opencv_flann", "opencv_imgproc"] +
opencv_xfeatures2d() + opencv_cudaarithm() + opencv_cudawarping() +
opencv_cudafeatures2d() + opencv_cudalegacy() + opencv_cudaimgproc() + eigen() + ipp(),
},
"video": {
"is_built": self.options.video,
"mandatory_options": ["imgproc"],
"requires": ["opencv_imgproc"] + opencv_calib3d() + ipp(),
},
"videoio": {
"is_built": self.options.videoio,
"mandatory_options": ["imgcodecs", "imgproc"],
"requires": ["opencv_imgcodecs", "opencv_imgproc"] + ffmpeg() + ipp(),
"system_libs": [
(self.settings.os == "Android" and int(str(self.settings.os.api_level)) > 20, ["mediandk"]),
],
"frameworks": [
(is_apple_os(self), ["Accelerate", "AVFoundation", "CoreGraphics", "CoreMedia", "CoreVideo", "QuartzCore"]),
(self.settings.os == "iOS", ["CoreImage", "UIKit"]),
(self.settings.os == "Macos", ["Cocoa"]),
],
},
# Extra modules
"alphamat": {
"is_built": self.options.get_safe("alphamat"),
"mandatory_options": ["with_eigen", "imgproc"],
"requires": ["opencv_core", "opencv_imgproc"] + ipp(),
},
"aruco": {
"is_built": self.options.aruco,
"mandatory_options": ["calib3d", "imgproc"],
"requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc"] + ipp(),
},
"barcode": {
"is_built": self.options.get_safe("barcode"),
"mandatory_options": ["dnn", "imgproc"],
"requires": ["opencv_core", "opencv_dnn", "opencv_imgproc"] + ipp(),
},
"bgsegm": {
"is_built": self.options.bgsegm,
"mandatory_options": ["calib3d", "imgproc", "video"],
"requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc", "opencv_video"] + ipp(),
},
"bioinspired": {
"is_built": self.options.bioinspired,
"requires": ["opencv_core"] + ipp(),
},
"ccalib": {
"is_built": self.options.ccalib,
"mandatory_options": ["calib3d", "features2d", "highgui", "imgproc"],
"requires": ["opencv_core", "opencv_calib3d", "opencv_features2d", "opencv_highgui", "opencv_imgproc"] + ipp(),
},
"cudaarithm": {
"is_built": self.options.cudaarithm,
"mandatory_options": ["with_cuda"],
"requires": ["opencv_core", "opencv_cudev"] + ipp(),
},
"cudabgsegm": {
"is_built": self.options.cudabgsegm,
"mandatory_options": ["with_cuda", "video"],
"requires": ["opencv_video"] + ipp(),
},
"cudacodec": {
"is_built": self.options.cudacodec,
"mandatory_options": ["with_cuda", "videoio"],
"requires": ["opencv_core", "opencv_videoio"] + ipp(),
},
"cudafeatures2d": {
"is_built": self.options.cudafeatures2d,
"mandatory_options": ["with_cuda", "features2d", "cudafilters", "cudawarping"],
"requires": ["opencv_features2d", "opencv_cudafilters", "opencv_cudawarping"] + ipp(),
},
"cudafilters": {
"is_built": self.options.cudafilters,
"mandatory_options": ["with_cuda", "imgproc", "cudaarithm"],
"requires": ["opencv_imgproc", "opencv_cudaarithm"] + ipp(),
},
"cudaimgproc": {
"is_built": self.options.cudaimgproc,
"mandatory_options": ["with_cuda", "imgproc"],
"requires": ["opencv_imgproc", "opencv_cudev"] + opencv_cudaarithm() + opencv_cudafilters() + ipp(),
},
"cudalegacy": {
"is_built": self.options.cudalegacy,
"mandatory_options": ["with_cuda", "video"],
"requires": ["opencv_core", "opencv_video"] + opencv_calib3d() + opencv_imgproc() + opencv_objdetect() +
opencv_cudaarithm() + opencv_cudafilters() + opencv_cudaimgproc() + ipp(),
},
"cudaobjdetect": {
"is_built": self.options.cudaobjdetect,
"mandatory_options": ["with_cuda", "objdetect", "cudaarithm", "cudawarping"],
"requires": ["opencv_objdetect", "opencv_cudaarithm", "opencv_cudawarping"] + opencv_cudalegacy() + ipp(),
},
"cudaoptflow": {
"is_built": self.options.cudaoptflow,
"mandatory_options": ["with_cuda", "video", "cudaarithm", "cudaimgproc", "cudawarping", "optflow"],
"requires": ["opencv_video", "opencv_cudaarithm", "opencv_cudaimgproc", "opencv_cudawarping",
"opencv_optflow"] + opencv_cudalegacy() + ipp(),
},
"cudastereo": {
"is_built": self.options.cudastereo,
"mandatory_options": ["with_cuda", "calib3d"],
"requires": ["opencv_calib3d", "opencv_cudev"] + ipp(),
},
"cudawarping": {
"is_built": self.options.cudawarping,
"mandatory_options": ["with_cuda", "imgproc"],
"requires": ["opencv_core", "opencv_imgproc", "opencv_cudev"] + ipp(),
},
"cudev": {
"is_built": self.options.with_cuda,
"no_option": True,
"requires": ipp(),
},
"cvv": {
"is_built": self.options.cvv,
"mandatory_options": ["with_qt", "features2d", "imgproc"],
"requires": ["opencv_core", "opencv_features2d", "opencv_imgproc", "qt::qt"] + ipp(),
},
"datasets": {
"is_built": self.options.datasets,
"mandatory_options": ["flann", "imgcodecs", "ml"],
"requires": ["opencv_core", "opencv_flann", "opencv_imgcodecs", "opencv_ml"] + ipp(),
},
"dnn_objdetect": {
"is_built": self.options.dnn_objdetect,
"mandatory_options": ["dnn", "imgproc"],
"requires": ["opencv_core", "opencv_dnn", "opencv_imgproc"] + ipp(),
},
"dnn_superres": {
"is_built": self.options.dnn_superres,
"mandatory_options": ["dnn", "imgproc"],
"requires": ["opencv_core", "opencv_dnn", "opencv_imgproc"] + ipp(),
},
"dpm": {
"is_built": self.options.dpm,
"mandatory_options": ["imgproc", "objdetect"],
"requires": ["opencv_core", "opencv_imgproc", "opencv_objdetect"] + ipp(),
},
"face": {
"is_built": self.options.face,
"mandatory_options": ["calib3d", "imgproc", "objdetect", "photo"],
"requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc", "opencv_objdetect", "opencv_photo"] + ipp(),
},
"freetype": {
"is_built": self.options.freetype,
"mandatory_options": ["imgproc"],
"requires": ["opencv_core", "opencv_imgproc", "freetype::freetype", "harfbuzz::harfbuzz"] + ipp(),
},
"fuzzy": {
"is_built": self.options.fuzzy,
"mandatory_options": ["imgproc"],
"requires": ["opencv_core", "opencv_imgproc"] + ipp(),
},
"hdf": {
"is_built": self.options.hdf,
"requires": ["opencv_core", "hdf5::hdf5"] + ipp(),
},
"hfs": {
"is_built": self.options.hfs,
"mandatory_options": ["imgproc"],
"requires": ["opencv_core", "opencv_imgproc"] + ipp(),
},
"img_hash": {
"is_built": self.options.img_hash,
"is_part_of_world": False,
"mandatory_options": ["imgproc"],
"requires": ["opencv_core", "opencv_imgproc"] + ipp(),
},
"intensity_transform": {
"is_built": self.options.get_safe("intensity_transform"),
"requires": ["opencv_core"] + ipp(),
},
"line_descriptor": {
"is_built": self.options.line_descriptor,
"mandatory_options": ["imgproc"],
"requires": ["opencv_imgproc"] + ipp(),
},
"mcc": {
"is_built": self.options.get_safe("mcc"),
"mandatory_options": ["calib3d", "dnn", "imgproc"],
"requires": ["opencv_core", "opencv_calib3d", "opencv_dnn", "opencv_imgproc"] + ipp(),
},
"optflow": {
"is_built": self.options.optflow,
"mandatory_options": ["calib3d", "flann", "imgcodecs", "imgproc", "video", "ximgproc"],
"requires": ["opencv_core", "opencv_calib3d", "opencv_flann", "opencv_imgcodecs", "opencv_imgproc",
"opencv_video", "opencv_ximgproc"] + ipp(),
},
"ovis": {
"is_built": self.options.ovis,
"mandatory_options": ["calib3d", "imgproc"],
"requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc", "ogre::ogre"] + ipp(),
},
"phase_unwrapping": {
"is_built": self.options.phase_unwrapping,
"mandatory_options": ["imgproc"],
"requires": ["opencv_core", "opencv_imgproc"] + ipp(),
},
"plot": {
"is_built": self.options.plot,
"mandatory_options": ["imgproc"],
"requires": ["opencv_core", "opencv_imgproc"] + ipp(),
},
"quality": {
"is_built": self.options.quality,
"mandatory_options": ["imgproc", "ml"],
"requires": ["opencv_core", "opencv_imgproc", "opencv_ml"] + ipp(),
},
"rapid": {
"is_built": self.options.get_safe("rapid"),
"mandatory_options": ["calib3d", "imgproc"],
"requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc"] + ipp(),
},
"reg": {
"is_built": self.options.reg,
"mandatory_options": ["imgproc"],
"requires": ["opencv_core", "opencv_imgproc"] + ipp(),
},
"rgbd": {
"is_built": self.options.rgbd,
"mandatory_options": ["calib3d", "imgproc"],
"requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc"] + eigen() + ipp(),
},
"saliency": {
"is_built": self.options.saliency,
"mandatory_options": ["features2d", "imgproc"],
"requires": ["opencv_features2d", "opencv_imgproc"] + ipp(),
},
"sfm": {
"is_built": self.options.sfm,
"is_part_of_world": False,
"mandatory_options": ["with_eigen", "calib3d", "features2d", "imgcodecs", "xfeatures2d"],
"requires": ["opencv_core", "opencv_calib3d", "opencv_features2d", "opencv_imgcodecs", "opencv_xfeatures2d",
"correspondence", "multiview", "numeric", "glog::glog", "gflags::gflags"] + eigen() + ipp(),
},
"shape": {
"is_built": self.options.shape,
"mandatory_options": ["calib3d", "imgproc"],
"requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc"] + ipp(),
},
"stereo": {
"is_built": self.options.stereo,
"mandatory_options": ["features2d", "imgproc", "tracking"],
"requires": ["opencv_core", "opencv_features2d", "opencv_imgproc", "opencv_tracking"] + ipp(),
},
"structured_light": {
"is_built": self.options.structured_light,
"mandatory_options": ["calib3d", "imgproc", "phase_unwrapping"],
"requires": ["opencv_core", "opencv_calib3d", "opencv_imgproc", "opencv_phase_unwrapping"] + ipp(),
},
"superres": {
"is_built": self.options.get_safe("superres"),
"mandatory_options": ["imgproc", "video", "optflow"],
"requires": ["opencv_imgproc", "opencv_video", "opencv_optflow"] + opencv_videoio() + ipp() +
opencv_cudaarithm() + opencv_cudafilters() + opencv_cudawarping() + opencv_cudaimgproc() +
opencv_cudaoptflow() + opencv_cudacodec(),
},
"surface_matching": {
"is_built": self.options.surface_matching,
"mandatory_options": ["flann"],
"requires": ["opencv_core", "opencv_flann"] + ipp(),
},
"text": {
"is_built": self.options.text,
"mandatory_options": ["dnn", "features2d", "imgproc", "ml"],
"requires": ["opencv_core", "opencv_dnn", "opencv_features2d", "opencv_imgproc", "opencv_ml"] +
tesseract() + ipp(),
},
"tracking": {
"is_built": self.options.tracking,
"mandatory_options": ["imgproc", "video"],
"requires": ["opencv_core", "opencv_imgproc", "opencv_video"] + opencv_dnn() + ipp(),
},
"videostab": {
"is_built": self.options.videostab,
"mandatory_options": ["calib3d", "features2d", "imgproc", "photo", "video"],
"requires": ["opencv_calib3d", "opencv_features2d", "opencv_imgproc", "opencv_photo", "opencv_video"] +
opencv_videoio() + ipp() + opencv_cudawarping() + opencv_cudaoptflow(),
},
"viz": {
"is_built": self.options.viz,
"requires": ["opencv_core", "vtk::vtk"] + ipp(),
},
"wechat_qrcode": {
"is_built": self.options.get_safe("wechat_qrcode"),
"mandatory_options": ["dnn", "imgproc"],
"requires": ["opencv_core", "opencv_dnn", "opencv_imgproc"] + ipp(),
},
"xfeatures2d": {
"is_built": self.options.xfeatures2d,
"mandatory_options": ["calib3d", "features2d", "imgproc"],
"requires": ["opencv_core", "opencv_calib3d", "opencv_features2d", "opencv_imgproc"] + ipp() + opencv_cudaarithm(),
},
"ximgproc": {
"is_built": self.options.ximgproc,
"mandatory_options": ["calib3d", "imgcodecs", "imgproc", "video"],
"requires": ["opencv_core", "opencv_calib3d", "opencv_imgcodecs", "opencv_imgproc", "opencv_video"] +
eigen() + ipp(),
},
"xobjdetect": {
"is_built": self.options.xobjdetect,
"mandatory_options": ["imgcodecs", "imgproc", "objdetect"],
"requires": ["opencv_core", "opencv_imgcodecs", "opencv_imgproc", "opencv_objdetect"] + ipp(),
},
"xphoto": {
"is_built": self.options.xphoto,
"mandatory_options": ["imgproc", "photo"],
"requires": ["opencv_core", "opencv_imgproc", "opencv_photo"] + ipp(),
},
# Extra targets (without prefix in their target & lib name)
"ippiw": {
"is_built": self.options.with_ipp == "opencv-icv" and not self.options.shared,
"is_part_of_world": False,
"no_option": True,
},
"numeric": {
"is_built": self.options.sfm,
"is_part_of_world": False,
"no_option": True,
"requires": eigen() + ipp(),
},
"correspondence": {
"is_built": self.options.sfm,
"is_part_of_world": False,
"no_option": True,
"requires": ["opencv_imgcodecs", "multiview", "glog::glog"] + eigen() + ipp(),
},
"multiview": {
"is_built": self.options.sfm,
"is_part_of_world": False,
"no_option": True,
"requires": ["numeric", "glog::glog"] + eigen() + ipp(),
},
}
if Version(self.version) >= "4.3.0":
opencv_modules["gapi"].setdefault("requires", []).extend(opencv_video())
if Version(self.version) >= "4.5.2":
opencv_modules["gapi"].setdefault("requires", []).extend(opencv_calib3d())
if Version(self.version) >= "4.5.4":
opencv_modules["objdetect"].setdefault("requires", []).extend(opencv_dnn())
if Version(self.version) >= "4.5.1":
opencv_modules["video"].setdefault("requires", []).extend(opencv_dnn())
if Version(self.version) >= "4.4.0":
opencv_modules["intensity_transform"].setdefault("mandatory_options", []).append("imgproc")
opencv_modules["intensity_transform"].setdefault("requires", []).append("opencv_imgproc")
if Version(self.version) < "4.3.0":
opencv_modules["stereo"].setdefault("mandatory_options", []).extend(["calib3d", "video"])
opencv_modules["stereo"].setdefault("requires", []).extend(["opencv_calib3d", "opencv_video"])
if Version(self.version) >= "4.7.0":
opencv_modules["aruco"].setdefault("mandatory_options", []).append("objdetect")
opencv_modules["aruco"].setdefault("requires", []).append("opencv_objdetect")
opencv_modules["cudacodec"].setdefault("mandatory_options", []).extend(["cudaarithm", "cudawarping"])
opencv_modules["cudacodec"].setdefault("requires", []).extend(["opencv_cudaarithm", "opencv_cudawarping"])
opencv_modules["wechat_qrcode"].setdefault("mandatory_options", []).append("objdetect")
opencv_modules["wechat_qrcode"].setdefault("requires", []).append("opencv_objdetect")
else:
opencv_modules["cudacodec"].setdefault("requires", []).append("opencv_cudev")
if Version(self.version) < "4.8.0":
opencv_modules["dnn"].setdefault("mandatory_options", []).append("with_protobuf")
return opencv_modules
def _get_mandatory_disabled_options(self, opencv_modules):
direct_options_to_enable = {}
transitive_options_to_enable = {}
# Check which direct options have to be enabled
base_options = [option for option, values in opencv_modules.items()
if not values.get("no_option") and self.options.get_safe(option)]
for base_option in base_options:
for mandatory_option in opencv_modules.get(base_option, {}).get("mandatory_options", []):
if not self.options.get_safe(mandatory_option):
direct_options_to_enable.setdefault(mandatory_option, set()).add(base_option)
# Now traverse the graph to check which transitive options have to be enabled
def collect_transitive_options(base_option, option):
for mandatory_option in opencv_modules.get(option, {}).get("mandatory_options", []):
if not self.options.get_safe(mandatory_option):
if mandatory_option not in transitive_options_to_enable:
transitive_options_to_enable[mandatory_option] = set()
collect_transitive_options(base_option, mandatory_option)
if base_option not in direct_options_to_enable.get(mandatory_option, set()):
transitive_options_to_enable[mandatory_option].add(base_option)
for base_option in base_options:
collect_transitive_options(base_option, base_option)
return {
"direct": direct_options_to_enable,
"transitive": transitive_options_to_enable,
}
def _solve_internal_dependency_graph(self, opencv_modules):
disabled_options = self._get_mandatory_disabled_options(opencv_modules)
direct_options_to_enable = disabled_options["direct"]
transitive_options_to_enable = disabled_options["transitive"]
# Enable mandatory options
all_options_to_enable = set(direct_options_to_enable.keys())
all_options_to_enable.update(transitive_options_to_enable.keys())
if all_options_to_enable:
message = ("Several opencv options which were disabled will be enabled because "
"they are required by modules you have explicitly requested:\n")
for option_to_enable in all_options_to_enable:
try:
setattr(self.options, option_to_enable, True)
except ConanException:
# It may not work in conan v2 and raise ConanException "Incorrect attempt to modify option"
continue
direct_and_transitive = []
direct = ", ".join(direct_options_to_enable.get(option_to_enable, []))
if direct:
direct_and_transitive.append(f"direct dependency of {direct}")
transitive = ", ".join(transitive_options_to_enable.get(option_to_enable, []))
if transitive:
direct_and_transitive.append(f"transitive dependency of {transitive}")
message += f" - {option_to_enable}: {' / '.join(direct_and_transitive)}\n"
self.output.warning(message)
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
# TODO: remove contrib option in few months