Camera
Camera is a device module in SweepMe!. It acquires images from cameras, for example to document a setup or a sample during a measurement. At each measurement point, the driver captures an image, saves it as a file, and returns the path of the file as a variable.
Available drivers can be found at sweep-me.net/devices.
Overview
The Camera module offers a common set of fields for cameras, e.g. gain, exposure time, white balance, and region of interest. Which fields are enabled and which options the drop-down menus offer is defined by the selected driver. Fields that the driver does not support are disabled. Further driver-specific settings appear in the Parameters box.
The module returns the path of the image file. The image itself can be shown on the dashboard with the Image widget or processed with the ImageProcessing module.
Usage
- Add the Camera module to your sequence (called setting in version 1.5) and select the driver of your camera.
- Press "Find Ports" and select your camera in the field "Port:".
- Set the acquisition options that the driver supports, e.g. trigger, gain, exposure time, and file format.
- Optionally, reduce the image size with the fields in the section "Region of interest".
- Press "Test" to capture a single image and check exposure, focus, and image section before the measurement.
- To see the images during the run, add an Image widget to the dashboard, double-click it, and select the image path variable of the Camera module.
- Run the measurement. An image is captured at each measurement point of the branch.
Selecting one of several cameras
If several cameras are connected to the computer, you choose the camera with the field "Port:". Press "Find Ports" to let the driver list the cameras it finds, and select one of them. The field is editable, so you can also type the value directly. What is listed depends on the driver:
| Driver | Entries in "Port:" | Notes |
|---|---|---|
| Camera-PC_Webcam | Numbers 0, 1, 2, ... |
The numbers follow the order in which Windows lists the cameras. 0 is usually the built-in camera of a laptop. The order can change when cameras are plugged in or out, so check the selection after you reconnect a camera.
|
| Camera-Basler_pylon | Model names of the connected cameras | If two cameras of the same model are connected, only one of them is listed. |
| Camera-FormFactor_Velox | localhost or the address of the computer running Velox |
The camera itself is selected in the field "Camera" of the Parameters box. |
Use the button "Test" to take a test image and check that the right camera is selected.
To record images with several cameras in one measurement, add one Camera module for each camera to the Sequencer and select a different port in each module.
GUI parameters
General
- Driver: The driver of the camera. "Open driver" opens the code of the driver in an editor.
- Port: The camera to use, e.g. a camera name or an address. Press "Find Ports" to let the driver search for connected cameras.
Sweep
- Sweep mode: The quantity that is varied, as offered by the driver, e.g. "None", "Exposure time in s", or "Gain". If the driver only offers "None", the field is disabled.
- Sweep value: The source of the sweep values. The Camera module has no own SweepEditor, so the values are taken from a variable of another module or from the sweep value of a parent module in the Sequencer. The field is disabled if the Sweep mode is "None".
File
- File: Read-only field that shows the path of the image captured with the button "Test".
- Test: See Buttons.
Acquisition
- Trigger: Trigger mode of the camera, e.g. "Software". The options depend on the driver.
- Auto gain: Automatic gain mode. The options depend on the driver.
- Gain: Gain of the camera.
- Auto exposure: Automatic exposure mode. The options depend on the driver.
- Exposure time in s: Exposure time of a single image in seconds.
- Aperture: Aperture of the lens.
- ISO: ISO sensitivity.
- Pixel format: Pixel format of the camera, e.g. color or monochrome with a certain bit depth. The options depend on the driver.
- File format: File format of the saved image, e.g. "jpg", "png", "bmp", or "tiff". The options depend on the driver.
Image
- Preset: A driver-specific preset, e.g. for the white balance.
- Gamma: Gamma correction.
- Balance ratio red:, Balance ratio green:, Balance ratio blue: White balance factors of the color channels.
- Compensation: Exposure compensation.
Region of interest
- Image width in px: Width of the captured image in pixels.
- Image height in px: Height of the captured image in pixels.
- Image offset x in px: Horizontal offset of the region of interest in pixels.
- Image offset y in px: Vertical offset of the region of interest in pixels.
The sections Acquisition, Image, and Region of interest can be expanded and collapsed with their check boxes. The numeric fields of these sections accept numbers greater than or equal to 0.
Parameters
Further driver-specific settings are shown in the Parameters box, for example the camera, a camera mode, or a custom file name. The box is only visible if the driver defines such parameters. It is disabled while a measurement is running. The Parameters box and the current set of camera fields are available from version 1.5.6.18.
Processing
- Keep only last image: If checked, the image file of the previous measurement point is deleted as soon as the next measurement point has been processed, so that only the latest image remains on disk. Use this option if you only need the image during the run, e.g. to display it in an Image widget, and want to save disk space. The deleted files cannot be restored.
Buttons
- Find Ports: Lets the driver search for connected cameras and fills the field "Port:".
- Test: Runs the driver once like a single measurement point, from connecting to disconnecting the camera. While the image is captured, the field "File:" shows "Capturing image ...". Afterwards, the field shows the path of the image and the image opens in a preview window, if the file format can be displayed (jpg, jpeg, png, bmp, pbm, pgm, ppm, xbm, xpm, svg, tiff, tif). If no image could be captured, the field shows "Error: No image captured" and the Debug widget contains further information.
Variables
The variables are defined by the driver. The first variable is the path of the saved image file, e.g. "path" or "image path". Some drivers return further variables, e.g. "Exposure time" in s or "Gain" if these quantities are varied with the Sweep mode.
Where the image file is saved is defined by the driver. Many drivers use the temporary folder of SweepMe!, see Folder system.
Applications
- Visual documentation of the setup and the samples during a measurement
- Verification of probe or sample positions
- Defect documentation of failed components
- Imaging at multiple sample positions together with a Robot or WaferProber module
- Surface imaging during temperature or environmental tests
Driver programming
This section is for developers of Camera drivers. See Driver Programming for the general concept. The drivers Camera-Basler_pylon and Camera-PC_Webcam in the instrument-drivers repository are good examples.
GUI parameter keys
A driver enables a field by returning its key in set_GUIparameter() or update_gui_parameters(). A list creates the options of a drop-down menu, a single value sets the default value. The values selected by the user are handed over in get_GUIparameter() or apply_gui_parameters().
| Field | Key | Typical value in the driver |
|---|---|---|
| Port: | Port |
handed over only, ports come from find_ports()
|
| Sweep mode: | SweepMode |
list of str, e.g. ["None", "Exposure time in s", "Gain"]
|
| Trigger: | Trigger |
list of str |
| Auto gain: | GainAuto |
list of str |
| Gain: | Gain |
float |
| Auto exposure: | ExposureAuto |
list of str |
| Exposure time in s: | ExposureTime |
float |
| Aperture: | Aperture |
float |
| ISO: | ISO |
float |
| Pixel format: | PixelFormat |
list of str |
| File format: | FileFormat |
list of str, e.g. ["jpg", "png"]
|
| Preset: | Preset |
list of str |
| Gamma: | Gamma |
float |
| Balance ratio red: | BalanceRatioRed |
float |
| Balance ratio green: | BalanceRatioGreen |
float |
| Balance ratio blue: | BalanceRatioBlue |
float |
| Compensation: | Compensation |
float |
| Image width in px: | ImageWidth |
int |
| Image height in px: | ImageHeight |
int |
| Image offset x in px: | ImageOffsetX |
int |
| Image offset y in px: | ImageOffsetY |
int |
| Keep only last image: | KeepLast |
bool, always enabled |
Any other key is shown in the Parameters box. The type of the default value defines the input field: bool creates a check box, int and float a number field, str a text field, list an editable drop-down menu, and pathlib.Path a button to select a file or folder.
Variables and functions
call()must return the path of the saved image file as the first value. The button "Test" and the option "Keep only last image" use this path.- If the driver offers a Sweep mode, the current sweep value is available as
self.valueinapply(). self.tempfoldercontains the path of the temporary folder of SweepMe! and can be used to save the images.- The button "Test" calls all functions of the Sequencer procedure of a single measurement point, from
connect()todisconnect().
See also
- Image: widget to display images
- ImageProcessing: module to process images
- Spectrometer
- Robot
- WaferProber