temp2.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import asyncio
  2. from mcu.capture.smart_shooter_class import SmartShooter
  3. smart = SmartShooter(None)
  4. async def parserProperty(CameraPropertyType=None):
  5. status, camera_property = await smart.GetCameraProperty()
  6. if CameraPropertyType:
  7. camera_property_obj = None
  8. for item in camera_property:
  9. if item['CameraPropertyType'] == CameraPropertyType:
  10. camera_property_obj = item
  11. break
  12. return camera_property_obj if camera_property_obj else camera_property
  13. return camera_property
  14. async def setCameraProperty(property="Aperture", value=""):
  15. await smart.setCameraProperty(property=property, value=value)
  16. async def setCameraProperties(properties: dict):
  17. '''批量设置多个参数,如 {"ISO": "200", "Aperture": "8", "ShutterSpeed": "1/60"}'''
  18. all_ok, results = await smart.setCameraProperties(properties)
  19. print("批量设置结果:", all_ok, results)
  20. async def main():
  21. '''
  22. Aperture:光圈
  23. ShutterSpeed:快门速度
  24. ISO:ISO设置
  25. Exposure:曝光
  26. "CameraPropertyType": 参数类型,
  27. "CameraPropertyValue": 当前值,
  28. "CameraPropertyIsWriteable": 是否可写,
  29. "CameraPropertyRange" 参数范围
  30. '''
  31. camera_property = await parserProperty("Aperture")
  32. # print('property', camera_property)
  33. # await setCameraProperty('Exposure', '5.0')
  34. await setCameraProperties({
  35. "ISO": "200",
  36. "Aperture": "8",
  37. "ShutterSpeed": "1/60",
  38. "Exposure": "5.0"
  39. })
  40. if __name__ == "__main__":
  41. asyncio.run(main())