The DB Image and Variable Image controls can be used with the PROPERTY command to capture images from any camera in order to save the image in a table.
After assigning a Component ID to the control, and adding the below PROPERTY command to any of the "On Click", "On Double Click", or "On Right Click" Custom EEPs, A dialog will be displayed.
Syntax:
PROPERTY ComponentID CapturefromVideoEx 'ImageFormat MaximumWidth MaximumHeight'
The CaptureFromVideoEx parameter will display a dialog window to take a picture from any Windows camera. The "Ex" in CaptureFromVideoEx signifies the expanded functionality to capture an image by accepting an image format type, maximum width, and maximum height. The second value for maximum width and third value for maximum height are optional.
Please note that the possible numeric portions of the parameters are a "maximum" value, and not the target value. If the width of the source is smaller, then that size will be used. If the width of the source is larger, then it will be resized to the specified maximum width. If no numeric parameter is passed, then no resizing will occur. Valid formats for the image type are BMP, JPG, and PNG. BMP is the default.
The ability to individually specify a maximum width or maximum height, or both, provides the ability to resize the image so that the final image fits inside the given dimension while preserving the aspect ratio. Depending on the specified value pair, sometimes the width will be the limiting factor, and sometimes it will be the height.
To capture a JPG image with a maximum width of 350 pixels use the following:
PROPERTY EmployeePhoto CapturefromVideoEx 'JPG 350'
To capture a JPG image, and keep whatever size the source provides, use the following:
PROPERTY EmployeePhoto CapturefromVideoEx 'JPG'
If you wish to capture a PNG image with a maximum height of 200 pixels, use the following:
PROPERTY EmployeePhoto CaptureFromVideoEx 'PNG 0 200'
If you wish to capture a PNG image with a maximum width and height of 100 pixels, use the following:
PROPERTY EmployeePhoto CaptureFromVideoEx 'PNG 100 100'
Notes:
•The options displayed will be dependent on the current camera hardware to capture a photo.
•The DB Image column must use the VARBIT data type, or the Variable Image control must use the VARBIT data type.
•After the device is selected, the supported resolutions are listed in a drop-down on the right. If a dimension is specified with CaptureFromVideoEx, the resolution size options are hidden. If no size option is specified, then the drop-down will be displayed.
•The form control cannot be set to read only.
•The "Low Resolution View Finder" property for the DB Image and Variable Image controls is available to specify the camera capture functionality will use a low-resolution feed for the view finder, but still take a picture using the target resolution. The option makes the camera more responsive. Note that when this property is checked (True), there will be a slight pause in the view finder when the picture is taken. This is because the camera will reset to the target resolution and take the actual picture.
•The PHOTOCAPTURED property for the GETPROPERTY command can be used to verify if a photo was captured successfully. The property should be used after the using CaptureFromVideoEx. The returned value is True/False.
GETPROPERTY EmployeeImage PHOTOCAPTURED vCapturedOK
Cameras and Resolution
Properties for the Variable/DB Image controls also include the ability to capture available cameras, and set the active camera, as well as a property to capture/set the default resolution of the video feed.
GETPROPERTY ImageCtrl DeviceCameras vCameras
Returns a comma separated list of attached camera devices. The functionality allows an application to create a custom camera selection for the user.
GETPROPERTY ImageCtrl DefaultCamera vCamera
Returns the last camera used to take a picture. If a picture has not been taken yet, this returns the first devices detected.
PROPERTY ImageCtrl DefaultCamera .vCamera
Sets the active camera for taking a picture.
GETPROPERTY ImageCtrl DefaultResolution 'vCameraRes'
Returns the default resolution of the camera.
PROPERTY ImageCtrl DefaultResolution .vCameraRes
Sets the default resolution for the active camera.