New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor core module for type-safety #12487
Conversation
modules/core/src/norm.cpp
Outdated
@@ -630,7 +631,7 @@ double cv::norm( InputArray _src, int normType, InputArray _mask ) | |||
normType &= NORM_TYPE_MASK; | |||
CV_Assert( normType == NORM_INF || normType == NORM_L1 || | |||
normType == NORM_L2 || normType == NORM_L2SQR || | |||
((normType == NORM_HAMMING || normType == NORM_HAMMING2) && _src.type() == CV_8U) ); | |||
((normType == NORM_HAMMING || normType == NORM_HAMMING2) && _src.type() == CV_8UC1) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like bug is catched here from the original code.
Why not _src.depth() == CV_8U
?
/cc @vpisarev
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will see hundreds of similar cases! There are even functions that receive type, although they just need the depth... I have actually made several decisions in utilizing depth instead of type (e.g. in all arithmetic operations, convertTo
, assign
, assignTo
, calcCovarMatrix
), and I really hop you will catch what I missed.
23e34cc
to
269217e
Compare
@alalek I am getting undefined reference to some functions that are already defined 😕 such as in this build. |
This build step trying to build samples with "installed" OpenCV binaries + headers. |
double beta, double gamma, OutputArray dst, ElemDepth ddepth = CV_DEPTH_AUTO); | ||
#ifdef CV_COMPATIBLE_API | ||
CV_EXPORTS inline void addWeighted(InputArray src1, double alpha, InputArray src2, | ||
double beta, double gamma, OutputArray dst, int ddepth) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CV_EXPORTS
Remove CV_EXPORTS
.
Use "static inline" for compatibility entry points.
6dd7b0a
to
a12e144
Compare
@alalek Never mind my previous request about some assertion failures, as it is already solved! |
Could you point on some examples? Perhaps we can skip compatibility stuff for them. |
It all originated from the class virtual void get_test_array_types_and_sizes(int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types);
virtual void get_minmax_bounds(int i, int j, int depth, Scalar& low, Scalar& high); I handled part of the problem, but I still see some failures here and there, which most probably have relation to the above mentioned functions, and it is taking too much time of me already 😕 |
Compatibility stuff is not needed in tests. |
1111f26
to
2282f54
Compare
well, if you look at the statistics of the closed PRs, you will see that we usually merge over 100 patches per month, over a thousand of patches per year. Most of the patches are innocent, they fix a small bug, or bring some new optimization, or even add new functionality or new documentation. Such patches usually take little time to review and they get merged very fast. Now the case of your patch is completely different. You started with very fundamental things in OpenCV that live there for 10 years already! You may not know, but I will tell you that many, many people still use OpenCV 2.4.x. I've heard about some big projects that only now consider migration to OpenCV 3.x, even though OpenCV 3.0 has been released 3 years ago. There is huge inertia in software. If it ain't break, don't fix it. You said that you value compatibility, but I honestly do not see that. It's number 1 priority in our project. Between the radical patch that sort of improves API style and compatibility I would choose compatibility any time of day. Say, if you come to Python community and suggest to change the language syntax "slightly", or come to Linux community and suggest to change a bit driver API that breaks backward compatibility - what would happen? Some PIPs in Python and some forks in Linux live separately for years. OpenCV is 18 year-long project, we have hundreds of thousands of users, and even though we are quite liberal w.r.t patches and suggestions, we still have to carefully evaluate each patch that breaks compatibility. 1 month is nothing comparing to the years of support from our side and many man-years that OpenCV community needs to spend to repair all the code that is broken because of this tiny patch. If the argument is that users will build OpenCV in "compatibility mode", then it looks like the patch is not up to some claims it makes - it does not make user's OpenCV-based code safer, it just makes OpenCV itself more type-safe (but we have many unit tests, valgrind and such, so OpenCV code itself is rather well-tested). If you are brave enough (as one of the reviewers said) to submit such radical patches, please get enough patience and be ready to find compromises. I value that you've updated the PR, thank you very much. I still see that it's quite a lot of changes, including many cases of == Here is the roadmap of this patch inclusion:
We try to do it all by OpenCV 4.0. If not, in principle we can do it in 4.1. Or maybe we'll split |
@vpisarev I will prepare the |
@vpisarev PR #12609 does what you requested for. Please let me know if you still have further requirements.
I have grouped the differences in a single commit for your convenience: cv3d/opencv@e1c13c0 |
I also have the same goal in mind, but my approach is different. I plan to increase the capacity of
Darn! Is that why I am getting tortured now? It is not my fault.. I cannot control others 😢
please get enough faith/believe/trust and be ready to get amazed |
9b11a60
to
8061468
Compare
- propagate CV_TYPE_SAFE_API/CV_TYPE_COMPATIBLE_API for user apps - special fix for CUDA
We are not fixing it. We are introducing new feature: type-safety
Besides your own opinion, what do you see exactly? What does this PR break?
I have reduced this PR to its minimal, in which there is zero changes from CV_8U to CV_8UC1 etc.
After I prepared the comparison patch, I believe we are in the final bullet (although I cannot get why this PR shall wait for the new types anyway), but you also said
It sounds like a recursive function call for me, but I do not see a termination criteria.. |
@vpisarev I said it a week ago, and I will say it again: I am not convinced by your logic, and I cannot understand why this PR should wait.. BTW: Why all this silence? |
@vpisarev I believe you meant this patch. So, any chance to consider this PR as a separate and independent feature by now? I think I already demonstrated they are unrelated via my other design and new types PRs (i.e. #12729 & #12730). Accordingly, I want to solve the conflicts in this PR in order to merge it, but first, I need your confirmation we will not have any further delays.. |
experiment with ElemType-only patch is not finished yet (#12609). I left you multiple comments, but they are not addressed; instead, you continue to create tons of new PRs |
@vpisarev My bad! I did not notice your reply 😕 |
Merge with opencv/opencv_contrib#1768
and opencv/opencv_extra#518This pullrequest changes
Utilized options/preprocessors:
CV_TYPE_SAFE_API
with CMAKE optionENABLE_TYPE_SAFE_API
to enable enum-based type-safe APICV_TYPE_COMPATIBLE_API
with CMAKE optionENABLE_COMPATIBLE_API
to enable the overloaded int-based API. Although it is enabled by default and using it would raise deprecation warnings, it still recommended to disable it in the build farm to enforce good practices.CV_COMPATIBLE_API
is only available whenENABLE_TYPE_SAFE_API
is set.CV_TRANSNATIONAL_API
utilized internally, and should be removed after migration completes.