@Test
public void testDcamSequenceAcquisition() throws InterruptedException,
IOException
{
final DcamAcquisition lDcamAcquisition = new DcamAcquisition(0);
final int lNumerOfDcamFrames = 4;
final int lNumberOfIterations = 10;
final int lNumberOfFramesToCapture = 10;
final int lImageResolution = 512;
lDcamAcquisition.setFrameWidthAndHeight(lImageResolution,
lImageResolution);
lDcamAcquisition.setExposureInSeconds(0.0001);
if (!lDcamAcquisition.open())
{
lDcamAcquisition.close();
return;
}
lDcamAcquisition.getProperties().setOutputTriggerToProgrammable();
final long lBufferCapacity = lDcamAcquisition.getBufferControl()
.computeTotalRequiredMemoryInBytes(lNumberOfFramesToCapture);
System.out.format("RequiredMemory is: %d MB \n",
lBufferCapacity / 1000000);
assertTrue(lDcamAcquisition.getBufferControl()
.allocateInternalBuffers(lNumberOfFramesToCapture));
final DcamFrame[] lDcamFrameArray = new DcamFrame[lNumerOfDcamFrames];
for (int i = 0; i < lNumerOfDcamFrames; i++)
lDcamFrameArray[i] = new DcamFrame( 2,
lImageResolution,
lImageResolution,
lNumberOfFramesToCapture);
lDcamFrameCounter = 0;
lDcamAcquisition.addListener(new DcamAcquisitionListener()
{
@Override
public void frameArrived( final DcamAcquisition pDcamAquisition,
final long pAbsoluteFrameIndex,
final long pArrivalTimeStamp,
final long pFrameIndexInBuffer,
final DcamFrame pDcamFrame)
{
System.out.format("Frame %d of depth %d in buffer %d arrived at %d \n",
pAbsoluteFrameIndex,
pDcamFrame.getDepth(),
pFrameIndexInBuffer,
pArrivalTimeStamp);/**/
assertTrue(pDcamFrame.getDepth() != 1);
}
});
System.gc();
final StopWatch lStopWatch = StopWatch.start();
for (int i = 0; i < lNumberOfIterations; i++)
{
// System.out.println("ITERATION=" + i);
assertTrue(lDcamAcquisition.startAcquisition( false,
true,
lDcamFrameArray[lDcamFrameCounter]));
// lDcamAcquisition.stopAcquisition();
// Thread.sleep(1000);
lDcamFrameCounter = (lDcamFrameCounter + 1) % lNumerOfDcamFrames;
/*final DcamFrame lNewDcamFrame = lDcamFrameArray[lDcamFrameCounter];
lDcamAcquisition.getBufferControl()
.attachExternalBuffers(lNewDcamFrame);/**/
}
final long lTimeInSeconds = lStopWatch.time(TimeUnit.SECONDS);
final double lSpeed = lNumberOfIterations * lNumberOfFramesToCapture
/ (lTimeInSeconds);
System.out.format("acquisition speed: %g frames/s \n", lSpeed);
while (lDcamAcquisition.isAcquiring())
{
System.out.println(".");
Thread.sleep(100);
}
for (int j = 0; j < lNumerOfDcamFrames; j++)
for (int i = 0; i < lDcamFrameArray[j].getDepth(); i++)
{
final double average = computeAverageInBuffer(lDcamFrameArray[j].getPointerForSinglePlane(i));
System.out.format("avg=%g \n", average);
assertTrue(average != 0);
}
lDcamAcquisition.close();
}