Open vpisarev opened 9 months ago
Several side notes on proposal:
In API we mostly use int's, double's and float's. I don't expect many changes in API. But I agree that we need to update bindings generators.
I myself, just like Java creators, don't like unsigned integer types, but we need them for a lot of stuff, especially inside OpenCV code; most notably, uint8_t.
Also I propose to got rid of double and double* as supertype. We have (u)int64 that does not fit into double. Also it break user types in many places.
'Also it break user types in many places' - can you please decrypt it?
I mean strong typing and extra code to convert to double and back.
ok, then probably those few functions that take/return scalars as scalars, not as Input/OutputArrays, should use the new std::variant<>
type.
Need to tune Java, Python, JS, Julia bindings for std::variant then.
Wouldn't it also make sense to redesign current Scalar
concept to align it with mathematical definition (and NumPy)? Maybe even get rid of this class completely? Then 3-channel images will be represented as 3D Mat (which they technically are) and might make interoperability with NumPy and other libraries easier.
Then 3-channel images will be represented as 3D Mat
Hands up for this feature 🙋
@mshabunin, this is interesting proposal, but we need to think about details, like:
Scalar sum(InputArray arr);
will look likevoid circle(InputOutputArray img, Point center, int radius, Scalar color, ...);
will look likevoid GaussianBlur(...)
, void resize(...)
etc. should do when they are given 0D, 1D, 2D, 3D, 4D, 5D, ... arrays on input?what users should do with their manually-written image processing loops that assume multi-channel 2D images, e.g.
for (int y = 0; y < img.rows; y++)
for (int x = 0; x < img.cols; x++)
img.at<Vec3b>(y, x) = Vec3b(y, x, y+x);
sum
should have axis parameter, e.g. sum(InputArray img, OutputArray res, InputArray axis)
, it can default to H&W axes for 2D-3D arrays for compatibility.Scalar
InputArray
should be used to pass color value, its type and dimensions should be checked for compatibility with given image, e.g. it can be Vec3b
for 3-channel 8u image.2D
suffix can be added to functions which are limited to working with regular images (2D arrays - HW, 3D arrays - HWC, 4D arrays - NHWC).at
should check for type and dimensions compatibility as it does now.I would like to share that int
might be different with int32_t
in some compiler, such as with HexagonSDK 5.5.0.1's hexagon-clang compiler, which may cause template function definition and invocation mismatch issue.
https://github.com/quic/toolchain_for_hexagon/issues/26#issuecomment-2049286555
Describe the feature and motivation
For OpenCV 5, where we have a good chance to repair certain things, even if it slightly breaks API, it would be nice to replace some "home-brewed" names with somewhat more standard:
'int' is a special story - it's used very often in API and probably we should keep it as-is in API (except when int means int32_t, not just "integer with sufficiently large value range")
the old definitions may be put into a dedicated header that may be included by default in OpenCV 5 and not included by default in OpenCV 6+
Additional context
No response