alicevision/CCTag

CCTag reproducible output

anauta00 opened this issue ยท 7 comments

Hi,

I have just started using your nice library.
The results are encouraging and fast (on the GPU). ๐Ÿ˜€

However, I would like each 'detection run' to yield the same output.
Now, each run shows small deviations in the center points found.

I have looked at the code but cannot seem to find out how to do this.

Can anyone help?

Thanks and greetings,
Auke Nauta

most probably it's because of some randomness of the algorithm in choosing points.
Whenever a random function is used in the code, a deterministic seed should be used so that the result are consistent over multiple runs.
This may require some refactoring, though. I cannot pinpoint the exact parts but if you are willing to do it, it could be a nice contribution. :)

Hi,

I have researched this issue extensively now.
Using the CPU, deterministic runs can be obtained by #defining 'CCTAG_SERIALIZE'.

However, for the GPU part, this is far from clear.
I tried #defining 'SORT_ALL_EDGECOORDS_IN_EXPORT' but then CCTag would no longer compile:
std::sort( _all_edgecoords.host.ptr, _all_edgecoords.host.ptr+all_sz, v_comp );
would not compile then...

As (at least some of) you have wrote the software, I would think (certainly hope!) that you could point me in the right direction.
Having non-deterministic output (using the GPU) is not an option for my application.

Thanks for any help and greetings,
Auke

What is the compilation error for std::sort?
@griwodz should know better what needs to be done.

Hi,

function "int2cmp::operator()" cannot be called with the given argument list	CCTag	C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include\xutility	1092	

Several such errors are generated for 'xutility' as well as 'algorithm'.

Predicate 'int2cmp' is defined like this:

class int2cmp
{
public:
    __host__
    inline bool operator()( const int2& l, const int2& r )
    {
        return tpcmp( l, r );
    }
};

Could it be that _all_edgecoords is a short2 instead of a int2?
Maybe trying to define a short2cmp the same way as int2cmp in cmp_list.h and then use it inside the std::sort could solve the issue?

Thanks, that did the trick!

However, GPU output still is not deterministic. I tried lots of other things (like using the '--sync' switch) but to no avail.
Unfortunately, my knowledge of CUDA programming is really limited and I can not get this to work (to my liking).
Any additional help to create deterministic output would be appreciated!

Greetings,
Auke

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.