Merge pull request #23788 from dkurt:py_scalar_assign

Change Scalar assignment in Python from single value
This commit is contained in:
Alexander Smorkalov 2023-06-13 18:12:00 +03:00 committed by GitHub
commit b522148bd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -446,5 +446,11 @@ class dnn_test(NewOpenCVTests):
normAssert(self, real_output, gold_output, "", getDefaultThreshold(target))
def test_scalefactor_assign(self):
params = cv.dnn.Image2BlobParams()
self.assertEqual(params.scalefactor, (1.0, 1.0, 1.0, 1.0))
params.scalefactor = 2.0
self.assertEqual(params.scalefactor, (2.0, 0.0, 0.0, 0.0))
if __name__ == '__main__':
NewOpenCVTests.bootstrap()

View File

@ -327,7 +327,7 @@ bool pyopencv_to(PyObject *o, Scalar& s, const ArgInfo& info)
}
} else {
if (PyFloat_Check(o) || PyInt_Check(o)) {
s[0] = PyFloat_AsDouble(o);
s = PyFloat_AsDouble(o);
} else {
failmsg("Scalar value for argument '%s' is not numeric", info.name);
return false;