Using the cameraControl

The cameraControl object is a native camera control that displays a preview image from the current camera device.

Creating a cameraControl

A cameraControl is created using the cameraControlCreate command.

cameraControlCreate "myCamera"
Click to copy

Camera Control Properties

The properties of the cameraControl are then set using the cameraControlSet command. The most basic properties that need to be set are the rect and device.

cameraControlSet "myCamera", "rect", the rect of graphic "cameraArea"
cameraControlSet "myCamera", "videoDevice", "default"
Click to copy

The full list of cameraControl properties is

  • "rect": the bounds of the control, relative to the top-left of the card. For example "0,0,100,100".
  • "visible": set to true or false to determine whether the control should be displayed.
  • "device": Specifies which camera device to use.
    • "default":
    • "front":
    • "back":
  • "videoDevice": Specifies the device to use for video input:
    • "default": Use the default video input device.
    • "front": (MacOS X, iOS, Android) Use the front-facing video input device (if available).
    • "back": (MacOS X, iOS, Android) Use the rear-facing video input device (if available).
    • "": No video recording - any recorded media file will have no video component.
    • : Use the device identified by the given device ID. This should be taken from one of the entries in the "videoDevices" property.
  • "audioDevice": Specifies the device to use for audio input:
    • "default": Use the default audio input device.
    • "": No audio recording - any recorded media file will have no audio component.
    • : Use the device identified by the given device ID. This should be taken from one of the entries in the "audioDevices" property.
  • "flashMode": Specifies whether or not to use the camera flash.
    • "on": Always use the camera flash.
    • "off": Never use the camera flash.
    • "auto": Let the camera hardware decide whether or not to use the camera flash.
  • "exposureMode": Specifies how the exposure of the camera should be adjusted.
    • "locked": Don't adjust the camera exposure.
    • "auto": Make an automatic adjustment to the camera exposure when capturing begins.
    • "continuous": Make continuous automatic adjustments to the camera exposure during capture.
  • "focusMode": Specifies how the focus of the camera should be adjusted.
    • "locked": Don't adjust the camera focus.
    • "auto": Make an automatic adjustment to the camera focus when set.
    • "autoSmooth": Make a gradual automatic adjustment to the camera focus when set.
    • "macro": Make an automatic adjustment to the camera focus when set, focusing on objects close to the camera.
    • "macroSmooth": Make a gradual automatic adjustment to the camera focus when set, focusing on objects close to the camera.
    • "infinity": Set the camera focal point to the maximum distance. Typically used to photograph distant objects.
    • "continuous": Make continuous automatic adjustments to the camera focus during capture.
    • "continuousSmooth": Continuously adjust the focus making gradual changes that are less noticeable during video capture.
    • "extended": Allows for a greater distance between the farthest & nearest objects that remain in focus.
  • "whitebalanceMode": Specifies how the white-balance of the camera should be adjusted.
    • "locked": Don't adjust the white-balance focus.
    • "auto": Make an automatic adjustment to the camera white-balance when capturing begins.
    • "continuous": Make continuous automatic adjustments to the camera white-balance during capture.
  • "qualityPreset" : Specifies which of the available preset camera quality settings to use.
  • "minFrameRate" : Request that the camera not use a recording framerate lower than the given value. Set to zero to remove this restriction.
  • "maxFrameRate" : Request that the camera not use a recording framerate higher than the given value. Set to zero to remove this restriction.
  • "zoomFactor" : Specifies the magnification of the camera.

Camera Control Actions

To take a picture or start and stop recording video you use the cameraControlDo command.

When using the takePicture action the picture is returned in the result as jpeg data.

cameraControlDo "myCamera", "takePicture"
put the result into tResult
set the text of image "snapshot" to tResult

When using the startRecording action the video is recorded to the  output file specified in the actionParameter parameter. This will be in WMV format on Windows, and MPEG4 on all other platforms.

cameraControlDo tCameraControlName, "startRecording", specialFolderPath("desktop") & "/video.mp4"
Click to copy

2 Comments

riko

if i want to use webrtc in lc version 9.6.3rc1. using the command "cameraControlCreate" ? can you share how to use webrtc in livecode. Thanks

Panos Merakos

Hello Riko,

WebRTC support was added for CEF in the browser widget in LC 9.6.3 rc1. This essentially means that the browser widget on Windows can now access the device camera and microphone. This feature is not related to the command "cameraControlCreate".
Hope this helps.
Kind regards,
Panos
--

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.