Still Image Capture
This page shows how to capture still images with connected camera device using RICOH Camera USB SDK.
The RICOH Camera USB SDK supports single frame capture among still image capture.
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 classes are used when you capture images:
CameraImage
- The
CameraImage
class represents image information and image data. - This class includes properties and 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 to release shutter of connected camera device.
StartCaptureResponse startCaptureResponse = cameraDevice.StartCapture();
if (startCaptureResponse.Result == Result.OK)
{
Console.WriteLine("Capturing StillImage has started. Capture ID: {0}",
startCaptureResponse.Capture.ID);
}
else
{
Console.WriteLine("Capturing StillImage is FAILED. detail: {0}",
startCaptureResponse.Errors[0].Message);
}
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 = cameraDevice.Focus();
if (response.Equals(Response.OK))
{
Console.WriteLine("Focus has started.");
}
else
{
Console.WriteLine("Focus is FAILED. detail: {0}",
response.Errors[0].Message);
}
bool withFocus = false;
StartCaptureResponse startCaptureResponse =
cameraDevice.StartCapture(withFocus);
if (startCaptureResponse.Result == Result.OK)
{
Console.WriteLine("Capturing StillImage has started. Capture ID: {0}",
startCaptureResponse.Capture.ID);
}
else
{
Console.WriteLine("Capturing StillImage is FAILED. detail: {0}",
startCaptureResponse.Errors[0].Message);
}
Check Capture Status
Use the State
property of the Capture
class to check capture status. One of the supported values of the property 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
TheStartCaptureResponse
class explained in sections above provides aCapture
type property calledCapture
.StartCaptureResponse startCaptureResponse = cameraDevice.StartCapture(); if (startCaptureResponse.Result == Result.OK) { Console.WriteLine("Capture state is {0}", startCaptureResponse.Capture.State); }
- Use the
CameraDevice
class
TheCameraDevice
class has aCameraStatus
property calledStatus
. TheCameraStatus
class provides aCapture
property calledCurrentCapture
.StartCaptureResponse startCaptureResponse = cameraDevice.StartCapture(); if (startCaptureResponse.Result == Result.OK) { Console.WriteLine("Capture state is {0}", cameraDevice.Status.CurrentCapture.State); }
- Use the
CameraEventListener
class
TheCaptureComplete
method of theCameraEventListener
class is invoked when the camera device has finished capturing.class UserEventListener : CameraEventListener { // Capture Complete public override void CaptureComplete(CameraDevice sender, Capture capture) { Console.WriteLine("Capture Complete. Capture ID: {0}", capture.ID); } }
Obtain Captured Image
Use the ImageAdded
method of the CameraEventListener
class to obtain the image you captured.
class UserEventListener : CameraEventListener
{
// Image Added
public override void ImageAdded(CameraDevice sender, CameraImage image)
{
// Get the image and save it in the current directory
using (FileStream fs = new FileStream(
Environment.CurrentDirectory + Path.DirectorySeparatorChar +
image.Name, FileMode.Create, FileAccess.Write))
{
Response imageGetResponse = image.GetData(fs);
Console.WriteLine("Get Image is " +
(imageGetResponse.Result == Result.OK ?
"SUCCEED." : "FAILED."));
}
}
}
See Also
- Movie Capture - Demonstrates how to capture movie images.
- 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
andImageAdded
.