Skip to main content

calibrate()

Instance Method | VTSensor Sensor Class

📖 Method Description

Perform sensor calibration to establish a baseline image for subsequent data collection and processing. The calibration process is crucial for ensuring data accuracy.


📝 Syntax

# Method 1: Auto-collect image for calibration (online mode)
sensor.calibrate()

# Method 2: Use a raw sensor image for calibration (offline mode)
sensor.calibrate(calib_image=raw_calib_image)

🔧 Parameters

ParameterTypeDefaultDescription
calib_imagenp.ndarray | NoneNoneRaw sensor image used for offline calibration
None means automatically capture an image in online mode

📤 Return Type

No return value


💡 Example Code

Online Calibration (Auto-collect)

from pyvitaisdk import VTSensor, VTSDeviceFinder

# Get device and initialize sensor
finder = VTSDeviceFinder()
devices = finder.get_devices()
sensor = VTSensor(devices[0])

# Auto-collect image for calibration
print("Please ensure sensor surface is untouched...")
sensor.calibrate()
print("Sensor calibrated")

# Use sensor...

# Release resources
sensor.release()

Offline Calibration (Specified Image)

import cv2
from pyvitaisdk import VTSensor, VTSensorType

# Initialize in offline mode
sensor = VTSensor(config=None, sensor_type=VTSensorType.GF225)

# Load a saved raw calibration image; do not warp it beforehand
raw_calib_image = cv2.imread("raw_calibration_image.jpg")

# The SDK applies warp internally before calibration
sensor.calibrate(calib_image=raw_calib_image)
print("Sensor calibrated (offline mode)")
sensor.release() # Release resources

⚠️ Notes

Calibration Environment Requirements
  • Untouched State: No objects should be in contact with the sensor surface during calibration
  • Stable Lighting: Maintain stable ambient lighting, avoid reflections and shadows
  • Clean Surface: Ensure sensor surface is clean, free of dust or stains
Important Reminders
  • Do not touch the sensor during calibration
  • Calibration image quality directly affects the accuracy of all subsequent data
  • Re-calibration is recommended after environmental changes (such as lighting changes)
Best Practices
  • Perform calibration once each time the program starts
  • Re-calibrate periodically during long-running sessions
  • Save calibration images for offline processing use
Offline Mode Notes

For offline data processing:

  • Provide a pre-collected raw sensor calibration image
  • Do not pass an already warped image; the SDK processes it internally according to sensor_type
  • Image format: np.ndarray, shape is (H, W, 3)
  • Ensure images are consistent with actual collection conditions