Capturing images from a camera

Setting up the hardware Camera drivers and connection: Camera setup on the PIVlab wiki.
Synchronizer and laser: Synchronizer setup on the PIVlab wiki.

PIVlab records PIV image pairs directly from a connected camera and, with a PIVlab synchronizer, triggers and times the pulsed laser to match. The recorded images go straight into the session, so you can analyse them without importing anything.

Open via Image acquisition → Capture PIV images, or the Acquire images button in the Input data panel. When you run PIVlab inside MATLAB, camera access needs the Image Acquisition Toolbox; the standalone PIVlab has it compiled in.

PIVlab Image Acquisition panel
The Image Acquisition panel — general settings, synchronizer control, camera settings, live image and PIV capture, all in one place.

Connecting the equipment

  1. Mount camera and laser, and aim them at the measurement area.
  2. Connect the synchronization cable from the synchronizer to the camera.
  3. Connect the camera to the computer.
  4. Connect the safety interlock (for example a door switch). Its contact has to be closed, otherwise the laser stays locked.
  5. Connect the power supply and switch the laser on.
  6. Plug in the USB wireless link — this is how PIVlab talks to the synchronizer.
  7. Start PIVlab and open the Image acquisition panel.

The panel, part by part

General settings

ControlWhat it does
Project path / Browse…Folder for the recorded images and the configuration.
Select configurationYour synchronizer + camera combination, e.g. PIVlab LD-PS + OPTOcam 2/80. PIVlab then looks for that camera and loads the matching firmware settings. Webcam demo (no synchronizer) runs the panel without PIV hardware (see below).
StereoRecord with two cameras of the selected type for stereo-PIV (see below).
COM port / ConnectSerial port of the synchronizer. The indicator next to the button is red while disconnected and green once the synchronizer answers.
General settings: project path, configuration, Stereo, COM port and Connect

Synchronizer control

ControlWhat it does
Frame rate in HzRate of the double images during capture. The available values come from the selected camera.
Pulse distance in µsTime between the two laser pulses — the Δt of the image pair. See Choosing the pulse distance.
Laser energy in %Energy per pulse.
Pulse lengthRead-out, not an input: the pulse length PIVlab derives from the energy and the configuration.
Timing graphDraws where the camera exposures and the laser pulses sit in time, for the current settings.
Low energy modePulses the laser at 100 Hz with the shortest pulse (1 µs) so you can align the sheet at a fraction of the average power. Synchronized capture is switched off while this is active.
Toggle LaserSwitches the laser on and off. The field to its left shows the laser state.
Trigger modeConfigures the trigger input, so an external signal can start the recording. Shown for synchronizers that support it.
DevicesSetup of further remote-controlled equipment on the wireless link, such as a seeding generator.
Synchronizer control: frame rate, pulse distance, laser energy, pulse length, Timing graph, Low energy mode, Toggle Laser and Devices

Camera settings

ControlWhat it does
BinningCombines neighbouring pixels: brighter image, lower resolution.
ROIReads out only part of the sensor, which allows higher frame rates.
LensLens control for cameras that support it, including autofocus.
SetupCamera-specific settings such as bit depth and gain, and the serial numbers of the connected cameras.
SharpnessBlur in pixels for the left, centre and right third of the image — smaller is sharper. See Focusing with the Sharpness overlay. Works in the live image and in the PIV preview.
GridOverlays a grid, for aligning the camera. Works in the live image and in the PIV preview.
CalibrationLive detection of a ChArUco board — see Calibration overlay. Works in the live image only.
Camera settings: Binning, ROI, Lens and Setup buttons, and the live overlay switches

Sharpness overlay

Focus until all three values are as small as you can get them. With a Scheimpflug adapter, focus until the centre value is smallest, then adjust the adapter until left and right are equal.

The bar under each value fills as that third gets sharper, and a white mark records the best value seen there. Turn back when a bar drops below its mark. All three bars at their marks means the image is in focus everywhere. If the side bars sit level but below a full centre bar, the adapter cannot fix it — close the aperture instead.

