下载
中文
注册

ComputeDistanceByThreshold

API定义

APP_ERROR ComputeDistanceByThreshold(const std::vector<uint32_t> &queryIdxArr, uint32_t codeStartIdx, uint32_t codeNum, float threshold, bool aboveFilter, std::vector<std::vector<float>> &resDistArr, std::vector<std::vector<uint32_t>> &resIdxArr);

功能描述

查询指定条数在底库中的特征向量与指定的底库特征向量的距离,并根据阈值筛选,返回满足条件的距离和其label。

输入

const std::vector<uint32_t> &queryIdxArr:要查询的向量在底库中的序号。

uint32_t codeStartIdx:要计算距离的底库的起始序号。

uint32_t codeNum:要计算距离的底库向量的数量。

float threshold:用于过滤的阈值,过滤掉比阈值小的距离。

bool aboveFilter:预留参数。

输出

std::vector<std::vector<float>> &resDistArr:返回的二维数组,每个要查询的向量与其满足阈值条件的底库向量的距离。

std::vector<std::vector<uint32_t>> &resIdxArr:返回的二维数组,每个要查询的向量与其满足阈值条件的底库向量的label。

返回值

APP_ERROR:调用返回状态,具体请参见接口调用返回值参考

约束说明

  • “queryIdxArr”“resDistArr”“resIdxArr”长度要一致,即queryIdxArr.size() == resDistArr.size()
  • “queryIdxArr.size()”需大于“0”并且小于等于“ntotal”
  • “codeNum ”需大于“0”并且小于等于“ntotal”
  • “codeStartIdx” +“ codeNum” 不大于“ntotal”(底库大小)。