Coverage for farmbot_sidecar_starter_pack/functions/camera.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-08-31 13:41 -0700

1""" 

2Camera class. 

3""" 

4 

5# └── functions/camera.py 

6# ├── [BROKER] calibrate_camera() 

7# ├── [BROKER] take_photo() 

8# └── [BROKER] photo_grid() 

9 

10from .broker import BrokerConnect 

11 

12class Camera(): 

13 """Camera class.""" 

14 def __init__(self, state): 

15 self.broker = BrokerConnect(state) 

16 self.state = state 

17 

18 def calibrate_camera(self): 

19 """Performs camera calibration. This action will reset camera calibration settings.""" 

20 

21 self.state.print_status(description="Calibrating camera") 

22 

23 calibrate_message = { 

24 "kind": "execute_script", 

25 "args": { 

26 "label": "camera-calibration" 

27 }, 

28 } 

29 

30 self.broker.publish(calibrate_message) 

31 

32 def take_photo(self): 

33 """Takes photo using the device camera and uploads it to the web app.""" 

34 

35 self.state.print_status(description="Taking a photo") 

36 

37 photo_message = { 

38 "kind": "take_photo", 

39 "args": {} 

40 } 

41 

42 self.broker.publish(photo_message) 

43 

44 # TODO: photo_grid()