Skip to content
⚡ Developer documentation for INFINICAM, the real-time high-speed camera (UC-1.1 / GbE-2)

Changing capture settings + SingleImage

This sample changes the INFINICAM GbE-2’s resolution, frame rate, and shutter speed from a program and captures one image.

  1. Enter and save the program

    Save the following code as single_image_settings.py in C:\infinicam_projects\python.

    import cv2
    from pypuclib import CameraFactory, PUCException
    print("Connecting to the camera...")
    try:
    # Connect to the GbE-2 at this IP address
    cam = CameraFactory().create(ip="192.168.0.10")
    except PUCException as e:
    print("Error: could not connect to the camera.", e)
    raise SystemExit(1)
    try:
    reso = cam.resolution()
    framerate, shutter = cam.framerateShutter()
    print(f"Settings when connected: {reso.width} x {reso.height} / {framerate} fps / shutter 1/{shutter} s")
    # Change the resolution (width and height must be multiples of 8)
    cam.setResolution(800, 320)
    # Change the frame rate and shutter speed (1000 fps, shutter 1/2000 s)
    cam.setFramerateShutter(1000, 2000)
    reso = cam.resolution()
    framerate, shutter = cam.framerateShutter()
    print(f"After the change: {reso.width} x {reso.height} / {framerate} fps / shutter 1/{shutter} s")
    # Take one frame with the new settings and save it as PNG
    image = cam.decoder().decode(cam.grab())
    filename = "custom_setting_image.png"
    cv2.imwrite(filename, image)
    print(f"Saved: {filename} (size: {image.shape[1]} x {image.shape[0]})")
    except PUCException as e:
    print("Error: could not change the settings or capture.", e)
    finally:
    cam.close()
  2. Run it

    Run the following 2 lines, one at a time, in Command Prompt (or PowerShell).

    Terminal window
    cd C:\infinicam_projects\python
    Terminal window
    python single_image_settings.py

    If you see the following and a 320-pixel-tall image custom_setting_image.png is created, it worked.

    Connecting to the camera...
    Settings when connected: 800 x 600 / 1000 fps / shutter 1/1000 s
    After the change: 800 x 320 / 1000 fps / shutter 1/2000 s
    Saved: custom_setting_image.png (size: 800 x 320)

reso = cam.resolution()
framerate, shutter = cam.framerateShutter()

cam.framerateShutter() returns 2 values at once: the frame rate and the shutter speed. With 2 variables on the left, as in framerate, shutter = ..., you receive each one separately.

cam.setResolution(800, 320)
  • Specify the width and height. Width and height must be multiples of 8.
  • Making the resolution (especially the height) smaller raises the maximum frame rate you can set. At 800 × 600 you can set up to 1,000 fps; at 800 × 48, up to 10,000 fps.

3. Change the frame rate and shutter speed

Section titled “3. Change the frame rate and shutter speed”
cam.setFramerateShutter(1000, 2000)
Argument Meaning Example
First Frame rate (frames captured per second) 1000 = 1,000 fps
Second Denominator of the shutter speed 2000 = 1/2000 s

The shutter speed (exposure time) cannot be longer than the time to capture one frame (1/frame rate). The second value must be greater than or equal to the first (1000 or more at 1,000 fps).