Live image of two cameras with the Sharpness overlay: three yellow bars per camera with the blur in pixels below them and a white mark for the best value; top right the sharpness and the mean brightness
The Sharpness overlay with two cameras: blur in pixels for the left, centre and right third of each image, each bar with the white mark of its best value.

Calibration overlay

The Calibration overlay is the quickest way to check a board and a camera position. Ticking it switches Sharpness off, and the other way round.

Live image of a ChArUco board with the Calibration overlay: a yellow outline around every detected marker, blue corners around the QR code, at the top left the board parameters read from the QR code and the marker percentage
The Calibration overlay: all markers found, the QR code read and the board parameters taken from it.

Live image

Here the camera runs freely: it is not triggered by the synchronizer, so the laser pulses and the camera exposures are not locked to each other. Brightness and particle images in this view therefore say nothing about the images you will record. Use it to aim the camera, to record the board image, and to focus on a target placed in the plane of the light sheet.

ControlWhat it does
Exposure in msCamera exposure for the live view only; the recording uses the laser pulse, not this value.
StartStarts the live view. Zoom and the Calibration overlay work only here.
SnapshotSaves the image currently displayed into the project folder.
SaveStops the live view and keeps the last image — this is how the board image for the camera calibration is recorded.
Live image: exposure, Start, Snapshot and Save

Capture PIV images

Here the camera runs synchronized with the laser. The Save tick decides what Start does: without it you get a running preview, with it a recording.

ControlWhat it does
SaveOff: Start runs a PIV preview — synchronized double images, nothing written to disk, running until you stop it. On: the images are written to the project folder and Image amount becomes editable.
Image amountNumber of double images to record. The field turns red when the amount will most likely not fit into your RAM.
StartStarts the laser and the synchronized camera. PIVlab asks before the laser starts, and — when saving — before existing files are overwritten.
AbortEnds the preview, or stops a recording and discards its images.
Capture PIV images: image amount, Save, Start and Abort
The PIV preview is where you judge the images It is the only mode that shows the images as they will be recorded: camera and laser synchronized, with the pulse distance you set. Focus here, and check particle images, seeding and exposure. Sharpness and Grid are available, and the laser energy can be changed while the preview runs.

When a recording ends, the images are loaded into the session automatically. Step through the pairs with the frame slider and run a quick analysis to see whether the data is good before you record more.

A recording from start to finish

  1. Set the Project path.
  2. Choose the Select configuration entry for your hardware and connect the synchronizer.
  3. Set bit depth and gain under Setup, and the Frame rate.
  4. Aim the camera with the Live image, and place a target in the plane of the light sheet if you want to focus roughly before the laser runs.
  5. Set the Pulse distance (see below) and the Laser energy.
  6. Leave Save unticked and click Start to run the PIV preview. Focus here — with Lens → autofocus or by eye with the Sharpness overlay — and adjust seeding and laser energy until the particle images look good. Then Abort.
  7. Tick Save, set the Image amount, and click Start.
  8. Check the recording: step through the pairs and analyse a few frames.

Pulse distance and frame straddling

The pulse distance is the Δt of your image pair, and it decides how far particles travel between the two images. Choose it so that the displacement fits the interrogation area you plan to use — Choosing Δt together with the interrogation area covers how to find a good value and how to read the displacement back from a test analysis.

How frame straddling works

Why Δt is not tied to the frame rate, and what limits it background

The two images of a pair are two consecutive camera frames. Instead of lighting each frame in the middle, the synchronizer puts the first laser pulse at the very end of the first frame's exposure and the second at the very beginning of the next one. Both pulses sit close together around the frame boundary, one on each side. This is frame straddling, and it is how PIVlab records PIV images.

Timing diagram: the green camera exposure trace alternates between image A and image B, and the two blue laser pulses sit close together on either side of the boundary from image A to image B. Pulse distance is marked between the two pulses, pulse length within one pulse, and the frame rate between two image pairs.
Frame straddling. The two laser pulses sit on either side of the boundary between image A and image B, so Pulse distance is much shorter than the time between two image pairs set by the Frame rate. The width of a single pulse is the pulse length, set by Laser energy.

