Skip to content

Commit a30fb44

Browse files
committed
Merge pull request #1447 from sturkmen72:optional_dependencies
2 parents ccfca15 + 90555db commit a30fb44

File tree

4 files changed

+46
-11
lines changed

4 files changed

+46
-11
lines changed

modules/datasets/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
set(the_description "datasets framework")
2-
ocv_define_module(datasets opencv_core opencv_imgcodecs opencv_ml opencv_flann opencv_text WRAP python)
2+
ocv_define_module(datasets opencv_core opencv_imgcodecs opencv_ml opencv_flann OPTIONAL opencv_text WRAP python)
33

44
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4267) # flann, Win64

modules/datasets/samples/tr_chars_benchmark.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@
3939
//
4040
//M*/
4141

42-
#include "opencv2/datasets/tr_chars.hpp"
42+
#include <iostream>
43+
#include <opencv2/opencv_modules.hpp>
4344

44-
#include <opencv2/core.hpp>
45+
#ifdef HAVE_OPENCV_TEXT
4546

47+
#include "opencv2/datasets/tr_chars.hpp"
48+
#include <opencv2/core.hpp>
4649
#include "opencv2/text.hpp"
4750
#include "opencv2/imgproc.hpp"
4851
#include "opencv2/imgcodecs.hpp"
@@ -127,3 +130,13 @@ int main(int argc, char *argv[])
127130

128131
return 0;
129132
}
133+
134+
#else
135+
136+
int main()
137+
{
138+
std::cerr << "OpenCV was built without text module" << std::endl;
139+
return 0;
140+
}
141+
142+
#endif // HAVE_OPENCV_TEXT

modules/datasets/samples/tr_icdar_benchmark.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,20 @@
3939
//
4040
//M*/
4141

42-
#include "opencv2/datasets/tr_icdar.hpp"
42+
#include <iostream>
43+
#include <opencv2/opencv_modules.hpp>
4344

44-
#include <opencv2/core.hpp>
45+
#ifdef HAVE_OPENCV_TEXT
4546

47+
#include "opencv2/datasets/tr_icdar.hpp"
48+
#include <opencv2/core.hpp>
4649
#include "opencv2/text.hpp"
4750
#include "opencv2/imgproc.hpp"
4851
#include "opencv2/imgcodecs.hpp"
4952

5053
#include <cstdio>
5154
#include <cstdlib> // atoi
5255

53-
#include <iostream>
54-
5556
#include <string>
5657
#include <vector>
5758

@@ -509,3 +510,13 @@ int main(int argc, char *argv[])
509510

510511
return 0;
511512
}
513+
514+
#else
515+
516+
int main()
517+
{
518+
std::cerr << "OpenCV was built without text module" << std::endl;
519+
return 0;
520+
}
521+
522+
#endif // HAVE_OPENCV_TEXT

modules/datasets/samples/tr_svt_benchmark.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,20 @@
3939
//
4040
//M*/
4141

42-
#include "opencv2/datasets/tr_svt.hpp"
42+
#include <iostream>
43+
#include <opencv2/opencv_modules.hpp>
4344

44-
#include <opencv2/core.hpp>
45+
#ifdef HAVE_OPENCV_TEXT
4546

47+
#include "opencv2/datasets/tr_svt.hpp"
48+
#include <opencv2/core.hpp>
4649
#include "opencv2/text.hpp"
4750
#include "opencv2/imgproc.hpp"
4851
#include "opencv2/imgcodecs.hpp"
4952

5053
#include <cstdio>
5154
#include <cstdlib> // atoi
5255

53-
#include <iostream>
54-
5556
#include <string>
5657
#include <vector>
5758

@@ -309,3 +310,13 @@ int main(int argc, char *argv[])
309310

310311
return 0;
311312
}
313+
314+
#else
315+
316+
int main()
317+
{
318+
std::cerr << "OpenCV was built without text module" << std::endl;
319+
return 0;
320+
}
321+
322+
#endif // HAVE_OPENCV_TEXT

0 commit comments

Comments
 (0)