Capture
This page shows how to capture images with connected camera device using RICOH Camera Wireless SDK. RICOH Camera Wireless SDK supports single frame shooting.
Depending on the model, there are some captures not supported.
When not supported capture is started, UnsupportedOperationException
is thrown.
Contents
- Related Classes
- How to Capture Still Images
- How to Focus and Capture Still Images
- How to Check Capture Status
- How to Obtain Captured Image
- See Also
Related Classes
The following interfaces and classes are used when you capture images:
CameraImage
- The
CameraImage
interface represents image information and image data. - This interface includes methods for obtaining image information and image data.
CameraEventListener
- The
CameraEventListener
class is a event listener which receives notifications from camera devices.
Capture Still Images
Use the startCapture
method with CaptureMethod.STILL_IMAGE
to capture still image with connected camera device.
CaptureMethod captureMethod = new CaptureMethod();
Response response =
cameraDevice.getCaptureSettings(
Arrays.asList((CaptureSetting) captureMethod));
if (response.getResult() == Result.ERROR) {
return;
}
if (CaptureMethod.STILL_IMAGE.equals(captureMethod) == false) {
List<CaptureSetting> availableList = captureMethod.getAvailableSettings();
if (availableList.contains(CaptureMethod.STILL_IMAGE)) {
response = cameraDevice.setCaptureSettings(
Arrays.asList((CaptureSetting) CaptureMethod.STILL_IMAGE));
if (response.getResult() == Result.ERROR) {
return;
}
} else {
System.out.println("Capturing StillImage is not available.");
return;
}
}
StartCaptureResponse startCaptureResponse = null;
try {
startCaptureResponse = cameraDevice.startCapture(true);
} catch (UnsupportedOperationException e) {
System.out.println("Capturing StillImage is not supported.");
return;
}
if (startCaptureResponse.getResult() == Result.OK) {
System.out.printf("Capturing StillImage has started. Capture ID: %s%n",
startCaptureResponse.getCapture().getId());
} else {
System.out.printf("Capturing StillImage is FAILED. detail: %s%n",
startCaptureResponse.getErrors().get(0).getMessage());
}
Focus and Capture Still Images
If you want to capture images after focusing, use the focus
method and the startCapture
method with the withFocus argument false.
Response response = null;
try {
response = cameraDevice.focus();
} catch (UnsupportedOperationException e) {
System.out.println("Focus is not supported.");
return;
}
if (response.getResult() == Result.OK) {
System.out.println("Focus has started.");
} else {
System.out.printf("Focus is FAILED. detail: %s%n",
response.getErrors().get(0).getMessage());
return;
}
CaptureMethod captureMethod = new CaptureMethod();
response = cameraDevice.getCaptureSettings(
Arrays.asList((CaptureSetting) captureMethod));
if (response.getResult() == Result.ERROR) {
return;
}
if (CaptureMethod.STILL_IMAGE.equals(captureMethod) == false) {
List<CaptureSetting> availableList = captureMethod.getAvailableSettings();
if (availableList.contains(CaptureMethod.STILL_IMAGE)) {
response = cameraDevice.setCaptureSettings(
Arrays.asList((CaptureSetting) CaptureMethod.STILL_IMAGE));
if (response.getResult() == Result.ERROR) {
return;
}
} else {
System.out.println("Capturing StillImage is not available.");
return;
}
}
StartCaptureResponse startCaptureResponse = null;
try {
startCaptureResponse = cameraDevice.startCapture(false);
} catch (UnsupportedOperationException e) {
System.out.println("Capturing StillImage is not supported.");
return;
}
if (startCaptureResponse.getResult() == Result.OK) {
System.out.printf("Capturing StillImage has started. Capture ID: %s%n",
startCaptureResponse.getCapture().getId());
} else {
System.out.printf("Capturing StillImage is FAILED. detail: %s%n",
startCaptureResponse.getErrors().get(0).getMessage());
}
Check Capture Status
Use the CaptureState
returned the getState
method of the Capture
interface to check capture status.
One of the supported values of the status is Complete
, which means the camera device has finished capturing.
You can obtain the Capture
class with the three ways below:
- Use the
StartCaptureResponse
class
The StartCaptureResponse
class explained in sections above provides a Capture
called getCapture
.
StartCaptureResponse startCaptureResponse = cameraDevice.startCapture(false);
if (startCaptureResponse.getResult() == Result.OK) {
Capture capture = startCaptureResponse.getCapture();
System.out.printf("Capture state is %s%n", capture.getState());
}
- Use the
CameraDevice
class
The CameraDevice
class has a CameraStatus
called getStatus
.
The CameraStatus
class provides a Capture
called getCurrentCapture
.
Capture currentCapture = cameraDevice.getStatus().getCurrentCapture();
if (currentCapture != null) {
System.out.printf("Capture state is %s%n", currentCapture.getState());
}
- Use the
CameraEventListener
class
The captureComplete
method of the CameraEventListener
class is invoked when the camera device has finished capturing.
class UserEventListener extends CameraEventListener {
// Capture Complete
@Override
public void captureComplete(CameraDevice sender, Capture capture) {
System.out.printf("Capture Complete. Caputure ID: %s%n", capture.getId());
}
}
Obtain Captured Image
Use the imageStored
method of the CameraEventListener
class to obtain the image you captured.
class UserEventListener extends CameraEventListener {
// Image Stored
@Override
public void imageStored(CameraDevice sender, CameraImage image) {
System.out.printf("Image Stored. Image Name: %s%n", image.getName());
}
}
See Also
- Image Handling - Demonstrates image acquisition.
- Capture Settings - Describes available capture settings such as capturing without saving data on camera storage.
- Events - Describes events such as
captureComplete
andimageStored
.