Similar image search by pHash distance in Elasticsearch

后端 未结 7 1515
悲哀的现实
悲哀的现实 2020-12-07 10:51

Similar image search problem

  • Millions of images pHash\'ed and stored in Elasticsearch.
  • Format is \"11001101...11\" (length 64), but can be changed (
相关标签:
7条回答
  • 2020-12-07 11:24

    Here is 64bit solution to @NikoNyrh's answer. Hamming distance can be calculated by just using XOR operator with builtin __popcll function of CUDA.

    struct HammingDistanceFilter
    {
        const uint64_t _target, _maxDistance;
    
        HammingDistanceFilter(const uint64_t target, const uint64_t maxDistance) :
                _target(target), _maxDistance(maxDistance) {
        }
    
        __device__ bool operator()(const uint64_t hash) {
            return __popcll(_target ^ hash) <= _maxDistance;
        }
    };
    
    0 讨论(0)
提交回复
热议问题