Package dcamj

Examples of dcamj.DcamAcquisition


  @Test
  public void testDcamAcquisition()  throws InterruptedException,
                                    IOException
  {

    final DcamAcquisition lDcamAcquisition = new DcamAcquisition(0);

    lDcamAcquisition.addListener(new DcamAcquisitionListener()
    {

      @Override
      public void frameArrivedfinal DcamAcquisition pDcamAquisition,
                                final long pAbsoluteFrameIndex,
                                final long pArrivalTimeStamp,
                                final long pFrameIndexInBufferList,
                                final DcamFrame pDcamFrame)
      {
        System.out.format("Frame %d in buffer %d arrived at %d \n",
                          pAbsoluteFrameIndex,
                          pFrameIndexInBufferList,
                          pArrivalTimeStamp);
        System.out.println("frameArrived: hashcode=" + pDcamFrame.hashCode()
                            + " index="
                            + pDcamFrame.getIndex());
      }
    });

    lDcamAcquisition.open();
    lDcamAcquisition.getProperties().setOutputTriggerToProgrammable();
    lDcamAcquisition.startAcquisition();
    Thread.sleep(250);
    lDcamAcquisition.stopAcquisition();
    lDcamAcquisition.close();

  }
View Full Code Here


  @Test
  public void testDcamAcquisitionWithExternalTriggering()  throws InterruptedException,
                                                          IOException
  {

    final DcamAcquisition lDcamAcquisition = new DcamAcquisition(0);
    lDcamAcquisition.setTriggerType(TriggerType.ExternalEdge);
    lDcamAcquisition.setExposureInSeconds(0.001);

    lDcamAcquisition.addListener(new DcamAcquisitionListener()
    {

      @Override
      public void frameArrivedfinal DcamAcquisition pDcamAquisition,
                                final long pAbsoluteFrameIndex,
                                final long pArrivalTimeStamp,
                                final long pFrameIndexInBuffer,
                                final DcamFrame pDcamFrame)
      {
        System.out.format("Frame %d in buffer %d arrived at %d \n",
                          pAbsoluteFrameIndex,
                          pFrameIndexInBuffer,
                          pArrivalTimeStamp);
      }
    });

    lDcamAcquisition.open();

    System.out.format("Effective exposure is: %g s \n",
                      lDcamAcquisition.getExposureInSeconds());

    lDcamAcquisition.startAcquisition();

    Thread.sleep(5000);
    lDcamAcquisition.stopAcquisition();
    lDcamAcquisition.close();

  }
View Full Code Here

  @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 DcamFrame2,
                                          lImageResolution,
                                          lImageResolution,
                                          lNumberOfFramesToCapture);

    lDcamFrameCounter = 0;

    lDcamAcquisition.addListener(new DcamAcquisitionListener()
    {

      @Override
      public void frameArrivedfinal 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.startAcquisitionfalse,
                                                    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();

  }
View Full Code Here

TOP

Related Classes of dcamj.DcamAcquisition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.