The Camera object provides the interface for a PocketBuilder application and a digital camera device. PocketBuilder supports the HP Photosmart, VEO 130S, and HTC cameras.
To capture an image, you must first specify the camera you want to use by selecting the camera type in the Properties view for a Camera object or by setting a specifier for the camera type in script. You must also set the Port or the Folder property on the Camera object before opening a communication channel to the camera device.
Table 15-2 shows integer values that have been defined for supported camera types. It also shows the additional property you must set depending on your camera type selection.
Camera type |
Specifier |
Port or Folder property |
---|---|---|
VEO 130S |
11 |
Port (set to "SIO1:") |
HP Photosmart |
71 |
Port (set to "SIO1:") |
HTC using the IA Camera Wizard |
81 |
Folder (set to the path on the Windows CE device) |
For the HP Photosmart and VEO 130S cameras, the CameraImageAttributes structure object stores the configurations allowed by the camera device for capturing images, and lets you select those attributes when previewing or snapping a photographic image. The CameraImageAttributes object is a read-only structure containing valid configuration settings for a particular camera device. You call GetAllowedImageAttributes to retrieve an array of legal configuration settings for the device.
HTC cameras For HTC cameras, you must use the IA Camera Wizard to set configurations, and to preview and capture images. After setting the CameraType and Folder properties for the Camera object, then calling Open to open a communication channel to the camera, you can launch the IA Camera Wizard by calling BeginPreview.
Some cameras have different allowable configurations for preview and capture modes. (Some cameras do not even permit preview mode.) For example, the Hewlett-Packard Photosmart Mobile Camera has four different configurations for picture size in capture mode, but only two in preview mode.
Typically, a structure object you use for the preview mode will be different from the structure object for the capture mode of the same device, so there are separate functions to set the configuration for each mode, SetPreviewImageAttributes and SetCaptureImageAttributes.
The following example opens a camera session where cam_1 is an object of type camera. It uses the CameraType property to define the camera as an HP Photosmart device before calling the Open function. The example sets preview and capture configurations, previews the current image in a preview window, and captures the image to a file:
integer iRet
CameraImageAttributes AllowedConfigs[]
cam_1.CameraType = 71
cam_1.Port = "SIO:"
iRet = cam_1.Open(w_myphoto_main)
// Get allowed configurations for this specific camera.
cam_1.GetAllowedImageAttributes(AllowedConfigs[])
// Assume presented to the user, and the user
// makes some selections…
// Assume the user selects the first configuration for
// preview purposes and the third configuration for
// capture purposes
cam_1.SetPreviewImageAttributes & (AllowedConfigs[1])
cam_1.SetCaptureImageAttributes & (AllowedModes[3])
// set some other options, such as fluorescent
// white balance and center weighting for the
// AE meter
cam_1.SetOption(CamOptWhiteBalance, 3)
cam_1.SetOption(CamOptAEMetering, 1)
// When the user presses a button to begin preview mode,
// preview the image in the picture control "p_preview"
cam_1.BeginPreview( w_main.p_preview )
// When the user presses a button to capture the current
// picture, save the picture to the file "my_pic.jpg"
if cam_1.isReadyToCapture() then
cam_1.CaptureImage( "\my_pic.jpg" )
end if
// In the application Close event, end the preview and
// close the camera connection
cam_1.EndPreview()
cam_1.Close()