Skip to content

Add read/write functions for features2d and normalize naming convention#20367

Merged
asmorkalov merged 3 commits intoopencv:4.xfrom
augustinmanecy:features2d-rw
Dec 21, 2022
Merged

Add read/write functions for features2d and normalize naming convention#20367
asmorkalov merged 3 commits intoopencv:4.xfrom
augustinmanecy:features2d-rw

Conversation

@augustinmanecy
Copy link
Copy Markdown
Contributor

@augustinmanecy augustinmanecy commented Jul 6, 2021

Merge with contrib: opencv/opencv_contrib#3003

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake
Xopencv_contrib=xfeatures2d-rw
build_image:Custom=ubuntu:18.04
buildworker:Custom=linux-f1

@vpisarev
Copy link
Copy Markdown
Contributor

vpisarev commented Jul 7, 2021

@augustinmanecy, thank you for the patch! We appreciate the new functionality that you've added. However, the pull request does not pass our tests. Can you please retain the original names and also make the added read() & write() methods non-virtual?

@augustinmanecy
Copy link
Copy Markdown
Contributor Author

@vpisarev Ok I'm working on java test corrections, as suggested by @berak in the corresponding opencv_contrib PR and will commit a fix soon.
However I cannot access to details of tests failures (for obscure reasons clicking on Details finishes on a timeout) Can you precise me which tests I have to check particularly on my side before committing again?

@asmorkalov
Copy link
Copy Markdown
Contributor

FASTFeatureDetectorTest and ORBDescriptorExtractorTest in Java read Detector configuration from file. Please check changes there.

@augustinmanecy
Copy link
Copy Markdown
Contributor Author

Hi, I just pushed a new commit which fix Java tests. I also added additionnal check in read methods in order to avoid erasing current value of parameters which are not in the configuration file (if a paramater was missing in the configuration file, it was replaced by 0).
Normally tests should pass now.

@augustinmanecy
Copy link
Copy Markdown
Contributor Author

augustinmanecy commented Jul 12, 2021

Ok, the tests for BRIEF, STAR and SURF (from xfeatures2d) have failed because it was not build with my own opencv_contrib branch: (last commit of augustinmanecy/opencv_contrib referenced as PR opencv/opencv_contrib#2997)
=> How can I specify that this PR should be build with a specific PR of opencv_contrib?

@asmorkalov
Copy link
Copy Markdown
Contributor

@augustinmanecy You need to create branch with the same name in contrib/extra and propose PRs there. PRs with the same branch name are tested together.

@augustinmanecy
Copy link
Copy Markdown
Contributor Author

Tests failed for windows 10 but the failling tests are relevant to opencv_test_videoio / opencv_test_videoio.videoio/videocapture_acceleration.read... I don't think this is due to my changes, what to do now?

@alalek
Copy link
Copy Markdown
Member

alalek commented Jul 13, 2021

ignore

@augustinmanecy
Copy link
Copy Markdown
Contributor Author

augustinmanecy commented Jul 13, 2021

Ok, so does it mean this PR can be merged or is there something else to do?

@augustinmanecy
Copy link
Copy Markdown
Contributor Author

augustinmanecy commented Jul 18, 2021

I updated tests to check read parameters and I also added some missing tests (BRISK, FREAK, etc.). All builds are successful for me but the pipeline failed because I didn't created a fork for opencv_extra with branch features2d-rw, as I did not modify this part... Then I forked it now and created the features2d-rw branch.
So, is it possible to trigger again the pipeline to check if builds pass now?

(I do not understand why previous builds succeed if this fork was mandatory...)

@asmorkalov
Copy link
Copy Markdown
Contributor

I re-triggered build on pullrequest.opencv.org.

@augustinmanecy
Copy link
Copy Markdown
Contributor Author

Build for iOS failed due to inconsistence between naming conventions in generated codes.
=> It seems that generated code for armv7-iphoneos does not follow the same convention of generated code for Java interface.

The following errors are due to the fact that the parameter structure for cv::SimpleBlobDetector::Params is not always defined using the same convention in different files:

  • The structure is originally defined as cv::SimpleBlobDetector::Params in features2d.hpp - lines 737-768
  • It is defined as cv::SimpleBlobDetectorParams in generated build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/features2d/SimpleBlobDetectorParams.h:28
  • Where it is attended to be cv::SimpleBlobDetector_Params in generated file build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/features2d/SimpleBlobDetector.mm:53:44.

I would suggest to generate this structure as cv::SimpleBlobDetector_Params in _build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/features2d/SimpleBlobDetectorParams.h:28_to remains coherent with naming convention chosen in Java interface.

Here is the compilation error obtained on the forge:

CompileC /Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc/framework_build/opencv2.build/Release-iphoneos/opencv2.build/Objects-normal/armv7/SimpleBlobDetector.o objc/features2d/SimpleBlobDetector.mm normal armv7 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler
    cd /Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen
    export LANG=en_US.US-ASCII
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/opt/build/bin:/opt/pythonenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c++ -target armv7-apple-ios9.0 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -Wno-trigraphs -fpascal-strings -O1 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-implicit-atomic-properties -Wno-objc-interface-ivars -Wno-arc-repeated-use-of-weak -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wno-shorten-64-to-32 -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wno-undeclared-selector -Wno-deprecated-implementations -Wno-c++11-extensions -DCMAKE_INTDIR=\"Release-iphoneos\" -DOBJC_OLD_DISPATCH_PROTOTYPES=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-range-loop-analysis -Wno-semicolon-before-method-body -fembed-bitcode -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/lib/Release/include -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/install/include -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/install/include/opencv2 -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/core -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/imgproc -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/ml -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/phase_unwrapping -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/photo -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/plot -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/xphoto -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/dnn -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/features2d -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/imgcodecs -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/text -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/videoio -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/wechat_qrcode -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/calib3d -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/objdetect -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/structured_light -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/video -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/xfeatures2d -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/ximgproc -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/aruco -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/bgsegm -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/bioinspired -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/face -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/tracking -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/img_hash -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc/framework_build/opencv2.build/Release-iphoneos/opencv2.build/DerivedSources-normal/armv7 -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc/framework_build/opencv2.build/Release-iphoneos/opencv2.build/DerivedSources/armv7 -I/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc/framework_build/opencv2.build/Release-iphoneos/opencv2.build/DerivedSources -F/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/lib/Release -fembed-bitcode -fobjc-arc -fobjc-weak -fvisibility=hidden -fPIC -D__OPENCV_BUILD=1 -Wno-incomplete-umbrella -DNDEBUG -std=gnu++11 -MMD -MT dependencies -MF /Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc/framework_build/opencv2.build/Release-iphoneos/opencv2.build/Objects-normal/armv7/SimpleBlobDetector.d --serialize-diagnostics /Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc/framework_build/opencv2.build/Release-iphoneos/opencv2.build/Objects-normal/armv7/SimpleBlobDetector.dia -c /Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/features2d/SimpleBlobDetector.mm -o /Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc/framework_build/opencv2.build/Release-iphoneos/opencv2.build/Objects-normal/armv7/SimpleBlobDetector.o
/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/features2d/SimpleBlobDetector.mm:53:17: error: no member named 'SimpleBlobDetector_Params' in namespace 'cv'
    cv::Ptr<cv::SimpleBlobDetector_Params> retVal = new cv::SimpleBlobDetector_Params(self.nativePtrSimpleBlobDetector->getParams());
            ~~~~^
/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/features2d/SimpleBlobDetector.mm:53:44: error: C++ requires a type specifier for all declarations
    cv::Ptr<cv::SimpleBlobDetector_Params> retVal = new cv::SimpleBlobDetector_Params(self.nativePtrSimpleBlobDetector->getParams());
                                           ^
/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/features2d/SimpleBlobDetector.mm:53:57: error: no type named 'SimpleBlobDetector_Params' in namespace 'cv'; did you mean 'SimpleBlobDetectorParams'?
    cv::Ptr<cv::SimpleBlobDetector_Params> retVal = new cv::SimpleBlobDetector_Params(self.nativePtrSimpleBlobDetector->getParams());
                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                        SimpleBlobDetectorParams
In file included from /Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/features2d/SimpleBlobDetector.mm:8:
/Volumes/build-storage/build/precommit-contrib_ios/build/build_ios_contrib/build/build-armv7-iphoneos/modules/objc_bindings_generator/ios/gen/objc/features2d/SimpleBlobDetectorParams.h:28:23: note: 'SimpleBlobDetectorParams' declared here
CV_EXPORTS @interface SimpleBlobDetectorParams : NSObject
                      ^
3 errors generated.

@augustinmanecy
Copy link
Copy Markdown
Contributor Author

augustinmanecy commented Jul 20, 2021

I'm not sure how to manage "Compare ABI dumps" fails during build...

These are due to new pure methods I added for getters/setters in some features2d base class. This getters/setters are implemented in there XXX_Impl derived class and are needed for Java tests...

I can make this methods not pure (to not break derived class implementation based on previous version), as it is done for example with BRISK.:

    /** @brief Set detection threshold.
    @param threshold AGAST detection threshold score.
    */
    CV_WRAP virtual void setThreshold(int threshold) { CV_UNUSED(threshold); return; }
    CV_WRAP virtual int getThreshold() const { return -1; }

=>The problem with this solution, is that this is not the initial implementation chosen for base class of other features2d...

Any suggestions?

@augustinmanecy
Copy link
Copy Markdown
Contributor Author

I'm not sure how to manage "Compare ABI dumps" fails during build...

These are due to new pure methods I added for getters/setters in some features2d base class. This getters/setters are implemented in there XXX_Impl derived class and are needed for Java tests...

I can make this methods not pure (to not break derived class implementation based on previous version), as it is done for example with BRISK.:

    /** @brief Set detection threshold.
    @param threshold AGAST detection threshold score.
    */
    CV_WRAP virtual void setThreshold(int threshold) { CV_UNUSED(threshold); return; }
    CV_WRAP virtual int getThreshold() const { return -1; }

=>The problem with this solution, is that this is not the initial implementation chosen for base class of other features2d...

Any suggestions?

So, what should I do for this point? Dummy core as done in BRISK, change nothing, or something else?

@augustinmanecy
Copy link
Copy Markdown
Contributor Author

Build for OpenCV CN Ubuntu 18.04 and 20.04 failed in the forge because DBUILD_opencv_xfeatures2d is set to OFF:

+ cmake -G Ninja -DBUILD_DOCS=ON -DPYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3 -DBUILD_opencv_xfeatures2d=OFF -DOPENCV_DOWNLOAD_PATH=/home/ci/binaries_cache ../opencv

But this define need to be set to ON to build features2d Java Tests (see below)...

compile:
    [mkdir] Created dir: /home/opencv-cn/slave/workspace/precommit/ubuntu-20.04-arm64/opencv-build/java_test/build/classes
    [javac] Compiling 71 source files to /home/opencv-cn/slave/workspace/precommit/ubuntu-20.04-arm64/opencv-build/java_test/build/classes
    [javac] /home/opencv-cn/slave/workspace/precommit/ubuntu-20.04-arm64/opencv-build/java_test/src/org/opencv/test/features2d/BEBLIDDescriptorExtractorTest.java:5: error: package org.opencv.xfeatures2d does not exist
    [javac] import org.opencv.xfeatures2d.BEBLID;
    [javac]                              ^
    [javac] /home/opencv-cn/slave/workspace/precommit/ubuntu-20.04-arm64/opencv-build/java_test/src/org/opencv/test/features2d/BEBLIDDescriptorExtractorTest.java:9: error: cannot find symbol
    [javac]     BEBLID extractor;
    [javac]     ^
    [javac]   symbol:   class BEBLID
    [javac]   location: class BEBLIDDescriptorExtractorTest

@augustinmanecy
Copy link
Copy Markdown
Contributor Author

augustinmanecy commented Sep 8, 2021

Hi,
I would like to conclude this work and know if PR can be accepted, I've not hear from you for several weeks. What should I do to have the PR be accepted?

According to last build, there are 3 issues I can't solve without some help or guidelines:

  • Build for iOS failed due to inconsistence between naming conventions in generated codes. => See my comment of 20th July
  • "Compare ABI dumps" fails during build due to adding of some pure method (setter/getters) needed for Javatest I added. See my comment of 23th July
  • Build for OpenCV CN Ubuntu 18.04 and 20.04 failed in the forge because DBUILD_opencv_xfeatures2d is set to OFF => See my comment of 29th July

@asmorkalov can you help me with this?

Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @Palmitoxico Thanks a lot for hard work! The PR looks good to me in general. There are several things that can simplify things and improve the code:

  • No need to cast floating point values, you can just add type literal like this (float)0.2 -> 0.2f.
  • It make sense to use common base class with "not implemented" exceptions and inherit test classes from it.
  • Please do not use (double)(float) casting. JUnit supports assertEqual for floats with epsilon
  • write + writeYml test does not give much to test coverage. cv::FileStorage is used internally everywhere, so only one test case is enough.

Comment on lines +774 to +775
CV_WRAP virtual void setParams( SimpleBlobDetector::Params params ) { CV_UNUSED(params); return; }
CV_WRAP virtual SimpleBlobDetector::Params getParams() { return SimpleBlobDetector::Params(); }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The methods look confusing. Please remove them if they cannot implement parameters management.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I make them pure abstract methods, and let the derived class SimpleBlobDetectorImpl do the implementation in blobdetector.cpp

=> Concerning your suggestion (which is the same thing) about using exceptions in base class for new getters/setters, it could be for exemple for SIFT:

CV_WRAP virtual void setNFeatures(int maxFeatures) { CV_Error(Error::StsNotImplemented, "The method is not implemented, this must be done by derived classes."); }
CV_WRAP virtual int getNFeatures() const { CV_Error(Error::StsNotImplemented, "The method is not implemented, this must be done by derived classes."); }

However I'm not sure this is the good choice. Indeed, I initially added cores to the new setters/getters to workaround the "Compare ABI dumps" fails during build. But it should be pure abstract methods because adding an implementation with exception in base class will leads to runtime exceptions if derived class does not overload theses methods...

So, I would prefer to make them pure abstract to yield to compilation errors if derived class does not implement them, but this will trigger "Compare ABI dumps" fails during build. So for the same SIFT example, I would prefer to use:

CV_WRAP virtual void setNFeatures(int maxFeatures) = 0;
CV_WRAP virtual int getNFeatures() const = 0;

@asmorkalov is it possible to keep add new getters/setters as abstract methods and ignore "Compare ABI dumps" fails when merging the PR?

@augustofg
Copy link
Copy Markdown
Contributor

@asmorkalov I think you mean @augustinmanecy ?

@asmorkalov
Copy link
Copy Markdown
Contributor

Thanks a lot! Sure.

@augustinmanecy
Copy link
Copy Markdown
Contributor Author

augustinmanecy commented Nov 8, 2021

@asmorkalov
Do you have a bit of time to take a look to my last changes (commit 8698ece) and tell me if it is acceptable to validate PR?
If "Compare ABI dumps" failures cannot be ignore, I can implement something with Exceptions (as you suggested, see my last comment from 19 Oct 2021) even if I find it not optimal.

@sturkmen72
Copy link
Copy Markdown
Contributor

I could help to complete this PR if needed.

BTW what is your opinion about using only Params to get and set values like this example usage

@augustinmanecy
Copy link
Copy Markdown
Contributor Author

augustinmanecy commented Feb 21, 2022

@sturkmen72, yes with pleasure, I don't really know what is missing now to complete this PR.
Concerning the management of parameters, personally I agree with you and prefer to use a Params structure and a getParams() setParams() method. We could do the same as blobDetector.
But it will change a lot the API and lead to a lot of "Compare ABI dumps" fails if we replace old setters/getters by setParams getParams... If you think this is not a problem, we can go this way!

@asmorkalov asmorkalov requested a review from alalek October 17, 2022 09:14
@asmorkalov asmorkalov force-pushed the features2d-rw branch 3 times, most recently from 8a18503 to f9f7c6a Compare October 20, 2022 11:55
Update Java tests accrording to new features2d read/write functions. In read function, check before if node is empty to avoid erasing default value in case of missing parameters.

fix whitespace

Add check of read parameters in Java Tests.
  => add getters/setters to complete cpp/java/python API (needed for these tests.)
Add new tests for AGAST, AKAZE, BEBLID, BRISK, DAISY, FREAK, KAZE, LATCH, LUCID and MSD features2d.

fix warning override for gftt

Remove warning for conversion from double to foat for akaze, and fix doc of BRISK

Make new getters/setters not pure virtual method in base class of
fetaures2d to pass "Compare ABI dumps" tests.

revert getter/setter of AKAZE threshold parameter to double instead of double to ensure compatibility with previous version

revert getters/setters of KAZE from float to double to ensure compatibility with previous version

fix suspicious cast and use f suffix in JAVA tests to force assetEquals overload. Add valid() method to check parameters' validity of simpleBlob detector.

Remove xfeatures2d tests and enpty test suites.

Restored doubles in API.

Reimplemented SimpleBlobDetector input validation.

Resotred broken feature2d java tests.

Exlcude SimpleBlobDetector::Params::blobColor from test for now as it cannot be automatically wrapped to java.

Re-implemented new java tests to handle non-free part too.

Got rid of double->text->double conversion issue in KAZE anr AKAZE tests.
@asmorkalov
Copy link
Copy Markdown
Contributor

@alalek Could you take a look again? Known issues:

  • disabled setProperties / getProperties for SimpleBlobDetector in Obj-C, because binding is generated incorrectly.
  • SimpleBlobDetector::Params::blobColor is not exported to java as it uses uchar.

Both of the issues coulld be solved by separate PR. Please add supressions to ABI checker. In case if it looks ok, I'll squash commits and merge the PR.

@asmorkalov
Copy link
Copy Markdown
Contributor

@alalek Could you take a look on this?

String filename = OpenCVTestRunner.getTempFileName("xml");

writeFile(filename, "%YAML:1.0\n---\nthreshold: 130\nnonmaxSuppression: 1\n");
writeFile(filename, "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.FastFeatureDetector</name>\n<threshold>10</threshold>\n<nonmaxSuppression>1</nonmaxSuppression>\n<type>2</type>\n</opencv_storage>\n");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is test code changed?
Are old configurations become broken?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR adds adds more parameters to saved configuration. The YAML->XML replacement looks strange, but the line changes anyway. I decided not to rework original solution.

CV_WRAP static Ptr<SimpleBlobDetector>
create(const SimpleBlobDetector::Params &parameters = SimpleBlobDetector::Params());

CV_WRAP virtual void setParams(const SimpleBlobDetector::Params& params ) = 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need setParams() if we already have ctor/create?
Especially "virtual".

Comment on lines +2 to +7
"ManualFuncs" : {
"SimpleBlobDetector": {
"setParams": { "declaration" : [""], "implementation" : [""] },
"getParams": { "declaration" : [""], "implementation" : [""] }
}
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it really work?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I checked objc code generation and this block just disables broken bindings.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps disabling/ignoring should be done more obviously, e.g. through class_ignore_list approach (but for methods).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll be replaced with appropriate solution with another PR.

@asmorkalov asmorkalov added this to the 4.7.0 milestone Nov 24, 2022
@asmorkalov
Copy link
Copy Markdown
Contributor

@alalek Can we merge this?

@alalek
Copy link
Copy Markdown
Member

alalek commented Dec 15, 2022

There is one build warning left on Win64 (MSVS 2015) configuration.

@asmorkalov
Copy link
Copy Markdown
Contributor

@alalek ready for merge.

@asmorkalov
Copy link
Copy Markdown
Contributor

@alalek may I merge the patch?

@asmorkalov asmorkalov merged commit 0bd54a6 into opencv:4.x Dec 21, 2022
if (p.thresholdStep <= 0)
CV_Error(Error::StsBadArg, "thresholdStep>0");

if (p.minThreshold > p.maxThreshold || p.minThreshold <= 0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@augustinmanecy Should that be p.minThreshold < 0?

Some of my own internal tests are now failing against OpenCV master, and I think this is why.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@augustinmanecy augustinmanecy deleted the features2d-rw branch January 2, 2023 10:16
@alalek alalek mentioned this pull request Jan 8, 2023
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
**Merge with contrib**: opencv/opencv_contrib#3003

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
- [x] The PR is proposed to proper branch
- [ ] There is reference to original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants