1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2025-02-05 09:28:27 +03:00
180 changed files with 11419 additions and 1819 deletions
+23 -33
View File
@@ -378,7 +378,6 @@ namespace binding_utils
return result;
}
void Tracker_init_wrapper(cv::Tracker& arg0, const cv::Mat& arg1, const Rect& arg2)
{
return arg0.init(arg1, arg2);
@@ -467,11 +466,15 @@ EMSCRIPTEN_BINDINGS(binding_utils)
register_vector<double>("DoubleVector");
register_vector<std::string>("StringVector");
register_vector<cv::Point>("PointVector");
register_vector<cv::Point3f>("Point3fVector");
register_vector<cv::Mat>("MatVector");
register_vector<cv::Rect>("RectVector");
register_vector<cv::KeyPoint>("KeyPointVector");
register_vector<cv::DMatch>("DMatchVector");
register_vector<std::vector<char>>("CharVectorVector");
register_vector<std::vector<cv::DMatch>>("DMatchVectorVector");
register_vector<std::vector<cv::KeyPoint>>("KeyPointVectorVector");
register_vector<std::vector<cv::Point>>("PointVectorVector");
emscripten::class_<cv::Mat>("Mat")
@@ -520,7 +523,7 @@ EMSCRIPTEN_BINDINGS(binding_utils)
.function("colRange", select_overload<Mat(int, int)const>(&cv::Mat::colRange))
.function("colRange", select_overload<Mat(const Range&)const>(&cv::Mat::colRange))
.function("step1", select_overload<size_t(int)const>(&cv::Mat::step1))
.function("clone", select_overload<Mat()const>(&cv::Mat::clone))
.function("mat_clone", select_overload<Mat()const>(&cv::Mat::clone))
.function("depth", select_overload<int()const>(&cv::Mat::depth))
.function("col", select_overload<Mat(int)const>(&cv::Mat::col))
.function("dot", select_overload<double(const Mat&, const Mat&)>(&binding_utils::matDot))
@@ -584,7 +587,7 @@ EMSCRIPTEN_BINDINGS(binding_utils)
.field("epsilon", &cv::TermCriteria::epsilon);
#define EMSCRIPTEN_CV_SIZE(type) \
emscripten::value_object<type>("#type") \
emscripten::value_object<type>(#type) \
.field("width", &type::width) \
.field("height", &type::height);
@@ -592,12 +595,13 @@ EMSCRIPTEN_BINDINGS(binding_utils)
EMSCRIPTEN_CV_SIZE(Size2f)
#define EMSCRIPTEN_CV_POINT(type) \
emscripten::value_object<type>("#type") \
emscripten::value_object<type>(#type) \
.field("x", &type::x) \
.field("y", &type::y); \
EMSCRIPTEN_CV_POINT(Point)
EMSCRIPTEN_CV_POINT(Point2f)
EMSCRIPTEN_CV_POINT(Point3f)
#define EMSCRIPTEN_CV_RECT(type, name) \
emscripten::value_object<cv::Rect_<type>> (name) \
@@ -614,10 +618,6 @@ EMSCRIPTEN_BINDINGS(binding_utils)
.field("size", &cv::RotatedRect::size)
.field("angle", &cv::RotatedRect::angle);
function("rotatedRectPoints", select_overload<emscripten::val(const cv::RotatedRect&)>(&binding_utils::rotatedRectPoints));
function("rotatedRectBoundingRect", select_overload<Rect(const cv::RotatedRect&)>(&binding_utils::rotatedRectBoundingRect));
function("rotatedRectBoundingRect2f", select_overload<Rect2f(const cv::RotatedRect&)>(&binding_utils::rotatedRectBoundingRect2f));
emscripten::value_object<cv::KeyPoint>("KeyPoint")
.field("angle", &cv::KeyPoint::angle)
.field("class_id", &cv::KeyPoint::class_id)
@@ -644,10 +644,25 @@ EMSCRIPTEN_BINDINGS(binding_utils)
.field("minLoc", &binding_utils::MinMaxLoc::minLoc)
.field("maxLoc", &binding_utils::MinMaxLoc::maxLoc);
emscripten::value_object<cv::Exception>("Exception")
.field("code", &cv::Exception::code)
.field("msg", &binding_utils::getExceptionMsg, &binding_utils::setExceptionMsg);
emscripten::value_object<binding_utils::Circle>("Circle")
.field("center", &binding_utils::Circle::center)
.field("radius", &binding_utils::Circle::radius);
function("boxPoints", select_overload<emscripten::val(const cv::RotatedRect&)>(&binding_utils::rotatedRectPoints));
function("rotatedRectPoints", select_overload<emscripten::val(const cv::RotatedRect&)>(&binding_utils::rotatedRectPoints));
function("rotatedRectBoundingRect", select_overload<Rect(const cv::RotatedRect&)>(&binding_utils::rotatedRectBoundingRect));
function("rotatedRectBoundingRect2f", select_overload<Rect2f(const cv::RotatedRect&)>(&binding_utils::rotatedRectBoundingRect2f));
function("exceptionFromPtr", &binding_utils::exceptionFromPtr, allow_raw_pointers());
function("minMaxLoc", select_overload<binding_utils::MinMaxLoc(const cv::Mat&, const cv::Mat&)>(&binding_utils::minMaxLoc));
function("minMaxLoc", select_overload<binding_utils::MinMaxLoc(const cv::Mat&)>(&binding_utils::minMaxLoc_1));
function("CV_MAT_DEPTH", &binding_utils::cvMatDepth);
function("getBuildInformation", &binding_utils::getBuildInformation);
#ifdef HAVE_OPENCV_IMGPROC
emscripten::value_object<cv::Moments >("Moments")
.field("m00", &cv::Moments::m00)
.field("m10", &cv::Moments::m10)
@@ -674,49 +689,24 @@ EMSCRIPTEN_BINDINGS(binding_utils)
.field("nu12", &cv::Moments::nu12)
.field("nu03", &cv::Moments::nu03);
emscripten::value_object<cv::Exception>("Exception")
.field("code", &cv::Exception::code)
.field("msg", &binding_utils::getExceptionMsg, &binding_utils::setExceptionMsg);
function("exceptionFromPtr", &binding_utils::exceptionFromPtr, allow_raw_pointers());
#ifdef HAVE_OPENCV_IMGPROC
function("minEnclosingCircle", select_overload<binding_utils::Circle(const cv::Mat&)>(&binding_utils::minEnclosingCircle));
function("floodFill", select_overload<int(cv::Mat&, cv::Mat&, Point, Scalar, emscripten::val, Scalar, Scalar, int)>(&binding_utils::floodFill_wrapper));
function("floodFill", select_overload<int(cv::Mat&, cv::Mat&, Point, Scalar, emscripten::val, Scalar, Scalar)>(&binding_utils::floodFill_wrapper_1));
function("floodFill", select_overload<int(cv::Mat&, cv::Mat&, Point, Scalar, emscripten::val, Scalar)>(&binding_utils::floodFill_wrapper_2));
function("floodFill", select_overload<int(cv::Mat&, cv::Mat&, Point, Scalar, emscripten::val)>(&binding_utils::floodFill_wrapper_3));
function("floodFill", select_overload<int(cv::Mat&, cv::Mat&, Point, Scalar)>(&binding_utils::floodFill_wrapper_4));
#endif
function("minMaxLoc", select_overload<binding_utils::MinMaxLoc(const cv::Mat&, const cv::Mat&)>(&binding_utils::minMaxLoc));
function("minMaxLoc", select_overload<binding_utils::MinMaxLoc(const cv::Mat&)>(&binding_utils::minMaxLoc_1));
#ifdef HAVE_OPENCV_IMGPROC
function("morphologyDefaultBorderValue", &cv::morphologyDefaultBorderValue);
#endif
function("CV_MAT_DEPTH", &binding_utils::cvMatDepth);
#ifdef HAVE_OPENCV_VIDEO
function("CamShift", select_overload<emscripten::val(const cv::Mat&, Rect&, TermCriteria)>(&binding_utils::CamShiftWrapper));
function("meanShift", select_overload<emscripten::val(const cv::Mat&, Rect&, TermCriteria)>(&binding_utils::meanShiftWrapper));
emscripten::class_<cv::Tracker >("Tracker")
.function("init", select_overload<void(cv::Tracker&,const cv::Mat&,const Rect&)>(&binding_utils::Tracker_init_wrapper), pure_virtual())
.function("update", select_overload<emscripten::val(cv::Tracker&,const cv::Mat&)>(&binding_utils::Tracker_update_wrapper), pure_virtual());
#endif
function("getBuildInformation", &binding_utils::getBuildInformation);
#ifdef HAVE_PTHREADS_PF
function("parallel_pthreads_set_threads_num", &cv::parallel_pthreads_set_threads_num);
function("parallel_pthreads_get_threads_num", &cv::parallel_pthreads_get_threads_num);
+4 -12
View File
@@ -66,7 +66,6 @@ Module['imread'] = function(imageSource) {
ctx = canvas.getContext('2d');
} else {
throw new Error('Please input the valid canvas or img id.');
return;
}
var imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
@@ -82,11 +81,9 @@ Module['imshow'] = function(canvasSource, mat) {
}
if (!(canvas instanceof HTMLCanvasElement)) {
throw new Error('Please input the valid canvas element or id.');
return;
}
if (!(mat instanceof cv.Mat)) {
throw new Error('Please input the valid cv.Mat instance.');
return;
}
// convert the mat type to cv.CV_8U
@@ -108,7 +105,6 @@ Module['imshow'] = function(canvasSource, mat) {
break;
default:
throw new Error('Bad number of channels (Source image must have 1, 3 or 4 channels)');
return;
}
var imgData = new ImageData(new Uint8ClampedArray(img.data), img.cols, img.rows);
var ctx = canvas.getContext('2d');
@@ -128,7 +124,6 @@ Module['VideoCapture'] = function(videoSource) {
}
if (!(video instanceof HTMLVideoElement)) {
throw new Error('Please input the valid video element or id.');
return;
}
var canvas = document.createElement('canvas');
canvas.width = video.width;
@@ -138,15 +133,12 @@ Module['VideoCapture'] = function(videoSource) {
this.read = function(frame) {
if (!(frame instanceof cv.Mat)) {
throw new Error('Please input the valid cv.Mat instance.');
return;
}
if (frame.type() !== cv.CV_8UC4) {
throw new Error('Bad type of input mat: the type should be cv.CV_8UC4.');
return;
}
if (frame.cols !== video.width || frame.rows !== video.height) {
throw new Error('Bad size of input mat: the size should be same as the video.');
return;
}
ctx.drawImage(video, 0, 0, video.width, video.height);
frame.data.set(ctx.getImageData(0, 0, video.width, video.height).data);
@@ -263,7 +255,7 @@ function Scalar(v0, v1, v2, v3) {
Scalar.prototype = new Array; // eslint-disable-line no-array-constructor
Scalar.all = function(v) {
return new Scalar(v, v, v, v);
return Scalar(v, v, v, v);
};
Module['Scalar'] = Scalar;
@@ -273,8 +265,8 @@ function MinMaxLoc() {
case 0: {
this.minVal = 0;
this.maxVal = 0;
this.minLoc = new Point();
this.maxLoc = new Point();
this.minLoc = Point(0, 0);
this.maxLoc = Point(0, 0);
break;
}
case 4: {
@@ -295,7 +287,7 @@ Module['MinMaxLoc'] = MinMaxLoc;
function Circle() {
switch (arguments.length) {
case 0: {
this.center = new Point();
this.center = Point(0, 0);
this.radius = 0;
break;
}