• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
        • Image Statement
        • Image.load Function
        • Image.save Function
        • Image.width Function
        • Image.height Function
        • Image.resample Function
        • Image.createQRCode Function
        • Image.takePhoto Function
        • Image.captureSignature Function
        • Image.view Function
        • Image.clear Function
      • List Object
      • Map Object
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Image.takePhoto Function

Format
b = image_name.takePhoto(ʃmessageʅ);
Description
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 aspect ratio of photos taken using the Android device's camera can be modified using the CSEntry.Setting.CameraAspectRatio setting.
Return Value
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.
Example
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;
See also: Image Object, Image.captureSignature Function