Skip to content

Commit

Permalink
compiled opencv with Oz compiler flag
Browse files Browse the repository at this point in the history
  • Loading branch information
latsic committed Mar 22, 2019
1 parent bedc90d commit d0e702e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
1 change: 1 addition & 0 deletions build_opencv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ cd opencv_src

#python ./platforms/js/build_js.py build --build_wasm --enable_exception --allow_memory_growth --binaryen_trap_mode_clamp
python ./platforms/js/build_js.py build --build_wasm --binaryen_trap_mode_clamp --allow_memory_growth
#python ./platforms/js/build_js.py build --build_wasm --binaryen_trap_mode_clamp --allow_memory_growth --closurec1

cd ..

Expand Down
2 changes: 1 addition & 1 deletion opencv_src/cmake/OpenCVCompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ if(CV_GCC OR CV_CLANG)
add_extra_compiler_option(-flto=thin)
endif()

set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} -DNDEBUG")
set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} -Oz -DNDEBUG")
if(NOT " ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} ${OPENCV_EXTRA_FLAGS_DEBUG} " MATCHES "-O")
set(OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG} -O0")
endif()
Expand Down
2 changes: 1 addition & 1 deletion opencv_src/modules/features2d/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
set(the_description "2D Features Framework")
ocv_define_module(features2d opencv_imgproc opencv_calib3d OPTIONAL opencv_flann opencv_highgui WRAP java python js)
ocv_define_module(features2d opencv_imgproc opencv_calib3d OPTIONAL opencv_flann WRAP java python js)
30 changes: 16 additions & 14 deletions opencv_src/modules/js/src/embindgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
]

# Classes and methods whitelist

