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

13 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-09-11 15:43 -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 

12 

13class Camera(): 

14 """Camera class.""" 

15 

16 def __init__(self, state): 

17 self.broker = BrokerConnect(state) 

18 self.state = state 

19 

20 def calibrate_camera(self): 

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

22 

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

24 

25 calibrate_message = { 

26 "kind": "execute_script", 

27 "args": { 

28 "label": "camera-calibration" 

29 }, 

30 } 

31 

32 self.broker.publish(calibrate_message) 

33 

34 def take_photo(self): 

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

36 

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

38 

39 photo_message = { 

40 "kind": "take_photo", 

41 "args": {} 

42 } 

43 

44 self.broker.publish(photo_message) 

45 

46 # TODO: photo_grid()