Skip to main content

calibrate()

Instance Method | GF225 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 specified image for calibration (offline mode)
sensor.calibrate(calib_img=image)

🔧 Parameters

ParameterTypeDefaultDescription
calib_imgnp.ndarray | NoneNoneImage used for calibration
None means auto-collect image for calibration

📤 Return Type

No return value


💡 Example Code

Online Calibration (Auto-collect)

from pyvitaisdk import GF225, VTSDeviceFinder

# Get device and initialize sensor
finder = VTSDeviceFinder()
devices = finder.get_devices()
sensor = GF225(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 GF225

# Initialize in offline mode
sensor = GF225(config=None)

# Load saved calibration image
calib_image = cv2.imread("calibration_image.jpg")

# Calibrate using specified image
sensor.calibrate(calib_img=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:

  • Need to provide pre-collected calibration images
  • Image format: np.ndarray, shape is (H, W, 3)
  • Ensure images are consistent with actual collection conditions