1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
22 // * Redistribution's in binary form must reproduce the above copyright notice,
23 // this list of conditions and the following disclaimer in the documentation
24 // and/or other materials provided with the distribution.
26 // * The name of the copyright holders may not be used to endorse or promote products
27 // derived from this software without specific prior written permission.
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
42 /*M///////////////////////////////////////////////////////////////////////////////////////
43 // Author: Sajjad Taheri, University of California, Irvine. sajjadt[at]uci[dot]edu
46 // Copyright (c) 2015 The Regents of the University of California (Regents)
48 // Redistribution and use in source and binary forms, with or without
49 // modification, are permitted provided that the following conditions are met:
50 // 1. Redistributions of source code must retain the above copyright
51 // notice, this list of conditions and the following disclaimer.
52 // 2. Redistributions in binary form must reproduce the above copyright
53 // notice, this list of conditions and the following disclaimer in the
54 // documentation and/or other materials provided with the distribution.
55 // 3. Neither the name of the University nor the
56 // names of its contributors may be used to endorse or promote products
57 // derived from this software without specific prior written permission.
59 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ''AS IS'' AND ANY
60 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
61 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
62 // DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY
63 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
64 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
65 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
66 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
67 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
68 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
71 #include <emscripten/bind.h>
74 #include "../../../modules/core/src/parallel_impl.hpp"
76 #ifdef TEST_WASM_INTRIN
77 #include "../../../modules/core/include/opencv2/core/hal/intrin.hpp"
78 #include "../../../modules/core/include/opencv2/core/utils/trace.hpp"
79 #include "../../../modules/ts/include/opencv2/ts/ts_gtest.h"
82 #include "../../../modules/core/test/test_intrin_utils.hpp"
87 using namespace emscripten;
90 #ifdef HAVE_OPENCV_DNN
91 using namespace cv::dnn;
94 #ifdef HAVE_OPENCV_ARUCO
95 using namespace aruco;
98 namespace binding_utils
100 template<typename classT, typename enumT>
101 static inline typename std::underlying_type<enumT>::type classT::* underlying_ptr(enumT classT::* enum_ptr)
103 return reinterpret_cast<typename std::underlying_type<enumT>::type classT::*>(enum_ptr);
107 emscripten::val matData(const cv::Mat& mat)
109 return emscripten::val(emscripten::memory_view<T>((mat.total()*mat.elemSize())/sizeof(T),
114 emscripten::val matPtr(const cv::Mat& mat, int i)
116 return emscripten::val(emscripten::memory_view<T>(mat.step1(0), mat.ptr<T>(i)));
120 emscripten::val matPtr(const cv::Mat& mat, int i, int j)
122 return emscripten::val(emscripten::memory_view<T>(mat.step1(1), mat.ptr<T>(i,j)));
125 cv::Mat* createMat(int rows, int cols, int type, intptr_t data, size_t step)
127 return new cv::Mat(rows, cols, type, reinterpret_cast<void*>(data), step);
130 static emscripten::val getMatSize(const cv::Mat& mat)
132 emscripten::val size = emscripten::val::array();
133 for (int i = 0; i < mat.dims; i++) {
134 size.call<void>("push", mat.size[i]);
139 static emscripten::val getMatStep(const cv::Mat& mat)
141 emscripten::val step = emscripten::val::array();
142 for (int i = 0; i < mat.dims; i++) {
143 step.call<void>("push", mat.step[i]);
148 static Mat matEye(int rows, int cols, int type)
150 return Mat(cv::Mat::eye(rows, cols, type));
153 static Mat matEye(Size size, int type)
155 return Mat(cv::Mat::eye(size, type));
158 void convertTo(const Mat& obj, Mat& m, int rtype, double alpha, double beta)
160 obj.convertTo(m, rtype, alpha, beta);
163 void convertTo(const Mat& obj, Mat& m, int rtype)
165 obj.convertTo(m, rtype);
168 void convertTo(const Mat& obj, Mat& m, int rtype, double alpha)
170 obj.convertTo(m, rtype, alpha);
173 Size matSize(const cv::Mat& mat)
178 cv::Mat matZeros(int arg0, int arg1, int arg2)
180 return cv::Mat::zeros(arg0, arg1, arg2);
183 cv::Mat matZeros(cv::Size arg0, int arg1)
185 return cv::Mat::zeros(arg0,arg1);
188 cv::Mat matOnes(int arg0, int arg1, int arg2)
190 return cv::Mat::ones(arg0, arg1, arg2);
193 cv::Mat matOnes(cv::Size arg0, int arg1)
195 return cv::Mat::ones(arg0, arg1);
198 double matDot(const cv::Mat& obj, const Mat& mat)
203 Mat matMul(const cv::Mat& obj, const Mat& mat, double scale)
205 return Mat(obj.mul(mat, scale));
208 Mat matT(const cv::Mat& obj)
213 Mat matInv(const cv::Mat& obj, int type)
215 return Mat(obj.inv(type));
218 void matCopyTo(const cv::Mat& obj, cv::Mat& mat)
220 return obj.copyTo(mat);
223 void matCopyTo(const cv::Mat& obj, cv::Mat& mat, const cv::Mat& mask)
225 return obj.copyTo(mat, mask);
228 Mat matDiag(const cv::Mat& obj, int d)
233 Mat matDiag(const cv::Mat& obj)
238 void matSetTo(cv::Mat& obj, const cv::Scalar& s)
243 void matSetTo(cv::Mat& obj, const cv::Scalar& s, const cv::Mat& mask)
248 emscripten::val rotatedRectPoints(const cv::RotatedRect& obj)
250 cv::Point2f points[4];
252 emscripten::val pointsArray = emscripten::val::array();
253 for (int i = 0; i < 4; i++) {
254 pointsArray.call<void>("push", points[i]);
259 Rect rotatedRectBoundingRect(const cv::RotatedRect& obj)
261 return obj.boundingRect();
264 Rect2f rotatedRectBoundingRect2f(const cv::RotatedRect& obj)
266 return obj.boundingRect2f();
269 int cvMatDepth(int flags)
271 return CV_MAT_DEPTH(flags);
283 MinMaxLoc minMaxLoc(const cv::Mat& src, const cv::Mat& mask)
286 cv::minMaxLoc(src, &result.minVal, &result.maxVal, &result.minLoc, &result.maxLoc, mask);
290 MinMaxLoc minMaxLoc_1(const cv::Mat& src)
293 cv::minMaxLoc(src, &result.minVal, &result.maxVal, &result.minLoc, &result.maxLoc);
304 #ifdef HAVE_OPENCV_IMGPROC
305 Circle minEnclosingCircle(const cv::Mat& points)
308 cv::minEnclosingCircle(points, circle.center, circle.radius);
312 int floodFill_withRect_helper(cv::Mat& arg1, cv::Mat& arg2, Point arg3, Scalar arg4, emscripten::val arg5, Scalar arg6 = Scalar(), Scalar arg7 = Scalar(), int arg8 = 4)
316 int rc = cv::floodFill(arg1, arg2, arg3, arg4, &rect, arg6, arg7, arg8);
318 arg5.set("x", emscripten::val(rect.x));
319 arg5.set("y", emscripten::val(rect.y));
320 arg5.set("width", emscripten::val(rect.width));
321 arg5.set("height", emscripten::val(rect.height));
326 int floodFill_wrapper(cv::Mat& arg1, cv::Mat& arg2, Point arg3, Scalar arg4, emscripten::val arg5, Scalar arg6, Scalar arg7, int arg8) {
327 return floodFill_withRect_helper(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
330 int floodFill_wrapper_1(cv::Mat& arg1, cv::Mat& arg2, Point arg3, Scalar arg4, emscripten::val arg5, Scalar arg6, Scalar arg7) {
331 return floodFill_withRect_helper(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
334 int floodFill_wrapper_2(cv::Mat& arg1, cv::Mat& arg2, Point arg3, Scalar arg4, emscripten::val arg5, Scalar arg6) {
335 return floodFill_withRect_helper(arg1, arg2, arg3, arg4, arg5, arg6);
338 int floodFill_wrapper_3(cv::Mat& arg1, cv::Mat& arg2, Point arg3, Scalar arg4, emscripten::val arg5) {
339 return floodFill_withRect_helper(arg1, arg2, arg3, arg4, arg5);
342 int floodFill_wrapper_4(cv::Mat& arg1, cv::Mat& arg2, Point arg3, Scalar arg4) {
343 return cv::floodFill(arg1, arg2, arg3, arg4);
347 #ifdef HAVE_OPENCV_VIDEO
348 emscripten::val CamShiftWrapper(const cv::Mat& arg1, Rect& arg2, TermCriteria arg3)
350 RotatedRect rotatedRect = cv::CamShift(arg1, arg2, arg3);
351 emscripten::val result = emscripten::val::array();
352 result.call<void>("push", rotatedRect);
353 result.call<void>("push", arg2);
357 emscripten::val meanShiftWrapper(const cv::Mat& arg1, Rect& arg2, TermCriteria arg3)
359 int n = cv::meanShift(arg1, arg2, arg3);
360 emscripten::val result = emscripten::val::array();
361 result.call<void>("push", n);
362 result.call<void>("push", arg2);
365 #endif // HAVE_OPENCV_VIDEO
367 std::string getExceptionMsg(const cv::Exception& e) {
371 void setExceptionMsg(cv::Exception& e, std::string msg) {
376 cv::Exception exceptionFromPtr(intptr_t ptr) {
377 return *reinterpret_cast<cv::Exception*>(ptr);
380 std::string getBuildInformation() {
381 return cv::getBuildInformation();
384 #ifdef TEST_WASM_INTRIN
385 void test_hal_intrin_uint8() {
386 cv::hal::test_hal_intrin_uint8();
388 void test_hal_intrin_int8() {
389 cv::hal::test_hal_intrin_int8();
391 void test_hal_intrin_uint16() {
392 cv::hal::test_hal_intrin_uint16();
394 void test_hal_intrin_int16() {
395 cv::hal::test_hal_intrin_int16();
397 void test_hal_intrin_uint32() {
398 cv::hal::test_hal_intrin_uint32();
400 void test_hal_intrin_int32() {
401 cv::hal::test_hal_intrin_int32();
403 void test_hal_intrin_uint64() {
404 cv::hal::test_hal_intrin_uint64();
406 void test_hal_intrin_int64() {
407 cv::hal::test_hal_intrin_int64();
409 void test_hal_intrin_float32() {
410 cv::hal::test_hal_intrin_float32();
412 void test_hal_intrin_float64() {
413 cv::hal::test_hal_intrin_float64();
415 void test_hal_intrin_all() {
416 cv::hal::test_hal_intrin_uint8();
417 cv::hal::test_hal_intrin_int8();
418 cv::hal::test_hal_intrin_uint16();
419 cv::hal::test_hal_intrin_int16();
420 cv::hal::test_hal_intrin_uint32();
421 cv::hal::test_hal_intrin_int32();
422 cv::hal::test_hal_intrin_uint64();
423 cv::hal::test_hal_intrin_int64();
424 cv::hal::test_hal_intrin_float32();
425 cv::hal::test_hal_intrin_float64();
430 EMSCRIPTEN_BINDINGS(binding_utils)
432 register_vector<int>("IntVector");
433 register_vector<float>("FloatVector");
434 register_vector<double>("DoubleVector");
435 register_vector<cv::Point>("PointVector");
436 register_vector<cv::Mat>("MatVector");
437 register_vector<cv::Rect>("RectVector");
438 register_vector<cv::KeyPoint>("KeyPointVector");
439 register_vector<cv::DMatch>("DMatchVector");
440 register_vector<std::vector<cv::DMatch>>("DMatchVectorVector");
443 emscripten::class_<cv::Mat>("Mat")
445 .constructor<const Mat&>()
446 .constructor<Size, int>()
447 .constructor<int, int, int>()
448 .constructor<int, int, int, const Scalar&>()
449 .constructor(&binding_utils::createMat, allow_raw_pointers())
451 .class_function("eye", select_overload<Mat(Size, int)>(&binding_utils::matEye))
452 .class_function("eye", select_overload<Mat(int, int, int)>(&binding_utils::matEye))
453 .class_function("ones", select_overload<Mat(Size, int)>(&binding_utils::matOnes))
454 .class_function("ones", select_overload<Mat(int, int, int)>(&binding_utils::matOnes))
455 .class_function("zeros", select_overload<Mat(Size, int)>(&binding_utils::matZeros))
456 .class_function("zeros", select_overload<Mat(int, int, int)>(&binding_utils::matZeros))
458 .property("rows", &cv::Mat::rows)
459 .property("cols", &cv::Mat::cols)
460 .property("matSize", &binding_utils::getMatSize)
461 .property("step", &binding_utils::getMatStep)
462 .property("data", &binding_utils::matData<unsigned char>)
463 .property("data8S", &binding_utils::matData<char>)
464 .property("data16U", &binding_utils::matData<unsigned short>)
465 .property("data16S", &binding_utils::matData<short>)
466 .property("data32S", &binding_utils::matData<int>)
467 .property("data32F", &binding_utils::matData<float>)
468 .property("data64F", &binding_utils::matData<double>)
470 .function("elemSize", select_overload<size_t()const>(&cv::Mat::elemSize))
471 .function("elemSize1", select_overload<size_t()const>(&cv::Mat::elemSize1))
472 .function("channels", select_overload<int()const>(&cv::Mat::channels))
473 .function("convertTo", select_overload<void(const Mat&, Mat&, int, double, double)>(&binding_utils::convertTo))
474 .function("convertTo", select_overload<void(const Mat&, Mat&, int)>(&binding_utils::convertTo))
475 .function("convertTo", select_overload<void(const Mat&, Mat&, int, double)>(&binding_utils::convertTo))
476 .function("total", select_overload<size_t()const>(&cv::Mat::total))
477 .function("row", select_overload<Mat(int)const>(&cv::Mat::row))
478 .function("create", select_overload<void(int, int, int)>(&cv::Mat::create))
479 .function("create", select_overload<void(Size, int)>(&cv::Mat::create))
480 .function("rowRange", select_overload<Mat(int, int)const>(&cv::Mat::rowRange))
481 .function("rowRange", select_overload<Mat(const Range&)const>(&cv::Mat::rowRange))
482 .function("copyTo", select_overload<void(const Mat&, Mat&)>(&binding_utils::matCopyTo))
483 .function("copyTo", select_overload<void(const Mat&, Mat&, const Mat&)>(&binding_utils::matCopyTo))
484 .function("type", select_overload<int()const>(&cv::Mat::type))
485 .function("empty", select_overload<bool()const>(&cv::Mat::empty))
486 .function("colRange", select_overload<Mat(int, int)const>(&cv::Mat::colRange))
487 .function("colRange", select_overload<Mat(const Range&)const>(&cv::Mat::colRange))
488 .function("step1", select_overload<size_t(int)const>(&cv::Mat::step1))
489 .function("clone", select_overload<Mat()const>(&cv::Mat::clone))
490 .function("depth", select_overload<int()const>(&cv::Mat::depth))
491 .function("col", select_overload<Mat(int)const>(&cv::Mat::col))
492 .function("dot", select_overload<double(const Mat&, const Mat&)>(&binding_utils::matDot))
493 .function("mul", select_overload<Mat(const Mat&, const Mat&, double)>(&binding_utils::matMul))
494 .function("inv", select_overload<Mat(const Mat&, int)>(&binding_utils::matInv))
495 .function("t", select_overload<Mat(const Mat&)>(&binding_utils::matT))
496 .function("roi", select_overload<Mat(const Rect&)const>(&cv::Mat::operator()))
497 .function("diag", select_overload<Mat(const Mat&, int)>(&binding_utils::matDiag))
498 .function("diag", select_overload<Mat(const Mat&)>(&binding_utils::matDiag))
499 .function("isContinuous", select_overload<bool()const>(&cv::Mat::isContinuous))
500 .function("setTo", select_overload<void(Mat&, const Scalar&)>(&binding_utils::matSetTo))
501 .function("setTo", select_overload<void(Mat&, const Scalar&, const Mat&)>(&binding_utils::matSetTo))
502 .function("size", select_overload<Size(const Mat&)>(&binding_utils::matSize))
504 .function("ptr", select_overload<val(const Mat&, int)>(&binding_utils::matPtr<unsigned char>))
505 .function("ptr", select_overload<val(const Mat&, int, int)>(&binding_utils::matPtr<unsigned char>))
506 .function("ucharPtr", select_overload<val(const Mat&, int)>(&binding_utils::matPtr<unsigned char>))
507 .function("ucharPtr", select_overload<val(const Mat&, int, int)>(&binding_utils::matPtr<unsigned char>))
508 .function("charPtr", select_overload<val(const Mat&, int)>(&binding_utils::matPtr<char>))
509 .function("charPtr", select_overload<val(const Mat&, int, int)>(&binding_utils::matPtr<char>))
510 .function("shortPtr", select_overload<val(const Mat&, int)>(&binding_utils::matPtr<short>))
511 .function("shortPtr", select_overload<val(const Mat&, int, int)>(&binding_utils::matPtr<short>))
512 .function("ushortPtr", select_overload<val(const Mat&, int)>(&binding_utils::matPtr<unsigned short>))
513 .function("ushortPtr", select_overload<val(const Mat&, int, int)>(&binding_utils::matPtr<unsigned short>))
514 .function("intPtr", select_overload<val(const Mat&, int)>(&binding_utils::matPtr<int>))
515 .function("intPtr", select_overload<val(const Mat&, int, int)>(&binding_utils::matPtr<int>))
516 .function("floatPtr", select_overload<val(const Mat&, int)>(&binding_utils::matPtr<float>))
517 .function("floatPtr", select_overload<val(const Mat&, int, int)>(&binding_utils::matPtr<float>))
518 .function("doublePtr", select_overload<val(const Mat&, int)>(&binding_utils::matPtr<double>))
519 .function("doublePtr", select_overload<val(const Mat&, int, int)>(&binding_utils::matPtr<double>))
521 .function("charAt", select_overload<char&(int)>(&cv::Mat::at<char>))
522 .function("charAt", select_overload<char&(int, int)>(&cv::Mat::at<char>))
523 .function("charAt", select_overload<char&(int, int, int)>(&cv::Mat::at<char>))
524 .function("ucharAt", select_overload<unsigned char&(int)>(&cv::Mat::at<unsigned char>))
525 .function("ucharAt", select_overload<unsigned char&(int, int)>(&cv::Mat::at<unsigned char>))
526 .function("ucharAt", select_overload<unsigned char&(int, int, int)>(&cv::Mat::at<unsigned char>))
527 .function("shortAt", select_overload<short&(int)>(&cv::Mat::at<short>))
528 .function("shortAt", select_overload<short&(int, int)>(&cv::Mat::at<short>))
529 .function("shortAt", select_overload<short&(int, int, int)>(&cv::Mat::at<short>))
530 .function("ushortAt", select_overload<unsigned short&(int)>(&cv::Mat::at<unsigned short>))
531 .function("ushortAt", select_overload<unsigned short&(int, int)>(&cv::Mat::at<unsigned short>))
532 .function("ushortAt", select_overload<unsigned short&(int, int, int)>(&cv::Mat::at<unsigned short>))
533 .function("intAt", select_overload<int&(int)>(&cv::Mat::at<int>) )
534 .function("intAt", select_overload<int&(int, int)>(&cv::Mat::at<int>) )
535 .function("intAt", select_overload<int&(int, int, int)>(&cv::Mat::at<int>) )
536 .function("floatAt", select_overload<float&(int)>(&cv::Mat::at<float>))
537 .function("floatAt", select_overload<float&(int, int)>(&cv::Mat::at<float>))
538 .function("floatAt", select_overload<float&(int, int, int)>(&cv::Mat::at<float>))
539 .function("doubleAt", select_overload<double&(int, int, int)>(&cv::Mat::at<double>))
540 .function("doubleAt", select_overload<double&(int)>(&cv::Mat::at<double>))
541 .function("doubleAt", select_overload<double&(int, int)>(&cv::Mat::at<double>));
543 emscripten::value_object<cv::Range>("Range")
544 .field("start", &cv::Range::start)
545 .field("end", &cv::Range::end);
547 emscripten::value_object<cv::TermCriteria>("TermCriteria")
548 .field("type", &cv::TermCriteria::type)
549 .field("maxCount", &cv::TermCriteria::maxCount)
550 .field("epsilon", &cv::TermCriteria::epsilon);
552 #define EMSCRIPTEN_CV_SIZE(type) \
553 emscripten::value_object<type>("#type") \
554 .field("width", &type::width) \
555 .field("height", &type::height);
557 EMSCRIPTEN_CV_SIZE(Size)
558 EMSCRIPTEN_CV_SIZE(Size2f)
560 #define EMSCRIPTEN_CV_POINT(type) \
561 emscripten::value_object<type>("#type") \
562 .field("x", &type::x) \
563 .field("y", &type::y); \
565 EMSCRIPTEN_CV_POINT(Point)
566 EMSCRIPTEN_CV_POINT(Point2f)
568 #define EMSCRIPTEN_CV_RECT(type, name) \
569 emscripten::value_object<cv::Rect_<type>> (name) \
570 .field("x", &cv::Rect_<type>::x) \
571 .field("y", &cv::Rect_<type>::y) \
572 .field("width", &cv::Rect_<type>::width) \
573 .field("height", &cv::Rect_<type>::height);
575 EMSCRIPTEN_CV_RECT(int, "Rect")
576 EMSCRIPTEN_CV_RECT(float, "Rect2f")
578 emscripten::value_object<cv::RotatedRect>("RotatedRect")
579 .field("center", &cv::RotatedRect::center)
580 .field("size", &cv::RotatedRect::size)
581 .field("angle", &cv::RotatedRect::angle);
583 function("rotatedRectPoints", select_overload<emscripten::val(const cv::RotatedRect&)>(&binding_utils::rotatedRectPoints));
584 function("rotatedRectBoundingRect", select_overload<Rect(const cv::RotatedRect&)>(&binding_utils::rotatedRectBoundingRect));
585 function("rotatedRectBoundingRect2f", select_overload<Rect2f(const cv::RotatedRect&)>(&binding_utils::rotatedRectBoundingRect2f));
587 emscripten::value_object<cv::KeyPoint>("KeyPoint")
588 .field("angle", &cv::KeyPoint::angle)
589 .field("class_id", &cv::KeyPoint::class_id)
590 .field("octave", &cv::KeyPoint::octave)
591 .field("pt", &cv::KeyPoint::pt)
592 .field("response", &cv::KeyPoint::response)
593 .field("size", &cv::KeyPoint::size);
595 emscripten::value_object<cv::DMatch>("DMatch")
596 .field("queryIdx", &cv::DMatch::queryIdx)
597 .field("trainIdx", &cv::DMatch::trainIdx)
598 .field("imgIdx", &cv::DMatch::imgIdx)
599 .field("distance", &cv::DMatch::distance);
601 emscripten::value_array<cv::Scalar_<double>> ("Scalar")
602 .element(emscripten::index<0>())
603 .element(emscripten::index<1>())
604 .element(emscripten::index<2>())
605 .element(emscripten::index<3>());
607 emscripten::value_object<binding_utils::MinMaxLoc>("MinMaxLoc")
608 .field("minVal", &binding_utils::MinMaxLoc::minVal)
609 .field("maxVal", &binding_utils::MinMaxLoc::maxVal)
610 .field("minLoc", &binding_utils::MinMaxLoc::minLoc)
611 .field("maxLoc", &binding_utils::MinMaxLoc::maxLoc);
613 emscripten::value_object<binding_utils::Circle>("Circle")
614 .field("center", &binding_utils::Circle::center)
615 .field("radius", &binding_utils::Circle::radius);
617 emscripten::value_object<cv::Moments >("Moments")
618 .field("m00", &cv::Moments::m00)
619 .field("m10", &cv::Moments::m10)
620 .field("m01", &cv::Moments::m01)
621 .field("m20", &cv::Moments::m20)
622 .field("m11", &cv::Moments::m11)
623 .field("m02", &cv::Moments::m02)
624 .field("m30", &cv::Moments::m30)
625 .field("m21", &cv::Moments::m21)
626 .field("m12", &cv::Moments::m12)
627 .field("m03", &cv::Moments::m03)
628 .field("mu20", &cv::Moments::mu20)
629 .field("mu11", &cv::Moments::mu11)
630 .field("mu02", &cv::Moments::mu02)
631 .field("mu30", &cv::Moments::mu30)
632 .field("mu21", &cv::Moments::mu21)
633 .field("mu12", &cv::Moments::mu12)
634 .field("mu03", &cv::Moments::mu03)
635 .field("nu20", &cv::Moments::nu20)
636 .field("nu11", &cv::Moments::nu11)
637 .field("nu02", &cv::Moments::nu02)
638 .field("nu30", &cv::Moments::nu30)
639 .field("nu21", &cv::Moments::nu21)
640 .field("nu12", &cv::Moments::nu12)
641 .field("nu03", &cv::Moments::nu03);
643 emscripten::value_object<cv::Exception>("Exception")
644 .field("code", &cv::Exception::code)
645 .field("msg", &binding_utils::getExceptionMsg, &binding_utils::setExceptionMsg);
647 function("exceptionFromPtr", &binding_utils::exceptionFromPtr, allow_raw_pointers());
649 #ifdef HAVE_OPENCV_IMGPROC
650 function("minEnclosingCircle", select_overload<binding_utils::Circle(const cv::Mat&)>(&binding_utils::minEnclosingCircle));
652 function("floodFill", select_overload<int(cv::Mat&, cv::Mat&, Point, Scalar, emscripten::val, Scalar, Scalar, int)>(&binding_utils::floodFill_wrapper));
654 function("floodFill", select_overload<int(cv::Mat&, cv::Mat&, Point, Scalar, emscripten::val, Scalar, Scalar)>(&binding_utils::floodFill_wrapper_1));
656 function("floodFill", select_overload<int(cv::Mat&, cv::Mat&, Point, Scalar, emscripten::val, Scalar)>(&binding_utils::floodFill_wrapper_2));
658 function("floodFill", select_overload<int(cv::Mat&, cv::Mat&, Point, Scalar, emscripten::val)>(&binding_utils::floodFill_wrapper_3));
660 function("floodFill", select_overload<int(cv::Mat&, cv::Mat&, Point, Scalar)>(&binding_utils::floodFill_wrapper_4));
663 function("minMaxLoc", select_overload<binding_utils::MinMaxLoc(const cv::Mat&, const cv::Mat&)>(&binding_utils::minMaxLoc));
665 function("minMaxLoc", select_overload<binding_utils::MinMaxLoc(const cv::Mat&)>(&binding_utils::minMaxLoc_1));
667 #ifdef HAVE_OPENCV_IMGPROC
668 function("morphologyDefaultBorderValue", &cv::morphologyDefaultBorderValue);
671 function("CV_MAT_DEPTH", &binding_utils::cvMatDepth);
673 #ifdef HAVE_OPENCV_VIDEO
674 function("CamShift", select_overload<emscripten::val(const cv::Mat&, Rect&, TermCriteria)>(&binding_utils::CamShiftWrapper));
676 function("meanShift", select_overload<emscripten::val(const cv::Mat&, Rect&, TermCriteria)>(&binding_utils::meanShiftWrapper));
679 function("getBuildInformation", &binding_utils::getBuildInformation);
681 #ifdef HAVE_PTHREADS_PF
682 function("parallel_pthreads_set_threads_num", &cv::parallel_pthreads_set_threads_num);
683 function("parallel_pthreads_get_threads_num", &cv::parallel_pthreads_get_threads_num);
686 #ifdef TEST_WASM_INTRIN
687 function("test_hal_intrin_uint8", &binding_utils::test_hal_intrin_uint8);
688 function("test_hal_intrin_int8", &binding_utils::test_hal_intrin_int8);
689 function("test_hal_intrin_uint16", &binding_utils::test_hal_intrin_uint16);
690 function("test_hal_intrin_int16", &binding_utils::test_hal_intrin_int16);
691 function("test_hal_intrin_uint32", &binding_utils::test_hal_intrin_uint32);
692 function("test_hal_intrin_int32", &binding_utils::test_hal_intrin_int32);
693 function("test_hal_intrin_uint64", &binding_utils::test_hal_intrin_uint64);
694 function("test_hal_intrin_int64", &binding_utils::test_hal_intrin_int64);
695 function("test_hal_intrin_float32", &binding_utils::test_hal_intrin_float32);
696 function("test_hal_intrin_float64", &binding_utils::test_hal_intrin_float64);
697 function("test_hal_intrin_all", &binding_utils::test_hal_intrin_all);
700 constant("CV_8UC1", CV_8UC1);
701 constant("CV_8UC2", CV_8UC2);
702 constant("CV_8UC3", CV_8UC3);
703 constant("CV_8UC4", CV_8UC4);
705 constant("CV_8SC1", CV_8SC1);
706 constant("CV_8SC2", CV_8SC2);
707 constant("CV_8SC3", CV_8SC3);
708 constant("CV_8SC4", CV_8SC4);
710 constant("CV_16UC1", CV_16UC1);
711 constant("CV_16UC2", CV_16UC2);
712 constant("CV_16UC3", CV_16UC3);
713 constant("CV_16UC4", CV_16UC4);
715 constant("CV_16SC1", CV_16SC1);
716 constant("CV_16SC2", CV_16SC2);
717 constant("CV_16SC3", CV_16SC3);
718 constant("CV_16SC4", CV_16SC4);
720 constant("CV_32SC1", CV_32SC1);
721 constant("CV_32SC2", CV_32SC2);
722 constant("CV_32SC3", CV_32SC3);
723 constant("CV_32SC4", CV_32SC4);
725 constant("CV_32FC1", CV_32FC1);
726 constant("CV_32FC2", CV_32FC2);
727 constant("CV_32FC3", CV_32FC3);
728 constant("CV_32FC4", CV_32FC4);
730 constant("CV_64FC1", CV_64FC1);
731 constant("CV_64FC2", CV_64FC2);
732 constant("CV_64FC3", CV_64FC3);
733 constant("CV_64FC4", CV_64FC4);
735 constant("CV_8U", CV_8U);
736 constant("CV_8S", CV_8S);
737 constant("CV_16U", CV_16U);
738 constant("CV_16S", CV_16S);
739 constant("CV_32S", CV_32S);
740 constant("CV_32F", CV_32F);
741 constant("CV_64F", CV_64F);
743 constant("INT_MIN", INT_MIN);
744 constant("INT_MAX", INT_MAX);