The point is that Δt is then set by the distance between the two pulses, not by the frame rate. With continuous light the two images are a full frame period apart, so a 100 Hz camera gives Δt = 10 ms and nothing faster can be measured. With straddling the same camera can use a Δt of a few microseconds.

How much that buys you follows from the displacement limit. With a field of view L, a sensor of N pixels and a largest acceptable displacement s in pixels:

vmax = (L / N) · s / Δt

For L = 100 mm, N = 2000 px and s = 10 px, the particles may travel 0.5 mm between the two images.

ΔtHighest measurable velocity
10 ms0.05 m/s — what a 100 Hz camera with continuous light is limited to
1 ms0.5 m/s
100 µs5 m/s
10 µs50 m/s

Same camera, same laser — only the pulse distance changes.

Δt cannot be made arbitrarily small. The lower limit comes from the camera: the two pulses have to fit on either side of the frame boundary, and with double-shutter cameras the gap between the two exposures is fixed by the sensor readout. The upper limit is one frame period. PIVlab enforces both — enter a value below the camera's minimum or above the frame period and the field briefly turns red and is set to the limit.

Switch Timing graph on to see it: camera exposures and laser pulses are drawn against time in µs over several frames, so you can check that the two pulses really do sit on either side of the frame boundary.

Pulse length: light against streaking A longer pulse puts more light on the sensor but also smears each particle into a streak. Keep the streaks short — but not at any price: too little light costs more accuracy than a little streaking does.
You can plan the timing without the hardware Pick any configuration and change frame rate, pulse distance and energy with the Timing graph switched on. PIVlab draws the timing and the resulting double-frame rate for that camera even when nothing is connected.

Stereo acquisition (two cameras)

For stereo-PIV, PIVlab records with two cameras of the same type at the same time (at present the OPTOcam 2/80).

  1. Connect both cameras to the computer, and both to the camera output of the synchronizer (Y-cable). Both cameras get the same trigger; frame rate, pulse distance, laser energy, exposure, bit depth, gain and ROI apply to both.
  2. Select the configuration and tick Stereo. PIVlab checks that two cameras are connected.
  3. Live image shows both cameras side by side. Camera 1 is the camera with the lower serial number; Setup shows both serial numbers, and Swap cameras exchanges camera 1 and 2.
  4. With Calibration ticked, the markers of a ChArUco board are shown in both images. Each image also shows the frame of the other camera as a dashed line in that camera's colour, and Overlap gives the part of the image that the other camera sees too: align the cameras until the overlap is as large as you need it. The automatic snapshots and the camera position need one camera shown (CAM button). Place the board in the light sheet so that both cameras see it well, then switch the laser off and light the board normally (why). Snapshot then saves one image per camera: the board images for the stereo calibration.
  5. Capture PIV images saves the images of camera 1 in the subfolder cam1 and those of camera 2 in cam2 of the project folder, and opens them in stereo mode. The next recording with the same setup keeps the stereo calibration.

Two cameras side by side: stitched field of view

The same recording also serves a second purpose. Place the two cameras side by side, each looking at its own part of the light sheet with a small overlap, and PIVlab stitches both into one larger image: a stitched field of view with u and v over the whole stitched field.

Live image of two cameras side by side, each showing the ChArUco board from a different angle, the detected markers outlined in yellow, the frame of the other camera as a dashed line, and the marker and overlap percentages at the top left
Live image of both cameras with Calibration ticked: almost all markers are detected in both images, and the dashed lines show where the other camera's image lies.

Trying it with just a webcam

The Webcam demo (no synchronizer) configuration runs the capture workflow against an ordinary USB webcam, so you can see how the panel behaves before setting up real equipment. When you run PIVlab inside MATLAB, this needs the free MATLAB Support Package for USB Webcams; the standalone PIVlab needs nothing extra. Everything that belongs to the synchronizer, the laser and a PIV camera is switched off, and the images it produces are a demonstration, not PIV data.