import asyncio from mcu.capture.smart_shooter_class import SmartShooter smart = SmartShooter(None) async def parserProperty(CameraPropertyType=None): status, camera_property = await smart.GetCameraProperty() if CameraPropertyType: camera_property_obj = None for item in camera_property: if item['CameraPropertyType'] == CameraPropertyType: camera_property_obj = item break return camera_property_obj if camera_property_obj else camera_property return camera_property async def setCameraProperty(property="Aperture", value=""): await smart.setCameraProperty(property=property, value=value) async def setCameraProperties(properties: dict): '''批量设置多个参数,如 {"ISO": "200", "Aperture": "8", "ShutterSpeed": "1/60"}''' all_ok, results = await smart.setCameraProperties(properties) print("批量设置结果:", all_ok, results) async def main(): ''' Aperture:光圈 ShutterSpeed:快门速度 ISO:ISO设置 Exposure:曝光 "CameraPropertyType": 参数类型, "CameraPropertyValue": 当前值, "CameraPropertyIsWriteable": 是否可写, "CameraPropertyRange" 参数范围 ''' camera_property = await parserProperty("Aperture") # print('property', camera_property) # await setCameraProperty('Exposure', '5.0') await setCameraProperties({ "ISO": "200", "Aperture": "8", "ShutterSpeed": "1/60", "Exposure": "5.0" }) if __name__ == "__main__": asyncio.run(main())