Created
June 12, 2013 07:57
-
-
Save zonski/5763540 to your computer and use it in GitHub Desktop.
A simple stress test of LTI CIVIL. On Windows the system bombs out after around 500 iterations of the loop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.lti.civil.*; | |
import java.util.List; | |
public class LtiCivilTest { | |
public static void main(String[] args) throws Exception { | |
System.out.println("Testing LTI CIVIL"); | |
System.out.println("Creating Capture System"); | |
CaptureSystemFactory factory = DefaultCaptureSystemFactorySingleton.instance(); | |
CaptureSystem system = factory.createCaptureSystem(); | |
System.out.println("Initialising Capture system"); | |
system.init(); | |
List devices = system.getCaptureDeviceInfoList(); | |
CaptureDeviceInfo deviceInfo = (CaptureDeviceInfo) devices.get(devices.size() - 1); | |
System.out.println("Using Capture Device: " + deviceInfo.getDescription()); | |
CaptureHandler captureHandler = new CaptureHandler(); | |
int count = 0; | |
while (true) { | |
System.out.println("Opening Capture Stream"); | |
CaptureStream captureStream = system.openCaptureDeviceStream(deviceInfo.getDeviceID()); | |
captureHandler.numImages = 0; | |
captureStream.setObserver(captureHandler); | |
System.out.println("Starting Capture Stream"); | |
captureStream.start(); | |
System.out.println("Letting camera run for a few seconds"); | |
Thread.sleep(2000); | |
System.out.println("Captured " + count + " images while active"); | |
System.out.println("Stopping Capture Stream"); | |
captureStream.stop(); | |
System.out.println("Disposing Capture Stream"); | |
captureStream.dispose(); | |
System.out.println("========================= Completed test # " + count++ + " ========================================"); | |
} | |
} | |
//------------------------------------------------------------------------- | |
private static class CaptureHandler implements CaptureObserver { | |
public int numImages; | |
public void onNewImage(CaptureStream captureStream, Image image) { | |
numImages++; | |
} | |
public void onError(CaptureStream captureStream, CaptureException e) { | |
System.out.println("Error during capture: " + e); | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment