b = image_name.takePhoto(ʃmessageʅ);
The
Image.takePhoto function takes a photo using a device's camera and stores the photo in the
Image object. This function only works on Android devices. The camera UI includes two options:
- Flip camera icon: Tap to toggle between the front and rear-facing camera.
- Camera icon: Tap to take the photo.
The optional string expression message will appear on the Android device's screen while the camera is active. The string will not be saved to the image.
The function returns a logical value of 1 (
true) if a photo was successfully taken and 0 (
false) if there was an error taking a photo or if the operator canceled the operation.
Image roof_photo;
if roof_photo.takePhoto("Take a photo of the household's roof.") then
// in case the device's camera takes photos with an unnecessarily
// large resolution, resample the image to a more reasonable size
roof_photo.resample(maxWidth := 1600, maxHeight := 1200);
// save the image using the household key...
string base_filename = Path.concat(application, "Roof Photos", key(HH_DICT));
// ...with 90 quality to prevent the JPEG from being too large
roof_photo.save(base_filename + ".jpg", quality := 90);
endif;