use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.
the class TestGaliosFieldTableOps method polyDivide_S.
@Test
public void polyDivide_S() {
GaliosFieldTableOps alg = new GaliosFieldTableOps(8, primitive8);
// Create an arbitrary polynomial: 0BB*x^4 + 0x12*x^3 + 0x54*x^2 + 0*x + 0xFF
GrowQueue_I8 inputA = new GrowQueue_I8();
inputA.resize(5);
inputA.set(4, 0xBB);
inputA.set(3, 0x12);
inputA.set(2, 0x54);
inputA.set(0, 0xFF);
GrowQueue_I8 inputB = new GrowQueue_I8();
inputB.resize(2);
inputB.set(1, 0xF0);
inputB.set(0, 0x0A);
GrowQueue_I8 quotient = new GrowQueue_I8();
GrowQueue_I8 remainder = new GrowQueue_I8();
alg.polyDivide_S(inputA, inputB, quotient, remainder);
assertEquals(4, quotient.size);
assertEquals(1, remainder.size);
// see if division was done correct and reconstruct the original equation
checkDivision_S(alg, inputA, inputB, quotient, remainder);
// have the divisor be larger than the dividend
alg.polyDivide_S(inputB, inputA, quotient, remainder);
assertEquals(0, quotient.size);
assertEquals(2, remainder.size);
checkDivision_S(alg, inputB, inputA, quotient, remainder);
}
use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.
the class TestGaliosFieldTableOps method polyMult_flipA.
@Test
public void polyMult_flipA() {
GaliosFieldTableOps alg = new GaliosFieldTableOps(8, primitive8);
// Create an arbitrary polynomial: 0x12*x^2 + 0x54*x + 0xFF
GrowQueue_I8 inputA = new GrowQueue_I8();
inputA.resize(3);
inputA.set(2, 0x12);
inputA.set(1, 0x54);
inputA.set(0, 0xFF);
GrowQueue_I8 inputB = new GrowQueue_I8();
inputB.resize(2);
inputB.set(1, 0x03);
GrowQueue_I8 output0 = new GrowQueue_I8();
alg.polyMult_flipA(inputA, inputB, output0);
assertEquals(4, output0.size);
// check the value against a manual solution
GrowQueue_I8 expected = new GrowQueue_I8();
expected.resize(4);
expected.set(1, alg.multiply(0x12, 0x03));
expected.set(2, alg.multiply(0x54, 0x03));
expected.set(3, alg.multiply(0xFF, 0x03));
}
use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.
the class TestUtilOpenKinect method saveDepth_parseDepth.
@Test
public void saveDepth_parseDepth() throws IOException {
GrayU16 depth = new GrayU16(width, height);
ImageMiscOps.fillUniform(depth, rand, 0, 10000);
GrowQueue_I8 data = new GrowQueue_I8();
GrayU16 found = new GrayU16(width, height);
UtilOpenKinect.saveDepth(depth, "temp.depth", data);
UtilOpenKinect.parseDepth("temp.depth", found, data);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
int a = depth.get(j, i);
int b = found.get(j, i);
assertEquals(a, b);
}
}
// clean up
File f = new File("temp.depth");
assertTrue(f.delete());
}
use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.
the class ConvertOpenCvFrame method convert.
public static void convert(Frame input, ImageBase output, boolean swapRgb, GrowQueue_I8 work) {
if (work == null)
work = new GrowQueue_I8();
Buffer data = input.image[0];
if (!(data instanceof ByteBuffer)) {
return;
}
ByteBuffer bb = (ByteBuffer) data;
output.reshape(input.imageWidth, input.imageHeight);
if (output instanceof Planar) {
((Planar) output).setNumberOfBands(input.imageChannels);
ConvertByteBufferImage.from_3BU8_to_3PU8(bb, 0, input.imageStride, (Planar) output, work);
if (swapRgb) {
BGR_to_RGB((Planar) output);
}
} else if (output instanceof ImageGray) {
ConvertByteBufferImage.from_3BU8_to_U8(bb, 0, input.imageStride, (GrayU8) output, work);
} else if (output instanceof ImageInterleaved) {
ConvertByteBufferImage.from_3BU8_to_3IU8(bb, 0, input.imageStride, (InterleavedU8) output);
} else {
throw new IllegalArgumentException("Unsupported output type");
}
}
use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.
the class CombineFilesTogether method combine.
public static void combine(List<String> fileNames, String outputName) throws IOException {
FileOutputStream fos = new FileOutputStream(outputName);
GrowQueue_I8 buffer = new GrowQueue_I8();
for (String s : fileNames) {
File f = new File(s);
FileInputStream fis = new FileInputStream(f);
long length = f.length();
buffer.resize((int) length);
// write out header
fos.write(255);
fos.write(255);
fos.write(255);
fos.write((byte) (length >> 24));
fos.write((byte) (length >> 16));
fos.write((byte) (length >> 8));
fos.write((byte) (length));
fis.read(buffer.data, 0, (int) length);
fos.write(buffer.data, 0, (int) length);
}
}
Aggregations