core = {'': ['absdiff', 'add', 'addWeighted', 'bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'cartToPolar',\
'compare', 'convertScaleAbs', 'copyMakeBorder', 'countNonZero', 'determinant', 'dft', 'divide', 'eigen', \
'exp', 'flip', 'getOptimalDFTSize','gemm', 'hconcat', 'inRange', 'invert', 'kmeans', 'log', 'magnitude', \
Expand Down Expand Up @@ -131,21 +132,22 @@

features2d = {'Feature2D': ['detect', 'compute', 'detectAndCompute', 'descriptorSize', 'descriptorType', 'defaultNorm', 'empty', 'getDefaultName'],
'ImgAlign': ['create', 'set', 'match', 'match_getAlignedImage', 'match_getTransMatrix', 'match_getExtData', 'getImageAligned', 'getImageBlended', 'getFixedImageWithMatchedPoints', 'getMovingImageWithMatchedPoints', 'getSideBySideImage', 'compare', 'getImageBlendedPolygonFixedImage', 'getImageBlendedPolygonMovingImage', 'getImageFloodFillFixedImage', 'getImageFloodFillMovingImage', 'getStitchedImage', 'stitch'],
'ImgStitch': ['create', 'setImages', 'set', 'stitch', 'stitchStart', 'stitchNext'],
'BRISK': ['create', 'getDefaultName'],
'ORB': ['create', 'setMaxFeatures', 'setScaleFactor', 'setNLevels', 'setEdgeThreshold', 'setFirstLevel', 'setWTA_K', 'setScoreType', 'setPatchSize', 'getFastThreshold', 'getDefaultName'],
'SIFT': ['create'],
'SURF': ['create'],
'MSER': ['create', 'detectRegions', 'setDelta', 'getDelta', 'setMinArea', 'getMinArea', 'setMaxArea', 'getMaxArea', 'setPass2Only', 'getPass2Only', 'getDefaultName'],
'FastFeatureDetector': ['create', 'setThreshold', 'getThreshold', 'setNonmaxSuppression', 'getNonmaxSuppression', 'setType', 'getType', 'getDefaultName'],
'AgastFeatureDetector': ['create', 'setThreshold', 'getThreshold', 'setNonmaxSuppression', 'getNonmaxSuppression', 'setType', 'getType', 'getDefaultName'],
'GFTTDetector': ['create', 'setMaxFeatures', 'getMaxFeatures', 'setQualityLevel', 'getQualityLevel', 'setMinDistance', 'getMinDistance', 'setBlockSize', 'getBlockSize', 'setHarrisDetector', 'getHarrisDetector', 'setK', 'getK', 'getDefaultName'],
'ImgStitch': ['create', 'setImages', 'set', 'stitch', 'stitchStart', 'stitchNext']
#'BRISK': ['create', 'getDefaultName'],
#'ORB': ['create', 'setMaxFeatures', 'setScaleFactor', 'setNLevels', 'setEdgeThreshold', 'setFirstLevel', 'setWTA_K', 'setScoreType', 'setPatchSize', 'getFastThreshold', 'getDefaultName'],
#'SIFT': ['create'],
#'SURF': ['create'],
#'MSER': ['create', 'detectRegions', 'setDelta', 'getDelta', 'setMinArea', 'getMinArea', 'setMaxArea', 'getMaxArea', 'setPass2Only', 'getPass2Only', 'getDefaultName'],
#'FastFeatureDetector': ['create', 'setThreshold', 'getThreshold', 'setNonmaxSuppression', 'getNonmaxSuppression', 'setType', 'getType', 'getDefaultName'],
#'AgastFeatureDetector': ['create', 'setThreshold', 'getThreshold', 'setNonmaxSuppression', 'getNonmaxSuppression', 'setType', 'getType', 'getDefaultName'],
#'GFTTDetector': ['create', 'setMaxFeatures', 'getMaxFeatures', 'setQualityLevel', 'getQualityLevel', 'setMinDistance', 'getMinDistance', 'setBlockSize', 'getBlockSize', 'setHarrisDetector', 'getHarrisDetector', 'setK', 'getK', 'getDefaultName'],
# 'SimpleBlobDetector': ['create'],
'KAZE': ['create', 'setExtended', 'getExtended', 'setUpright', 'getUpright', 'setThreshold', 'getThreshold', 'setNOctaves', 'getNOctaves', 'setNOctaveLayers', 'getNOctaveLayers', 'setDiffusivity', 'getDiffusivity', 'getDefaultName'],
'AKAZE': ['create', 'setDescriptorType', 'getDescriptorType', 'setDescriptorSize', 'getDescriptorSize', 'setDescriptorChannels', 'getDescriptorChannels', 'setThreshold', 'getThreshold', 'setNOctaves', 'getNOctaves', 'setNOctaveLayers', 'getNOctaveLayers', 'setDiffusivity', 'getDiffusivity', 'getDefaultName'],
'DescriptorMatcher': ['add', 'clear', 'empty', 'isMaskSupported', 'train', 'match', 'knnMatch', 'radiusMatch', 'clone', 'create'],
'BFMatcher': ['isMaskSupported', 'create'],
'': ['FAST', 'AGAST', 'drawKeypoints', 'drawMatches']}
#'KAZE': ['create', 'setExtended', 'getExtended', 'setUpright', 'getUpright', 'setThreshold', 'getThreshold', 'setNOctaves', 'getNOctaves', 'setNOctaveLayers', 'getNOctaveLayers', 'setDiffusivity', 'getDiffusivity', 'getDefaultName'],
#'AKAZE': ['create', 'setDescriptorType', 'getDescriptorType', 'setDescriptorSize', 'getDescriptorSize', 'setDescriptorChannels', 'getDescriptorChannels', 'setThreshold', 'getThreshold', 'setNOctaves', 'getNOctaves', 'setNOctaveLayers', 'getNOctaveLayers', 'setDiffusivity', 'getDiffusivity', 'getDefaultName'],
#'DescriptorMatcher': ['add', 'clear', 'empty', 'isMaskSupported', 'train', 'match', 'knnMatch', 'radiusMatch', 'clone', 'create'],
#'BFMatcher': ['isMaskSupported', 'create'],
#'': ['FAST', 'AGAST', 'drawKeypoints', 'drawMatches']
}

def makeWhiteList(module_list):
wl = {}
Expand Down
3 changes: 3 additions & 0 deletions opencv_src/platforms/js/build_js.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ def get_build_flags(self):
flags += "-s BINARYEN_TRAP_MODE='clamp' "
if self.options.allow_memory_growth:
flags += "-s ALLOW_MEMORY_GROWTH=1 "
if self.options.closurec1:
flags += "--closure 1 -s MODULARIZE=1 "
return flags

def config(self):
Expand Down Expand Up @@ -199,6 +201,7 @@ def build_doc(self):
parser.add_argument('--enable_exception', action="store_true", help="Enable exception handling")
parser.add_argument('--binaryen_trap_mode_clamp', action="store_true", help="Enable trap mode clamp")
parser.add_argument('--allow_memory_growth', action="store_true", help="Allow memory growth")
parser.add_argument('--closurec1', action="store_true", help="closure compiler")

args = parser.parse_args()

Expand Down
2 changes: 1 addition & 1 deletion public/js/opencv_3_4_custom.js

Large diffs are not rendered by default.

0 comments on commit d0e702e

Please sign in to comment.