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
CameraImageclass represents image information and image data. - This class includes methods for obtaining image information and image data.
CameraEventListener
- The
CameraEventListenerclass 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.getResult() == Result::Ok) {
std::cout << "Capturing StillImage has started. Capture ID: "
<< startCaptureResponse.getCapture()->getId()
<< std::endl;
} else {
std::cout << "Capturing StillImage is FAILED. detail: "
<< startCaptureResponse.getErrors()[0]->getMessage()
<< std::endl;
}
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.getResult() == Result::Ok) {
std::cout << "Focus has started." << std::endl;
} else {
std::cout << "Focus is FAILED. detail: "
<< response.getErrors()[0]->getMessage() << std::endl;
}
bool withFocus = false;
StartCaptureResponse response = cameraDevice->startCapture(withFocus);
if (response.getResult() == Result::Ok) {
std::cout << "Capturing StillImage without focus has started. Capture ID: "
<< response.getCapture()->getId() << std::endl;
} else {
std::cout << "Capturing StillImage without focus is FAILED. detail: "
<< response.getErrors()[0]->getMessage() << std::endl;
}
Check Capture Status
Use the getState method of the Capture class to check capture status. One of the supported values is Complete, which means the camera device has finished capturing.
You can obtain the Capture class with the three ways below:
- Use the
StartCaptureResponseclassStartCaptureResponse startCaptureResponse = cameraDevice->startCapture(); if (startCaptureResponse.getResult() == Result::Ok) { std::cout << "Capture state is " << startCaptureResponse.getCapture()->getState() << std::endl; } - Use the
CameraStatusclassStartCaptureResponse startCaptureResponse = cameraDevice->startCapture(); if (startCaptureResponse.getResult() == Result::Ok) { std::cout << "Capture state is " << cameraDevice->getStatus().getCurrentCapture()->getState() << std::endl; } - Use the
captureCompletemethod of theCameraEventListenerclassclass UserEventListener : public CameraEventListener { public: void captureComplete(const std::shared_ptr<const CameraDevice>& sender, const std::shared_ptr<const Capture>& capture) override { std::cout << "Capture Complete. Capture ID: " << capture->getId() << std::endl; } };
Obtain Captured Image
Use the imageAdded method of the CameraEventListener class to obtain the image you captured.
class UserEventListener : public CameraEventListener {
public:
void imageAdded(const std::shared_ptr<const CameraDevice>& sender,
const std::shared_ptr<const CameraImage>& image) override
{
std::string filename = image->getName();
std::ofstream o;
o.open(filename, std::ofstream::out | std::ofstream::binary);
Response res = image->getData(o);
o.close();
std::cout << "Get Image is "
<< (res.getResult() == Result::Ok ? "SUCCEED." : "FAILED.")
<< std::endl;
}
};
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
captureCompleteandimageAdded.