opencv_contrib
opencv_contrib copied to clipboard
Issue building Face module for JS platform
System information (version)
Detailed description
opencv_js.config.py : face = {'': ['createFacemarkLBF', 'createFacemarkAAM', 'createFacemarkKazemi', 'drawFacemarks'], 'Facemark': ['fit', 'loadModel'], 'FacemarkLBF': [], 'FacemarkAAM': [], 'FacemarkKazemi': [], }
JS enabled in Face module make file.
Error:
100%] Generating bindings.cpp
cd /home/svg/opencv/build_wasm/modules/js && /usr/bin/python2.7 /home/svg/opencv/modules/js/src/embindgen.py /home/svg/opencv/modules/js/../python/src2/hdr_parser.py /home/svg/opencv/build_wasm/modules/js/bindings.cpp /home/svg/opencv/build_wasm/modules/js/headers.txt /home/svg/opencv/modules/js/src/core_bindings.cpp
Generator error: unable to resolve base face::Facemark for face_FacemarkKazemi
make[3]: *** [modules/js/CMakeFiles/opencv_js.dir/build.make:143: modules/js/bindings.cpp] Error 255
make[3]: Leaving directory '/home/svg/opencv/build_wasm'
make[2]: *** [CMakeFiles/Makefile2:3856: modules/js/CMakeFiles/opencv_js.dir/all] Error 2
make[2]: Leaving directory '/home/svg/opencv/build_wasm'
make[1]: *** [CMakeFiles/Makefile2:3825: modules/js/CMakeFiles/opencv.js.dir/rule] Error 2
make[1]: Leaving directory '/home/svg/opencv/build_wasm'
make: *** [Makefile:691: opencv.js] Error 2
Traceback (most recent call last):
File "./platforms/js/build_js.py", line 284, in
The program embindgen.py assumes that the list of header filenames is being sorted in order of usage. It looks like the list is not sorted as such which causes facemark.hpp and facemark_train.hpp to be processed after face_alignment.hpp.
https://github.com/opencv/opencv/blob/9fcf0152140c449f74678add820e81de3e69b8b0/modules/js/generator/embindgen.py#L738
From what I can see there are two solutions:
- Parse the #include macros in the header files and make sure any dependencies are being processed first.
- Remove the check around line 328 that makes sure the base class exists.
Here's some quick and dirty code that allows you to compile without fixing this properly:
def gen(self, dst_file, src_files, core_bindings):
# step 0: sort headers
filenameOrder = ['face_alignment.hpp', 'facemarkAAM.hpp', 'facemarkLBF.hpp']
for filename in filenameOrder:
index = next(i for i, v in enumerate(src_files) if v.endswith(filename))
src_files.append(src_files.pop(index))