Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

MxArray::toMoments out of order arguments to cv::Moments #465

Open
ringcounting opened this issue Mar 16, 2021 · 0 comments
Open

MxArray::toMoments out of order arguments to cv::Moments #465

ringcounting opened this issue Mar 16, 2021 · 0 comments

Comments

@ringcounting
Copy link

ringcounting commented Mar 16, 2021

MxArray.cpp line 714:

Is:
return cv::Moments(
(isField("m00")) ? at("m00", index).toDouble() : 0,
(isField("m10")) ? at("m10", index).toDouble() : 0,
(isField("m01")) ? at("m01", index).toDouble() : 0,
(isField("m20")) ? at("m20", index).toDouble() : 0,
(isField("m11")) ? at("m11", index).toDouble() : 0,
(isField("m02")) ? at("m02", index).toDouble() : 0,
(isField("m30")) ? at("m30", index).toDouble() : 0,
(isField("m12")) ? at("m12", index).toDouble() : 0,
(isField("m21")) ? at("m21", index).toDouble() : 0,

(isField("m03")) ? at("m03", index).toDouble() : 0
);

Should be:
return cv::Moments(
(isField("m00")) ? at("m00", index).toDouble() : 0,
(isField("m10")) ? at("m10", index).toDouble() : 0,
(isField("m01")) ? at("m01", index).toDouble() : 0,
(isField("m20")) ? at("m20", index).toDouble() : 0,
(isField("m11")) ? at("m11", index).toDouble() : 0,
(isField("m02")) ? at("m02", index).toDouble() : 0,
(isField("m30")) ? at("m30", index).toDouble() : 0,
(isField("m21")) ? at("m21", index).toDouble() : 0,
(isField("m12")) ? at("m12", index).toDouble() : 0,

(isField("m03")) ? at("m03", index).toDouble() : 0
);

Alternatively, copy all input fields instead of recalculating the central and normalized moments:
cv::Moments mo;
mo.m00 = (isField("m00")) ? at("m00", index).toDouble() : 0;
mo.m10 = (isField("m10")) ? at("m10", index).toDouble() : 0;
mo.m01 = (isField("m01")) ? at("m01", index).toDouble() : 0;
mo.m20 = (isField("m20")) ? at("m20", index).toDouble() : 0;
mo.m11 = (isField("m11")) ? at("m11", index).toDouble() : 0;
mo.m02 = (isField("m02")) ? at("m02", index).toDouble() : 0;
mo.m30 = (isField("m30")) ? at("m30", index).toDouble() : 0;
mo.m12 = (isField("m12")) ? at("m12", index).toDouble() : 0;
mo.m21 = (isField("m21")) ? at("m21", index).toDouble() : 0;
mo.m03 = (isField("m03")) ? at("m03", index).toDouble() : 0;
mo.mu20 = (isField("mu20")) ? at("mu20", index).toDouble() : 0;
mo.mu11 = (isField("mu11")) ? at("mu11", index).toDouble() : 0;
mo.mu02 = (isField("mu02")) ? at("mu02", index).toDouble() : 0;
mo.mu30 = (isField("mu30")) ? at("mu30", index).toDouble() : 0;
mo.mu21 = (isField("mu21")) ? at("mu21", index).toDouble() : 0;
mo.mu12 = (isField("mu12")) ? at("mu12", index).toDouble() : 0;
mo.mu03 = (isField("mu03")) ? at("mu03", index).toDouble() : 0;
mo.nu20 = (isField("nu20")) ? at("nu20", index).toDouble() : 0;
mo.nu11 = (isField("nu11")) ? at("nu11", index).toDouble() : 0;
mo.nu02 = (isField("nu02")) ? at("nu02", index).toDouble() : 0;
mo.nu30 = (isField("nu30")) ? at("nu30", index).toDouble() : 0;
mo.nu12 = (isField("nu12")) ? at("nu12", index).toDouble() : 0;
mo.nu21 = (isField("nu21")) ? at("nu21", index).toDouble() : 0;
mo.nu03 = (isField("nu03")) ? at("nu03", index).toDouble() : 0;
return mo;

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant