Skip to content
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

Custom handling of FaceRecognizer results #402

Merged
merged 1 commit into from
Dec 8, 2015

Conversation

comdiv
Copy link
Contributor

@comdiv comdiv commented Oct 14, 2015

It's code that can close #401 or can be used as suggestion to close this ticket

To implement this method u just have to do same internal cycle as in predict(InputArray src, CV_OUT int &label, CV_OUT double &confidence) but
not try to get "best@ result, just resend it to caller side with given collector
*/
CV_WRAP virtual void predict_collect(InputArray src, PredictCollector collector) const = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

since the automated scripting generator (for python java,etc) can't handle callbacks (save c++11 things), this might have to go without the CV_WRAP tag

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK will fix it

@comdiv
Copy link
Contributor Author

comdiv commented Oct 14, 2015

suggestions fixed

@berak
Copy link
Contributor

berak commented Oct 14, 2015

(disclaimer: i haven't tried)

the linux/android builds might need enabling c++11, similar to this

@comdiv comdiv force-pushed the comdiv branch 4 times, most recently from 3a23a9d to 0616037 Compare October 15, 2015 08:32
@mshabunin
Copy link
Contributor

@comdiv, why didn't you use object as a handler? Something similar to:

struct Collector {
    virtual bool collectOne(int, double, int) = 0;
}
...
virtual void predict_collect(InputArray src, Collector & collector, const int state = 0) const = 0;

I think it is not a good idea to have different interfaces for different C++ standards. If one have library compiled with C++03 compiler than all applications using this library will be restricted to use same standard, otherwise linking errors will occur.

@comdiv
Copy link
Contributor Author

comdiv commented Oct 15, 2015

I think that really better is to use Iterator patter -

PredictItertator FaceRecognizer.open(...) ;
PredictRecord PredictIterator::next();
void PredictIterator::close();
struct PredictRecord  { int label, double dist } ; // or {int* label, double* dist}

As it used to be in .NET world - so client side decide itself how to deal with that.

While may be Collector class should be more usefull while we can predefine MaxCollector, AvgCollector, FirstByTreshholdCollector, Top10Collector and so on with ready to use aggregations.

Such set of classes could be Templated and be capable work with different collect_one notations.

The only thing is not good - while i'm using (bool*) and std::funciton it's just overload of predict, expressed in other C++ standard things. When we add Collector class family we grow entropy of opencv + opencv_contrib design. Where it could be defined? In face? In shared code for contrib? In opencv? Somwhere else?

@comdiv
Copy link
Contributor Author

comdiv commented Oct 15, 2015

Think I'll rewrite on collector as class design and replace existed master overload of predict (while it's more generic).
The only implemented in core type of Collector will be MostCloseCollector that will be used internally by FaceRecognizer.
On public API level only abstract Collector will be provided.
So any brainf**ks about C++11 will be fixed.

@comdiv
Copy link
Contributor Author

comdiv commented Oct 15, 2015

Have totally rewrite facerecognizer internals to use with PredicCollector class,
not breaking change - older API still in game
no c++ 11 dependency or other conditional compilation

@comdiv comdiv force-pushed the comdiv branch 5 times, most recently from 2016a0b to 30bb818 Compare October 15, 2015 17:47
@comdiv
Copy link
Contributor Author

comdiv commented Oct 15, 2015

require suggestion - how to make it Pythonable?
When I make CV_WRAP onto method - it error that PredicCollector is unknown.
How to make it well?

@comdiv comdiv force-pushed the comdiv branch 2 times, most recently from 1bbca8a to 093fc58 Compare October 16, 2015 07:44
@mshabunin
Copy link
Contributor

Try to change to Ptr<PredictCollector>:

CV_WRAP virtual void predict(InputArray src, Ptr<PredictCollector> collector, const int state = 0) const = 0;

Also, users will need to create instances of PredictCollector in python, for this factory method should be implemented (static class method or separate function):

Ptr<MinDistancePredictCollector> MinDistancePredictCollector::create() {}

@comdiv comdiv force-pushed the comdiv branch 5 times, most recently from 5e10eff to 7b129a6 Compare October 16, 2015 11:43
@comdiv
Copy link
Contributor Author

comdiv commented Oct 16, 2015

All green but builds was renamed so warning in github still occures

@mshabunin
Copy link
Contributor

@comdiv, please replace tabs with 4 spaces.

@comdiv
Copy link
Contributor Author

comdiv commented Oct 22, 2015

done

@comdiv
Copy link
Contributor Author

comdiv commented Oct 27, 2015

Is it usefull to add some custom PredictCollector implementations?
For example i have TopNPredictCollector.

@mshabunin
Copy link
Contributor

@comdiv , please revert all unrelated changes e.g. code formatting.

@comdiv
Copy link
Contributor Author

comdiv commented Dec 7, 2015

Have fixed

* without specific prior written permission.
*
* See <http://www.opensource.org/licenses/bsd-license>
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this license is wrong. Please replace it with text from the main license.

@mshabunin
Copy link
Contributor

I have no other comments.

@comdiv
Copy link
Contributor Author

comdiv commented Dec 8, 2015

yes, copyed license from somewhere in opencv or opencv-contrib, will place your one

predict method rewritten to use with PredictCollector interface (abstract class)
now face recognizer allow to perform different scenarios of result handling
@comdiv
Copy link
Contributor Author

comdiv commented Dec 8, 2015

Have applyed valid license.
Another question - i can add some PredictCollector subclasses that can be usefull - is it pleased?

@mshabunin
Copy link
Contributor

@comdiv , yes it could be useful. I think it is better to create new PR for this. Maybe we could also implement a simple example of using new interface.

👍

@comdiv
Copy link
Contributor Author

comdiv commented Dec 8, 2015

What is better?

  1. New ISSUE + new PR
  2. Existed ISSUE + new PR
  3. Continue this pair of ISSUE+PR

@opencv-pushbot opencv-pushbot merged commit 9ff3192 into opencv:master Dec 8, 2015
mshabunin added a commit that referenced this pull request Dec 8, 2015
@mshabunin
Copy link
Contributor

Just create a new PR with the proposed functionality, new issue is not necessary.

@comdiv comdiv deleted the comdiv branch December 8, 2015 08:14
@comdiv
Copy link
Contributor Author

comdiv commented Dec 8, 2015

Have question - can std::list be used with CV_WRAP , if not what is common type and conversion for such return values.

allnes pushed a commit to allnes/opencv_contrib that referenced this pull request Jun 9, 2024
* Updated history_cuda.yml, sanitizer_cuda.yml and test_cuda.yml pipelines:
1) All cuda_plugin pipelines will be run if cuda_plugin fiolder was changed
2) Updated sanitizer_cuda.yml with proper CudaFuncTests's filters due to memory exhausting under cuda-memcheck

* Renamed Range test to be handled by sanitizer_cuda
* Update timeout for CUDAPlugin_Lin to 60 minutes

Made separate Azure pipeline for CUDA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom handling of FaceRecognizer results
4 participants