GSoC 2017: Improve and Extend the JavaScript Bindings for OpenCV (#9466)
* Initial support for build with emscripten
mkdir build_js
cd build_js
cmake -D CMAKE_TOOLCHAIN_FILE=/path/to/emsdk/emsdk-portable/emscripten/master/cmake/Modules/Platform/Emscripten.cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
* Add js module
The output is build/bin/opencv_js.js
* Fix opencv2/calib3d.hpp not found issue
* Add module name
Usage:
var cv = cv();
* Add total memory as 128MB and allow growth
* Add compilation flags for emscripten
* Use EMSCRIPTEN build target
* Disable js module for non emscripten build
* Bind the preload file path to root
Usage:
face_cascade.load('haarcascade_frontalface_default.xml');
* add test folder
* fix test files
* Copy js module test to bin
* Support to run tests on Node.js
Fix tests to import cv Module when runtime is node.
Add tests.js to use qunit to auto run tests.
Modify umd wrapper to support Module is not defined.
Usage:
node tests.js
* Support UMD and file system
Wrap the opencv_js.js to opencv.js by UMD wrapper
Use emscripten file system API to load files instead of generating data file or
embedding them. It supports both browser and node.js usages.
* Fix incorrect module name in tests
* Add package.json to add dependence of qunit
* Add js_tutorials folder and a intro page of opencv.js
Enable BUILD_DOCS in CMakeLists.txt.
Add new folder of js_tutorials in folder opencv/doc.
Imitate the tutorials of OpenCV-Python to create a intro page of opencv.js and a setup guide
* Import and use binding gen from opencvjs project
* Modify the embindgen.py to pass the build and test
* Add classes and functions white list
* Consolidate hdr_parser.py (#31)
Use hdr_parser.py of python module
Add js flag to support js binding generator.
* Use emscripten::vecFromJSArray for input vector param
Fix part of #23
* Fix test cases after #34Fix#39
* Expose groupRectangles and CascadeClassifier.empty
* Add js highgui tutorials
add tutorials of imread&imshow and createTrackbar in doc/js_tutorials/js_gui folder
add interactive tutorial webpage for imread&imshow and createTrackbar in doc/js_tutorials/js_interactive_tutorials folder, and some images needed.
change doc/CMakeLists.txt to copy the interactive tutorial webpage and opencv.js to the tutorials' destination folder
* rm useless annotation in doc/CMakeLists.txt
* fix some nonstandard indentation and space
* add check if canvas is valid
* Expose BackgroundSubtractorMOG2
Fix#43
* Fix build of js doc
Limit copy_js_interactive_tutorials for doxygen build
Add dep to opencv.js
Fix#53
* Implement cv.imread & cv.imshow and insert interactive pages in tutorials (#55)
* add helper.js
* delete ALL in add target copy_js_interactive_tutorials to avoid dependence error
* Insert interactive pages in tutorials
insert the old interactive pages in markdown by using \htmlonly and \endhtmlonly command.
delete the useless interactive page
rename js_interactive_tutorials to js_assets to put some images needed in
* fix the depends of the target doxygen
add opencv.js to depends and delete the useless target of copy_js_assets
* change filename helper.js to helpers.js
* disable button or trankbar before opencv.js is ready
* Expose CV_64F
Fix#65
* improve cv.imshow to display different types as native imshow
* add utils.js to reuse functions and update tutorials
* Make doxygen depend on bin/opencv.js
* Fix memory issue of matFromArray
Fix#37
* Merge pull request from ganwenyao/tutorial_18
* Add notes for ganwenyao/tutorial_18
* Modifying for ganwenyao/tutorial_18
* Change Mat constructor with data to 5 parameters
* Mat supports constructor with Scalar
Fix#60
* update cv.imread cause the memory issue of matFromArray has been fixed
* fix canvas name and default input image
* Expose cv::Moments
Fix#85
* Add -Wno-missing-prototypes for emscripten build
* fix canvas name
* add tutorial of video input and output
* Expose enums as emscripten consts
Fix#72
* update the tutorial to use Mat constructor with Scalar and change lena.jpg
* Exclude cv::Mat for vecFromJSArray
Fix#82
* Add unit tests for cv.moments
* Fix the unit tests.
* add checkbox and stop button
* add adapter.js to make sure compatibility fo video tutorials
* Support default parameters with function overloading
* modify enums to constants
* Use https URL for MathJax.js
Fix#109
* Comment out the debug print in embindgen.py
* Expose RotatedRect
Fix#96
* replace enum with constants and improve onload function
* delete some useless paras cause #105 fixed this
* Modify const name
* Modify Contour Properties
* tutorials for imgprc2 and objdec
* Expose more functions for img proc tutorials
Fix#76
* Expose polylines for video analysis tutorial
Fix#121
* Expose constants for default parameters of img proc tutorials
Fix#122
* Fix wrong parameter types of Mat.copyTo
Fix#87
* Support default parameters of mat.convertTo
Fix#123
* Support default parameters for external constructors
Fix#131
* Revert "Expose polylines for video analysis tutorial"
This reverts commit 3ce7615652e510d30e3c0014706ac38c98883189.
Fix#121
* Support cv.minMaxLoc
Fix#127
* Expose cv.minEnclosingCircle
Fix#126
* Add video analysis tutorials
add three video tutorials, Meanshift and Camshift, Optical Flow Background Subtraction
add cup.mp4 and box.mp4 for demo in tutorials
* improve image processing tutorials
* repalce console.warn with throw to throw exception
* add try-catch to throw exception in code demo
* Change mat.size() return value to JS Array object
Fix#140
* add a note about different channels order between canvas and native opencv
* add a note about how to capture video from video files
* Binding cv.Scalar to JS array
Fix#147
* Add JS cv.Scalar object into helpers.js
* Update Install OpenCV-JavaScript tutorial page
Fix#44
* Update the OpenCV-JavaScript introduction page
Fix#44
* add cv.VideoCapture and read() function
* set the size of the hidden canvas same as the video
* Add Using OpenCV-JavaScript tutorial page
Fix#44
* fix some bad code style
* Update tutorials after 8/2 sync meeting
Changes include:
- Use OpenCV.js name instead of OpenCV-JavaScript
- Put using OpenCV.js ahead of build OpenCV.js
- Refine usage and introduction page
- Muted the video in tutorials
* Fix a typo in introduction page
* use cv.VideoCapture and its read() function to read video
* replace OpenCV-JavaScript with OpenCV.js
* Use onload of async script in js_usage tutorial
* add more info about mat.data
* Change Size to value_object
* Integrate Moh and Sajjad's editing into introduction page
* Change Point to value_object
* Change Rect to value_object with helper object
* Add helper objects for Point and Size
* Change RotatedRect to value_object with helpers
* Change MinMaxLoc and Circle to value_object
* Change TermCriteria to value_object
* Fix core_bindings.cpp for MinMaxLoc and Circle
* Remove unused types
* Change meanShift and CamShift to return Rect
* Change methods of RotatedRect to static
* Change mat.data from methods to property
Fix#75 and #77
* support img id and element in cv.imread
* Change mat.size to property and add mat.step
Fix#163
* Add matFromArray and matFromImageData as JS helpers
Fix#79, #78
* Lower camel case for Mat element getters
Fix#81
* Mat.getRoiRect and tests
Fix#86
* Support type for Mat.ptr
Fix#83
* Name changing of Mat element getters
'getUcharAt` -> 'ucharAt'
* fix code style and args names
* Fix helpers.js due to cv.Mat API update
* Fix opencv.js usage tutorial
* Fix a typo of js_setup
* Change Moments to value_object
* Add Range as value_object
Fix#171
* Support Mat.diag and Mat.isContinous
Fix#84 and #89
* Support Mat.setTo
Fix#88
* Apply edits to js_intro
* Apply edits to js_usage
* Apply edits to js_setup
* update tutorials to apply data type change
* Modify tutorials
* add core tutorials
* delete MatVector elements and delete useless set operation
* add tutorials_objdec_camera
* Add instructions for WebAssembly
* apply tech writer's feedbacks into tutorials
* Organize white list by modules
* Change size to method and bind to MatExpr.size()
Fix#177
* improve tutorials
* Modify core tutorials
* add params list and explanations for OpenCV.js functions
* remove face_profile from Face Detection in Video Capture
* Add demos link
* Change Gui to GUI
* Update js_intro based on Moh and Sajjad's edits
* Fixup for 3.3.0 rebase
* Update js_intro per Moh's suggestion
* Update contributors list per Moh's idea
* add adapter.js in video_display tutorial
* Change Mat.getRoiRect to Mat.roi
Fix#194
* Remove unnecessary files for test
Fix#192
* Licenses updated to UC BSD 3-Clause
* Apply OpenCV coding style for C++ files
* Add OpenCV license for python and js files
* Fix coding style issue in helpers.js
* Remove unused test_commons.js
* Fix coding style of test_imgproc.js
* Fix coding style of test_mat.js
* Fix space before semicolon
* Fix coding style of test_objdetect.js
* Fix coding style of tests.js
* Fix coding style of test_utils.js
* Fix coding style of test_video.js
* Fix failures of node.js tests
* Add eslint rule config and fix eslint errors
* Add eslint config for js/src and fix eslint errors
* Clean up the opencv.js dependencies
Fix#186
* Fix build issue for python generator
* Fix doxygen buildbot failure
* delete trailing whitespace, blank line at EOF and replace tab with space
* Fix tutorial_js_root reference issue for non opencv.js build
* replace the file with small size
* Initial commit of build_js.py
* Move the js build configurations to build script
* Add wasm build support
* Update OpenCV.js build tutorial by using script
* Fix global var issue in tests
* Add a README.md for build_js.py
* Copy the haar cascade files from data dir for tutorials
* Not use memory init file
* Disable debug print for modules/js/CMakeLists.txt
* Check files when build done
* Fix image name in js_gradients tutorial
* Fix image load issue in js_trackbar tutorial
* Find the opencv source directory via relative path by default
* Make the cmake args based on build_doc option
* Fix a typo in js_setup.markdown
* Fix make failure issue on config generated by build_js.py
* Eliminate js branch of hdr_parser.py
* Extract examples from js_basic_ops tutorial
* Fix coding style of utils.js
* Improve examples error handling
Handle:
1. opencv.js loading errors
2. script errors (Error)
3. cv::Exception
Fix#217
* Add enable_exception option into build_js.py
* Support print exception for exception catching disabled build
* Extract example from js_usage tutorial
* Avoid copying .eslintrc.json when building doc
Fix#223
* Revert to use onload as opencv.js ready event
* Use 4 spaces indention for js examples
* embed html in tutorials with iframe tag
* Revert to use onload as opencv.js ready event
* Extract examples from js_video_display tutorial
* Implement Utils object
* modify core imgprc and face_detection tutorials
* Fix examples of js_gui tutorials
* Fix coding style of utils.js
* Modify tutorials
* Extract example from js_face_detection_camera tutorial
* Disable new-cap check in eslint
* Extract examples from js_meanshift tutorial
* Extract examples from video tutorials
* Remove new-cap declaration and update grammer in comments
* Change textarea width to 100 to align with eslint config
* Fix printError issue when opencv.js loading fails
* Remove BUILD_opencv_js dependency for doc build
Fix#213
* Expose cv::getBuildInformation
* Dump opencv build info when opencv.js loaded for live examples
* Make the button to stand out in js live examples
Fix#235
* Style for disabled button
* Add js_imgproc_camera.html example
* Fix coding style of imgproc_camera example
* Add js_imgproc_camera tutorial
* Remove link to opencv.js demos
* doc: copy opencv.js on build, use absolute paths for assets
* doc: reuse existed file box.mp4
Remove unnecessary Non-ASCII characters from source code (#9075)
* Remove unnecessary Non-ASCII characters from source code
Remove unnecessary Non-ASCII characters and replace them with ASCII
characters
* Remove dashes in the @param statement
Remove dashes and place single space in the @param statement to keep
coding style
* misc: more fixes for non-ASCII symbols
* misc: fix non-ASCII symbol in CMake file
general:
- all iterative tests have been replaced with parameterized tests
- old-style try..catch tests have been modified to use EXPECT_/ASSERT_ gtest macros
- added temporary files cleanup
- modified MatComparator error message formatting
imgcodecs:
- test_grfmt.cpp split to test_jpg.cpp, test_png.cpp, test_tiff.cpp, etc.
videoio:
- added public HAVE_VIDEO_INPUT, HAVE_VIDEO_OUTPUT definitions to cvconfig.h
- built-in MotionJPEG codec could not be tested on some platforms (read_write test was disabled if ffmpeg is off, encoding/decoding was handled by ffmpeg otherwise).
- image-related tests moved to imgcodecs (Videoio_Image)
- several property get/set tests have been combined into one
- added MotionJPEG test video to opencv_extra
The method does cvCheckPixelBackgroundNP (which reads bgmodel)
before it is ever updated (in cvUpdatePixelBackgroundNP). This
initialization is thus needed to avoid reads of unitialized values.
OpenVX optical flow PyrLK wrappers added (#7774)
* wrappers for vx_pyramid added
* initial version of Optical Flow PyrLK wrappers added
* array downloading code simplified
* disabled due to bad accuracy; fixed bugs, e.g. vendor-specific ones
* rewritten for new macro use
[GSOC] New camera model for stitching pipeline
* implement estimateAffine2D
estimates affine transformation using robust RANSAC method.
* uses RANSAC framework in calib3d
* includes accuracy test
* uses SVD decomposition for solving 3 point equation
* implement estimateAffinePartial2D
estimates limited affine transformation
* includes accuracy test
* stitching: add affine matcher
initial version of matcher that estimates affine transformation
* stitching: added affine transform estimator
initial version of estimator that simply chain transformations in homogeneous coordinates
* calib3d: rename estimateAffine3D test
test Calib3d_EstimateAffineTransform rename to Calib3d_EstimateAffine3D. This is more descriptive and prevents confusion with estimateAffine2D tests.
* added perf test for estimateAffine functions
tests both estimateAffine2D and estimateAffinePartial2D
* calib3d: compare error in square in estimateAffine2D
* incorporates fix from #6768
* rerun affine estimation on inliers
* stitching: new API for parallel feature finding
due to ABI breakage new functionality is added to `FeaturesFinder2`, `SurfFeaturesFinder2` and `OrbFeaturesFinder2`
* stitching: add tests for parallel feature find API
* perf test (about linear speed up)
* accuracy test compares results with serial version
* stitching: use dynamic_cast to overcome ABI issues
adding parallel API to FeaturesFinder breaks ABI. This commit uses dynamic_cast and hardcodes thread-safe finders to avoid breaking ABI.
This should be replaced by proper method similar to FeaturesMatcher on next ABI break.
* use estimateAffinePartial2D in AffineBestOf2NearestMatcher
* add constructor to AffineBestOf2NearestMatcher
* allows to choose between full affine transform and partial affine transform. Other params are the as for BestOf2NearestMatcher
* added protected field
* samples: stitching_detailed support affine estimator and matcher
* added new flags to choose matcher and estimator
* stitching: rework affine matcher
represent transformation in homogeneous coordinates
affine matcher: remove duplicite code
rework flow to get rid of duplicite code
affine matcher: do not center points to (0, 0)
it is not needed for affine model. it should not affect estimation in any way.
affine matcher: remove unneeded cv namespacing
* stitching: add stub bundle adjuster
* adds stub bundle adjuster that does nothing
* can be used in place of standard bundle adjusters to omit bundle adjusting step
* samples: stitching detailed, support no budle adjust
* uses new NoBundleAdjuster
* added affine warper
* uses R to get whole affine transformation and propagates rotation and translation to plane warper
* add affine warper factory class
* affine warper: compensate transformation
* samples: stitching_detailed add support for affine warper
* add Stitcher::create method
this method follows similar constructor methods and returns smart pointer. This allows constructing Stitcher according to OpenCV guidelines.
* supports multiple stitcher configurations (PANORAMA and SCANS) for convenient setup
* returns cv::Ptr
* stitcher: dynamicaly determine correct estimator
we need to use affine estimator for affine matcher
* preserves ABI (but add hints for ABI 4)
* uses dynamic_cast hack to inject correct estimator
* sample stitching: add support for multiple modes
shows how to use different configurations of stitcher easily (panorama stitching and scans affine model)
* stitcher: find features in parallel
use new FeatureFinder API to find features in parallel. Parallelized using TBB.
* stitching: disable parallel feature finding for OCL
it does not bring much speedup to run features finder in parallel when OpenCL is enabled, because finder needs to wait for OCL device.
Also, currently ORB is not thread-safe when OCL is enabled.
* stitching: move matcher tests
move matchers tests perf_stich.cpp -> perf_matchers.cpp
* stitching: add affine stiching integration test
test basic affine stitching (SCANS mode of stitcher) with images that have only translation between them
* enable surf for stitching tests
stitching.b12 test was failing with surf
investigated the issue, surf is producing good result. Transformation is only slightly different from ORB, so that resulting pano does not exactly match ORB's result. That caused sanity check to fail.
* added size checks similar to other tests
* sanity check will be applied only for ORB
* stitching: fix wrong estimator choice
if case was exactly wrong, estimators were chosen wrong
added logging for estimated transformation
* enable surf for matchers stitching tests
* enable SURF
* rework sanity checking. Check estimated transform instead of matches. Est. transform should be more stable and comparable between SURF and ORB.
* remove regression checking for VectorFeatures tests. It has a lot if data andtest is the same as previous except it test different vector size for performance, so sanity checking does not add any value here. Added basic sanity asserts instead.
* stitching tests: allow relative error for transform
* allows .01 relative error for estimated homography sanity check in stitching matchers tests
* fix VS warning
stitching tests: increase relative error
increase relative error to make it pass on all platforms (results are still good).
stitching test: allow bigger relative error
transformation can differ in small values (with small absolute difference, but large relative difference). transformation output still looks usable for all platforms. This difference affects only mac and windows, linux passes fine with small difference.
* stitching: add tests for affine matcher
uses s1, s2 images. added also new sanity data.
* stitching tests: use different data for matchers tests
this data should yeild more stable transformation (it has much more matches, especially for surf). Sanity data regenerated.
* stitching test: rework tests for matchers
* separated rotation and translations as they are different by scale.
* use appropriate absolute error for them separately. (relative error does not work for values near zero.)
* stitching: fix affine warper compensation
calculation of rotation and translation extracted for plane warper was wrong
* stitching test: enable surf for opencl integration tests
* enable SURF with correct guard (HAVE_OPENCV_XFEATURES2D)
* add OPENCL guard and correct namespace as usual for opencl tests
* stitching: add ocl accuracy test for affine warper
test consistent results with ocl on and off
* stitching: add affine warper ocl perf test
add affine warper to existing warper perf tests. Added new sanity data.
* stitching: do not overwrite inliers in affine matcher
* estimation is run second time on inliers only, inliers produces in second run will not be therefore correct for all matches
* calib3d: add Levenberg–Marquardt refining to estimateAffine2D* functions
this adds affine Levenberg–Marquardt refining to estimateAffine2D functions similar to what is done in findHomography.
implements Levenberg–Marquardt refinig for both full affine and partial affine transformations.
* stitching: remove reestimation step in affine matcher
reestimation step is not needed. estimateAffine2D* functions are running their own reestimation on inliers using the Levenberg-Marquardt algorithm, which is better than simply rerunning RANSAC on inliers.
* implement partial affine bundle adjuster
bundle adjuster that expect affine transform with 4DOF. Refines parameters for all cameras together.
stitching: fix bug in BundleAdjusterAffinePartial
* use the invers properly
* use static buffer for invers to speed it up
* samples: add affine bundle adjuster option to stitching_detailed
* add support for using affine bundle adjuster with 4DOF
* improve logging of initial intristics
* sttiching: add affine bundle adjuster test
* fix build warnings
* stitching: increase limit on sanity check
prevents spurious test failures on mac. values are still pretty fine.
* stitching: set affine bundle adjuster for SCANS mode
* fix bug with AffineBestOf2NearestMatcher (we want to select affine partial mode)
* select right bundle adjuster
* stitching: increase error bound for matcher tests
* this prevents failure on mac. tranformation is still ok.
* stitching: implement affine bundle adjuster
* implements affine bundle adjuster that is using full affine transform
* existing test case modified to test both affinePartial an full affine bundle adjuster
* add stitching tutorial
* show basic usage of stitching api (Stitcher class)
* stitching: add more integration test for affine stitching
* added new datasets to existing testcase
* removed unused include
* calib3d: move `haveCollinearPoints` to common header
* added comment to make that this also checks too close points
* calib3d: redone checkSubset for estimateAffine* callback
* use common function to check collinearity
* this also ensures that point will not be too close to each other
* calib3d: change estimateAffine* functions API
* more similar to `findHomography`, `findFundamentalMat`, `findEssentialMat` and similar
* follows standard recommended semantic INPUTS, OUTPUTS, FLAGS
* allows to disable refining
* supported LMEDS robust method (tests yet to come) along with RANSAC
* extended docs with some tips
* calib3d: rewrite estimateAffine2D test
* rewrite in googletest style
* parametrize to test both robust methods (RANSAC and LMEDS)
* get rid of boilerplate
* calib3d: rework estimateAffinePartial2D test
* rework in googletest style
* add testing for LMEDS
* calib3d: rework estimateAffine*2D perf test
* test for LMEDS speed
* test with/without Levenberg-Marquart
* remove sanity checking (this is covered by accuracy tests)
* calib3d: improve estimateAffine*2D tests
* test transformations in loop
* improves test by testing more potential transformations
* calib3d: rewrite kernels for estimateAffine*2D functions
* use analytical solution instead of SVD
* this version is faster especially for smaller amount of points
* calib3d: tune up perf of estimateAffine*2D functions
* avoid copying inliers
* avoid converting input points if not necessary
* check only `from` point for collinearity, as `to` does not affect stability of transform
* tutorials: add commands examples to stitching tutorials
* add some examples how to run stitcher sample code
* mention stitching_detailed.cpp
* calib3d: change computeError for estimateAffine*2D
* do error computing in floats instead of doubles
this have required precision + we were storing the result in float anyway. This make code faster and allows auto-vectorization by smart compilers.
* documentation: mention estimateAffine*2D function
* refer to new functions on appropriate places
* prefer estimateAffine*2D over estimateRigidTransform
* stitching: add camera models documentations
* mention camera models in module documentation to give user a better overview and reduce confusion