upm/examples/java/SCAM_Example.java
Mihai Tudor Panu 89d5de43e0 license: update to SPDX style license text throughout
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2020-03-05 15:13:36 -08:00

54 lines
1.3 KiB
Java

/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* This program and the accompanying materials are made available under the
* terms of the The MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
*/
//NOT TESTED!!!
public class SCAM_Example {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Instantiate a Serial Camera on UART 0
upm_scam.SCAM camera = new upm_scam.SCAM(0);
// make sure port is initialized properly. 115200 baud is the default.
if (!camera.setupTty()) {
System.err.println("Failed to setup tty port parameters");
System.exit(-1);
}
if (camera.init())
System.out.println("Initialized...");
else
System.out.println("Initialization failed");
if (camera.preCapture())
System.out.println("preCapture succeeded...");
else
System.out.println("preCapture failed.");
if (camera.doCapture())
System.out.println("doCapture succeeded...");
else
System.out.println("doCapture failed.");
if (camera.getImageSize() > 0) {
System.out.println("Storing image.jpg...");
if (camera.storeImage("image.jpg"))
System.out.println("storeImage succeeded...");
else
System.out.println("storeImage failed.");
}
// ! [Interesting]
}
}