Skip to content

Commit bf31a35

Browse files
authored
Merge pull request #13 from Matter-and-Form/feature/versionUpdate
Add's CaptureImage to the tasks
2 parents 3fc3a99 + 3b78f3c commit bf31a35

File tree

9 files changed

+185
-16
lines changed

9 files changed

+185
-16
lines changed

scripts/transpileProto.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ def parse_message_props(message):
288288
for procedure in service.procedures:
289289

290290
# Remove only the last word from procedure.request and procedure.response
291-
request_base = procedure.request.rsplit('.', 1)[0]
292-
response_base = procedure.response.rsplit('.', 1)[0]
291+
request_base = procedure.request.rsplit('.', 2)[-2]
292+
response_base = procedure.response.rsplit('.', 2)[-2]
293293

294294
import_descriptor_request = get_descriptor_by_partial_filename(request_base, node.imports)
295295
import_descriptor_response = get_descriptor_by_partial_filename(response_base, node.imports)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from MF.V3.Settings.CaptureImage import CaptureImage as MF_V3_Settings_CaptureImage_CaptureImage
2+
3+
4+
class CaptureImage:
5+
6+
"""
7+
Capture image descriptor.
8+
"""
9+
def __init__(self, camera: int, codec: MF_V3_Settings_CaptureImage_CaptureImage.Codec, grayscale: bool, width: int, height: int, step: int):
10+
# The index of the camera that produced the image.
11+
self.camera = camera
12+
# Image codec.
13+
self.codec = codec
14+
# If true, image is 8-bit grayscale. Otherwise image is BGR888.
15+
self.grayscale = grayscale
16+
# Image width.
17+
self.width = width
18+
# Image height.
19+
self.height = height
20+
# Image row step in bytes.
21+
self.step = step
22+
23+

three/MF/V3/Descriptors/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from MF.V3.Descriptors.BoundingBox import *
2+
from MF.V3.Descriptors.CaptureImage import *
23
from MF.V3.Descriptors.Export import *
34
from MF.V3.Descriptors.Image import *
45
from MF.V3.Descriptors.Merge import *
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from enum import Enum
2+
from typing import List
3+
4+
5+
class CaptureImage:
6+
7+
"""
8+
Capture image settings.
9+
"""
10+
class Codec(Enum):
11+
12+
"""
13+
Image codecs.
14+
"""
15+
jpg = "jpg" # JPEG encoding.
16+
png = "png" # PNG encoding.
17+
bmp = "bmp" # Bitmap encoding.
18+
raw = "raw" # Raw pixel data (no encoding).
19+
20+
def __init__(self, selection: List[int] = None, codec: 'Codec' = None, grayscale: bool = None):
21+
# Camera selection. Default is all cameras.
22+
self.selection = selection
23+
# Image codec. Default is jpg.
24+
self.codec = codec
25+
# Capture 8-bit grayscale image. Default is false (BGR888).
26+
self.grayscale = grayscale
27+
28+

three/MF/V3/Settings/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from MF.V3.Settings.BoundingBox import *
55
from MF.V3.Settings.Camera import *
66
from MF.V3.Settings.Capture import *
7+
from MF.V3.Settings.CaptureImage import *
78
from MF.V3.Settings.CopyGroup import *
89
from MF.V3.Settings.CopyProject import *
910
from MF.V3.Settings.Export import *

three/MF/V3/Task.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,6 @@ class Task:
6060
}
6161
```
6262
"""
63-
class Progress:
64-
65-
"""
66-
V3 Task Progress Descriptor
67-
"""
68-
def __init__(self, current: int, step: str, total: int):
69-
# The current step of the scan.
70-
self.current = current
71-
# The string description of the current step.
72-
self.step = step
73-
# The total steps in the progress.
74-
self.total = total
75-
7663
def __init__(self, Index: int, Type: str, Input: _any_pb2 = None, Output: _any_pb2 = None, State: 'TaskState' = None, Error: str = None, Progress: _any_pb2 = None):
7764
# A unique identifier generated by the client. This identifier associates all incoming and outgoing task messages with a specific task requested by the client.
7865
self.Index = Index

three/MF/V3/Tasks/CaptureImage.py

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
from MF.V3.Descriptors.CaptureImage import CaptureImage as MF_V3_Descriptors_CaptureImage_CaptureImage
2+
from MF.V3.Settings.CaptureImage import CaptureImage as MF_V3_Settings_CaptureImage_CaptureImage
3+
from MF.V3.Task import TaskState as MF_V3_Task_TaskState, Task as MF_V3_Task_Task
4+
from typing import List
5+
6+
7+
class CaptureImage:
8+
"""*
9+
Capture an image from one or both cameras.
10+
11+
> Request example:
12+
13+
```json
14+
{
15+
"Task":{
16+
"Index":1,
17+
"Type":"CaptureImage"
18+
"Input":{
19+
"selection":{0,1},
20+
"grayscale":false,
21+
"codec":jpg
22+
}
23+
}
24+
}
25+
```
26+
27+
> Buffer messages from server.
28+
29+
```json
30+
{
31+
"Buffer":{
32+
"Descriptor":"{"camera":0,"codec":"jpg","grayscale":false,"height":1560,"step":6312,"width":2104},
33+
"Index":0,
34+
"Size":856664,
35+
"Task":{
36+
"Index":1,
37+
"Type":"CaptureImage",
38+
"Input":{"selection":{0,1}, "grayscale":false, "codec":jpg}
39+
}
40+
}
41+
}
42+
```
43+
```json
44+
{
45+
"Buffer":{
46+
"Descriptor":"{"camera":1,"codec":"jpg","grayscale":false,"height":1560,"step":6312,"width":2104},
47+
"Index":1,
48+
"Size":847726,
49+
"Task":{
50+
"Index":1,
51+
"Type":"CaptureImage",
52+
"Input":{"selection":{0,1}, "grayscale":false, "codec":jpg}
53+
}
54+
}
55+
}
56+
```
57+
58+
> Response example:
59+
60+
```json
61+
{
62+
"Task":{
63+
"Index":1,
64+
"Type":"CaptureImage"
65+
"Input":{
66+
"selection":{0,1},
67+
"grayscale":false,
68+
"codec":jpg
69+
}
70+
"Output":[
71+
{"camera":0,"codec":"jpg","grayscale":false,"height":1560,"step":6312,"width":2104},
72+
{"camera":1,"codec":"jpg","grayscale":false,"height":1560,"step":6312,"width":2104}
73+
],
74+
"State":"Completed"
75+
}
76+
}
77+
```
78+
"""
79+
class Request:
80+
81+
"""
82+
Client request for the `CaptureImage` task.
83+
"""
84+
def __init__(self, Index: int, Type: str, Input: int):
85+
# A unique identifier generated by the client.
86+
self.Index = Index
87+
# "CaptureImage"
88+
self.Type = Type
89+
# Index of the project to download.
90+
self.Input = Input
91+
92+
class Response:
93+
94+
"""
95+
Server response for the `CaptureImage` task.
96+
"""
97+
def __init__(self, Index: int, Type: str, Input: MF_V3_Settings_CaptureImage_CaptureImage, Output: List[MF_V3_Descriptors_CaptureImage_CaptureImage] = None, State: MF_V3_Task_TaskState = None, Error: str = None):
98+
# The unique identifier generated by the client.
99+
self.Index = Index
100+
# "CaptureImage"
101+
self.Type = Type
102+
# Requested capture image settings.s
103+
self.Input = Input
104+
# A capture image descriptors for each selected camera.
105+
self.Output = Output
106+
# The current state of the task.
107+
self.State = State
108+
# A string describing the error if the task has failed.
109+
self.Error = Error
110+
111+
class Buffer:
112+
113+
"""
114+
Server buffer message for the `CaptureImage` task.
115+
"""
116+
def __init__(self, Index: int, Size: int, Task: MF_V3_Task_Task, Descriptor: MF_V3_Descriptors_CaptureImage_CaptureImage):
117+
# The zero-based index identifying the data buffer.
118+
self.Index = Index
119+
# The size of the incoming data buffer in bytes.
120+
self.Size = Size
121+
# The requested CaptureImage task.
122+
self.Task = Task
123+
# The capture image descriptor.
124+
self.Descriptor = Descriptor
125+
126+
def __init__(self):
127+
pass
128+

three/MF/V3/Tasks/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from MF.V3.Tasks.CalibrateTurntable import *
77
from MF.V3.Tasks.CalibrationCaptureTargets import *
88
from MF.V3.Tasks.CameraCalibration import *
9+
from MF.V3.Tasks.CaptureImage import *
910
from MF.V3.Tasks.CloseProject import *
1011
from MF.V3.Tasks.ConnectWifi import *
1112
from MF.V3.Tasks.DepthMap import *

0 commit comments

Comments
 (0)