为基础示例接入按设备 ID 选择的力标定
让使用者从本地目录选标定并看见实际单位。短片回放及相关测试通过。
This commit is contained in:
@@ -19,6 +19,7 @@ Run:
|
||||
python examples/basic_pipeline.py -v 0 -c mini
|
||||
python examples/basic_pipeline.py -v recording.mp4 -c box
|
||||
python examples/basic_pipeline.py --no-show # headless: print only
|
||||
python examples/basic_pipeline.py -v 0 -c box --calibration-dir data/calibrations --device-id BOX-001
|
||||
|
||||
Keys: 'q' quit, 'r' reset the tracker.
|
||||
"""
|
||||
@@ -44,18 +45,39 @@ def main() -> int:
|
||||
help="camera index or video file path (default: 0)")
|
||||
parser.add_argument("-c", "--config", default="box",
|
||||
help="product config: box, mini, finger, or a config path")
|
||||
parser.add_argument("--cal", default=None,
|
||||
help="force calibration file; omit to use the sensor bundle's own")
|
||||
calibration = parser.add_mutually_exclusive_group()
|
||||
calibration.add_argument("--cal", default=None,
|
||||
help="force calibration file; omit to use the sensor bundle's own")
|
||||
calibration.add_argument("--calibration-dir", default=None,
|
||||
help="root containing <product>/<device-id>.json")
|
||||
parser.add_argument("--device-id", default=None,
|
||||
help="physical sensor ID; required with --calibration-dir")
|
||||
parser.add_argument("--no-show", dest="show", action="store_false",
|
||||
help="do not open the display windows")
|
||||
parser.add_argument("-verbose", action="store_true", help="SDK verbose logs")
|
||||
args = parser.parse_args()
|
||||
if args.calibration_dir is not None and args.device_id is None:
|
||||
parser.error("--calibration-dir requires --device-id")
|
||||
if args.device_id is not None and args.calibration_dir is None and args.cal is None:
|
||||
parser.error("--device-id requires --calibration-dir or --cal")
|
||||
|
||||
# ------------------------------------------------------------------ create the object
|
||||
# That is the whole setup. The source may be a camera index or a video path.
|
||||
source = int(args.video) if args.video.isdigit() else args.video
|
||||
sensor = orisys.Sensor(source, config_name=args.config, cal_path=args.cal,
|
||||
verbose=args.verbose)
|
||||
sensor = orisys.Sensor(
|
||||
source, config_name=args.config, cal_path=args.cal,
|
||||
calibration_dir=args.calibration_dir, device_id=args.device_id,
|
||||
verbose=args.verbose,
|
||||
)
|
||||
fn_unit, fx_unit, fy_unit = sensor.force_units
|
||||
selected = sensor.calibration.source_path if sensor.calibration else None
|
||||
print(f"Force calibration: {selected or 'none'}")
|
||||
print(f"Force units: FN={fn_unit}, FX={fx_unit}, FY={fy_unit}")
|
||||
if sensor.device_calibration_missing:
|
||||
print(
|
||||
f"Warning: no calibration for {args.device_id!r} under "
|
||||
f"{args.calibration_dir}; force is raw."
|
||||
)
|
||||
|
||||
# contact=True runs contact analysis. include=... selects which arrays each snapshot carries;
|
||||
# arrays that are not included are None, so you pay only for what you use.
|
||||
@@ -99,7 +121,7 @@ def main() -> int:
|
||||
if colour is not None:
|
||||
cv2.imshow("depth", colour)
|
||||
|
||||
key = cv2.waitKey(1) & 0xFF
|
||||
key = cv2.waitKey(1) & 0xFF if args.show else -1
|
||||
if key == ord("q"):
|
||||
print("\nExiting.")
|
||||
break
|
||||
@@ -117,4 +139,4 @@ def main() -> int:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
sys.exit(main())
|
||||
|
||||
Reference in New Issue
Block a user