当前位置: 首页>>代码示例>>Java>>正文


Java FactoryNearestNeighbor类代码示例

本文整理汇总了Java中org.ddogleg.nn.FactoryNearestNeighbor的典型用法代码示例。如果您正苦于以下问题:Java FactoryNearestNeighbor类的具体用法?Java FactoryNearestNeighbor怎么用?Java FactoryNearestNeighbor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FactoryNearestNeighbor类属于org.ddogleg.nn包,在下文中一共展示了FactoryNearestNeighbor类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: matchImage

import org.ddogleg.nn.FactoryNearestNeighbor; //导入依赖的package包/类
/**
 * Self API. Load an image from the URL and find the closest matching image.
 */
@SuppressWarnings("unchecked")
public Vertex matchImage(byte[] image, Vertex tag, double error, Network network) throws IOException {
   	double[] histogram = coupledHueSat(image);
   	
	List<double[]> points = new ArrayList<double[]>();
	List<Vertex> images = tag.orderedRelations(Primitive.IMAGE);
	for (Vertex vertex : images) {
		Object value = vertex.getData();
		if (!(value instanceof BinaryData)) {
			continue;
		}
		BinaryData data = (BinaryData)network.findData((BinaryData)value);
	    points.add(coupledHueSat(data.getBytes()));
	}

	// Use a generic NN search algorithm.  This uses Euclidean distance as a distance metric.
	NearestNeighbor<Vertex> nn = FactoryNearestNeighbor.exhaustive();
	FastQueue<NnData<Vertex>> results = new FastQueue(NnData.class, true);

	nn.init(histogram.length);
	nn.setPoints(points, images);
	nn.findNearest(histogram, -1, 1, results);
	NnData<Vertex> best = results.get(0);
	log("Image match", Level.FINE, best.distance);
	if (best.distance > error) {
		return null;
	}
	return best.data;
}
 
开发者ID:BotLibre,项目名称:BotLibre,代码行数:33,代码来源:Vision.java

示例2: createAlg

import org.ddogleg.nn.FactoryNearestNeighbor; //导入依赖的package包/类
@Override
public AssociateDescription<TupleDesc_F64> createAlg() {
	// exhaustive algorithm will produce perfect results
	NearestNeighbor<Integer> exhaustive = FactoryNearestNeighbor.exhaustive();
	AssociateNearestNeighbor<TupleDesc_F64> alg = new AssociateNearestNeighbor<TupleDesc_F64>(exhaustive,1);
	return alg;
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:8,代码来源:TestAssociateNearestNeighbor.java

示例3: kdRandomForest

import org.ddogleg.nn.FactoryNearestNeighbor; //导入依赖的package包/类
/**
 * Approximate association using multiple random K-D trees (random forest) for descriptors with a high degree of
 * freedom, e.g. > 20
 *
 * @see AssociateNearestNeighbor
 * @see org.ddogleg.nn.wrap.KdForestBbfSearch
 *
 * @param dimension Number of elements in the feature vector
 * @param maxNodesSearched  Maximum number of nodes it will search.  Controls speed and accuracy.
 * @param numTrees Number of trees that are considered.  Try 10 and tune.
 * @param numConsiderSplit Number of nodes that are considered when generating a tree.  Must be less than the
 *                         point's dimension.  Try 5
 * @param randomSeed Seed used by random number generator
 * @return Association using approximate nearest neighbor
 */
public static AssociateDescription<TupleDesc_F64> kdRandomForest( int dimension,
																  int maxNodesSearched ,
																  int numTrees ,
																  int numConsiderSplit ,
																  long randomSeed) {
	NearestNeighbor nn = FactoryNearestNeighbor.kdRandomForest(
			maxNodesSearched,numTrees,numConsiderSplit,randomSeed);

	return new AssociateNearestNeighbor<TupleDesc_F64>(nn,dimension);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:26,代码来源:FactoryAssociation.java

示例4: kdtree

import org.ddogleg.nn.FactoryNearestNeighbor; //导入依赖的package包/类
/**
 * Approximate association using a K-D tree degree of moderate size (10-15) that uses a best-bin-first search
 * order.
 *
 * @see AssociateNearestNeighbor
 * @see org.ddogleg.nn.alg.KdTreeSearchBbf
 *
 * @param dimension Number of elements in the feature vector
 * @param maxNodesSearched  Maximum number of nodes it will search.  Controls speed and accuracy.
 * @return Association using approximate nearest neighbor
 */
public static AssociateDescription<TupleDesc_F64> kdtree( int dimension, int maxNodesSearched ) {
	NearestNeighbor nn = FactoryNearestNeighbor.kdtree(maxNodesSearched);

	return new AssociateNearestNeighbor<TupleDesc_F64>(nn,dimension);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:17,代码来源:FactoryAssociation.java


注:本文中的org.ddogleg.nn.FactoryNearestNeighbor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。