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

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:

  1. Use the StartCaptureResponse class
    The StartCaptureResponse class explained in sections above provides a Capture type property called Capture.
    StartCaptureResponse startCaptureResponse = cameraDevice.StartCapture();
    if (startCaptureResponse.Result == Result.OK)
    {
     Console.WriteLine("Capture state is {0}",
         startCaptureResponse.Capture.State);
    }
    
  2. Use the CameraDevice class
    The CameraDevice class has a CameraStatus property called Status. The CameraStatus class provides a Capture property called CurrentCapture.
    StartCaptureResponse startCaptureResponse = cameraDevice.StartCapture();
    if (startCaptureResponse.Result == Result.OK)
    {
     Console.WriteLine("Capture state is {0}",
         cameraDevice.Status.CurrentCapture.State);
    }
    
  3. Use the CameraEventListener class
    The CaptureComplete method of the CameraEventListener 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 and ImageAdded.