org.ddogleg.struct.FastQueue Java Examples

The following examples show how to use org.ddogleg.struct.FastQueue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageDesc.java    From MtgDesktopCompanion with GNU General Public License v3.0 6 votes vote down vote up
public static FastQueue<BrightFeature> readDescIn(ByteBuffer buf,DetectDescribePoint<GrayF32,BrightFeature> ddp)
{
	FastQueue<BrightFeature> d = UtilFeature.createQueue(ddp,0);
	int dts = buf.getInt();
	for(int i=0;i<dts;i++)
	{
		int vs = buf.getInt();
		BrightFeature f = new BrightFeature(vs);
		double[] vls = new double[vs];
		for(int j=0;j<vs;j++)
		{
			vls[j]=buf.getDouble();
		}
		f.set(vls);
		d.add(f);
	}
	return d;
}
 
Example #2
Source File: ImageDesc.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
public void writeDescOut(DataOutputStream out, FastQueue<BrightFeature> d) throws IOException
{
	out.writeInt(d.data.length);
	for(BrightFeature ft:d.data)
	{
		out.writeInt(ft.value.length);
		for(double val:ft.value)
		{
			out.writeDouble(val);
		}
	}
}
 
Example #3
Source File: Vision.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #4
Source File: ImageDesc.java    From MtgDesktopCompanion with GNU General Public License v3.0 4 votes vote down vote up
public ImageDesc(FastQueue<BrightFeature> d, AverageHash h)
{
	desc = d;
	hash = h;
}
 
Example #5
Source File: ImageDesc.java    From MtgDesktopCompanion with GNU General Public License v3.0 4 votes vote down vote up
public static ImageDesc readIn(ByteBuffer buf)
{
	FastQueue<BrightFeature> d = readDescIn(buf,detDesc);
	AverageHash h = AverageHash.readIn(buf);
	return new ImageDesc(d,h);
}
 
Example #6
Source File: ImageDesc.java    From MtgDesktopCompanion with GNU General Public License v3.0 4 votes vote down vote up
private void describeImage(GrayF32 input, FastQueue<BrightFeature> descs) {
	detDesc.detect(input);
	for (int i = 0; i < detDesc.getNumberOfFeatures(); i++) {
		descs.grow().setTo(detDesc.getDescription(i));
	}
}