py3dcal 1.0.0__py3-none-any.whl → 1.0.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- py3DCal/__init__.py +7 -5
- py3DCal/data_collection/Calibrator.py +10 -8
- py3DCal/data_collection/{Sensors → sensors}/GelsightMini/GelsightMini.py +5 -5
- py3DCal/data_collection/{Sensors → sensors}/Sensor.py +10 -1
- py3DCal/model_training/datasets/DIGIT_dataset.py +4 -2
- py3DCal/model_training/datasets/GelSightMini_dataset.py +4 -2
- py3DCal/model_training/datasets/tactile_sensor_dataset.py +4 -3
- py3DCal/model_training/lib/annotate_dataset.py +560 -0
- py3DCal/model_training/lib/depthmaps.py +11 -3
- py3DCal/model_training/lib/fast_poisson.py +12 -12
- py3DCal/model_training/lib/validate_parameters.py +44 -2
- {py3dcal-1.0.0.dist-info → py3dcal-1.0.6.dist-info}/METADATA +1 -1
- py3dcal-1.0.6.dist-info/RECORD +40 -0
- py3DCal/model_training/lib/validate_device.py +0 -22
- py3DCal/model_training/touchnet/__init__.py +0 -0
- py3DCal/model_training/touchnet/dataset.py +0 -78
- py3DCal/model_training/touchnet/touchnet.py +0 -736
- py3DCal/model_training/touchnet/touchnet_architecture.py +0 -72
- py3dcal-1.0.0.dist-info/RECORD +0 -44
- /py3DCal/data_collection/{Printers → printers}/Ender3/Ender3.py +0 -0
- /py3DCal/data_collection/{Printers → printers}/Ender3/__init__.py +0 -0
- /py3DCal/data_collection/{Printers → printers}/Printer.py +0 -0
- /py3DCal/data_collection/{Printers → printers}/__init__.py +0 -0
- /py3DCal/data_collection/{Sensors → sensors}/DIGIT/DIGIT.py +0 -0
- /py3DCal/data_collection/{Sensors → sensors}/DIGIT/__init__.py +0 -0
- /py3DCal/data_collection/{Sensors → sensors}/DIGIT/default.csv +0 -0
- /py3DCal/data_collection/{Sensors → sensors}/GelsightMini/__init__.py +0 -0
- /py3DCal/data_collection/{Sensors → sensors}/GelsightMini/default.csv +0 -0
- /py3DCal/data_collection/{Sensors → sensors}/__init__.py +0 -0
- {py3dcal-1.0.0.dist-info → py3dcal-1.0.6.dist-info}/LICENSE +0 -0
- {py3dcal-1.0.0.dist-info → py3dcal-1.0.6.dist-info}/WHEEL +0 -0
- {py3dcal-1.0.0.dist-info → py3dcal-1.0.6.dist-info}/entry_points.txt +0 -0
- {py3dcal-1.0.0.dist-info → py3dcal-1.0.6.dist-info}/top_level.txt +0 -0
py3DCal/__init__.py
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
from .data_collection.Calibrator import Calibrator
|
|
2
|
-
from .data_collection.
|
|
3
|
-
from .data_collection.
|
|
4
|
-
from .data_collection.
|
|
5
|
-
from .data_collection.
|
|
6
|
-
from .data_collection.
|
|
2
|
+
from .data_collection.printers.Printer import Printer
|
|
3
|
+
from .data_collection.printers.Ender3.Ender3 import Ender3
|
|
4
|
+
from .data_collection.sensors.Sensor import Sensor
|
|
5
|
+
from .data_collection.sensors.DIGIT.DIGIT import DIGIT
|
|
6
|
+
from .data_collection.sensors.GelsightMini.GelsightMini import GelsightMini
|
|
7
7
|
from .model_training import datasets, models
|
|
8
8
|
from .model_training.datasets.split_dataset import split_dataset
|
|
9
9
|
from .model_training.models.touchnet import SensorType
|
|
10
|
+
from .model_training.lib.annotate_dataset import annotate, visualize_annotations
|
|
10
11
|
from .model_training.lib.train_model import train_model
|
|
11
12
|
from .model_training.lib.depthmaps import get_depthmap, save_2d_depthmap, show_2d_depthmap
|
|
13
|
+
from .model_training.lib.fast_poisson import fast_poisson
|
|
12
14
|
from .utils.utils import list_com_ports
|
|
@@ -6,9 +6,8 @@ from typing import Union
|
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
from PIL import Image
|
|
8
8
|
from tqdm import tqdm
|
|
9
|
-
|
|
10
|
-
from .
|
|
11
|
-
from .Sensors.Sensor import Sensor
|
|
9
|
+
from .printers.Printer import Printer
|
|
10
|
+
from .sensors.Sensor import Sensor
|
|
12
11
|
|
|
13
12
|
class Calibrator:
|
|
14
13
|
""" Calibrator class to automatically probe a tactile sensor.
|
|
@@ -153,7 +152,7 @@ class Calibrator:
|
|
|
153
152
|
# Connect to 3D printer if not already connected
|
|
154
153
|
if not self.printer_connected:
|
|
155
154
|
self.connect_printer()
|
|
156
|
-
self.printer.send_gcode("M117
|
|
155
|
+
self.printer.send_gcode("M117 Calibrating sensor...")
|
|
157
156
|
|
|
158
157
|
# Connect to sensor
|
|
159
158
|
if save_images == True:
|
|
@@ -257,11 +256,14 @@ class Calibrator:
|
|
|
257
256
|
with open(os.path.join(data_save_path, "annotations", "probe_data.csv"), 'a', newline='') as csv_file:
|
|
258
257
|
csv_writer = csv.writer(csv_file)
|
|
259
258
|
|
|
260
|
-
|
|
259
|
+
# Flush frames to clear camera buffer
|
|
260
|
+
self.sensor.flush_frames(n=5)
|
|
261
|
+
|
|
262
|
+
for _ in range(int(self.calibration_points[i][3])):
|
|
261
263
|
frame = self.sensor.capture_image()
|
|
262
264
|
|
|
263
265
|
img_name = str(img_idx) + "_" + "X" + str(self.calibration_points[i][0]) + "Y" + str(self.calibration_points[i][1]) + "Z" + str(self.calibration_points[i][2]) + ".png"
|
|
264
|
-
img_path = os.path.join(data_save_path, "probe_images",img_name)
|
|
266
|
+
img_path = os.path.join(data_save_path, "probe_images", img_name)
|
|
265
267
|
|
|
266
268
|
img = Image.fromarray(frame)
|
|
267
269
|
img.save(img_path)
|
|
@@ -283,7 +285,7 @@ class Calibrator:
|
|
|
283
285
|
print("")
|
|
284
286
|
|
|
285
287
|
# Update printer display
|
|
286
|
-
self.printer.send_gcode("M117
|
|
288
|
+
self.printer.send_gcode("M117 Calibration Done!")
|
|
287
289
|
|
|
288
290
|
# Disconnect from 3D printer
|
|
289
291
|
self.disconnect_printer()
|
|
@@ -292,7 +294,7 @@ class Calibrator:
|
|
|
292
294
|
if save_images == True:
|
|
293
295
|
self.disconnect_sensor()
|
|
294
296
|
|
|
295
|
-
print("
|
|
297
|
+
print("Calibration procedure complete!")
|
|
296
298
|
print("")
|
|
297
299
|
|
|
298
300
|
return True
|
|
@@ -10,10 +10,10 @@ except:
|
|
|
10
10
|
|
|
11
11
|
class GelsightMini(Sensor):
|
|
12
12
|
"""
|
|
13
|
-
GelsightMini: A Sensor Class for the
|
|
13
|
+
GelsightMini: A Sensor Class for the GelSight Mini sensor
|
|
14
14
|
"""
|
|
15
15
|
def __init__(self):
|
|
16
|
-
self.name = "
|
|
16
|
+
self.name = "GelSight Mini"
|
|
17
17
|
self.x_offset = 108
|
|
18
18
|
self.y_offset = 110
|
|
19
19
|
self.z_offset = 67
|
|
@@ -23,7 +23,7 @@ class GelsightMini(Sensor):
|
|
|
23
23
|
|
|
24
24
|
def connect(self):
|
|
25
25
|
"""
|
|
26
|
-
Connects to the
|
|
26
|
+
Connects to the GelSight Mini sensor.
|
|
27
27
|
"""
|
|
28
28
|
# Code to connect to the sensor
|
|
29
29
|
self.sensor = gsdevice.Camera("GelSight Mini")
|
|
@@ -31,14 +31,14 @@ class GelsightMini(Sensor):
|
|
|
31
31
|
|
|
32
32
|
def disconnect(self):
|
|
33
33
|
"""
|
|
34
|
-
Disconnects from the
|
|
34
|
+
Disconnects from the GelSight Mini sensor.
|
|
35
35
|
"""
|
|
36
36
|
# Code to disconnect from the sensor
|
|
37
37
|
self.sensor.stop_video()
|
|
38
38
|
|
|
39
39
|
def capture_image(self):
|
|
40
40
|
"""
|
|
41
|
-
Captures an image from the
|
|
41
|
+
Captures an image from the GelSight Mini sensor.
|
|
42
42
|
"""
|
|
43
43
|
# Code to return an image from the sensor
|
|
44
44
|
image = cv2.cvtColor(self.sensor.get_image(), cv2.COLOR_BGR2RGB)
|
|
@@ -32,4 +32,13 @@ class Sensor(ABC):
|
|
|
32
32
|
Returns:
|
|
33
33
|
numpy.ndarray: The image from the sensor.
|
|
34
34
|
"""
|
|
35
|
-
pass
|
|
35
|
+
pass
|
|
36
|
+
|
|
37
|
+
def flush_frames(self, n: int = 5):
|
|
38
|
+
"""Discards the next n frames to clear camera buffer.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
n (int): Number of frames to discard. Default is 5.
|
|
42
|
+
"""
|
|
43
|
+
for _ in range(n):
|
|
44
|
+
self.capture_image()
|
|
@@ -21,13 +21,15 @@ class DIGIT(TactileSensorDataset):
|
|
|
21
21
|
def __init__(self, root: Union[str, Path] = Path("."), download=False, add_coordinate_embeddings=True, subtract_blank=True, transform=None):
|
|
22
22
|
validate_root(root)
|
|
23
23
|
|
|
24
|
-
self.
|
|
24
|
+
self.root = root
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
self.dataset_path = os.path.join(self.root, "digit_calibration_data")
|
|
27
27
|
|
|
28
28
|
if download:
|
|
29
29
|
self._download_dataset()
|
|
30
30
|
|
|
31
|
+
super().__init__(root=self.dataset_path, add_coordinate_embeddings=add_coordinate_embeddings, subtract_blank=subtract_blank, transform=transform)
|
|
32
|
+
|
|
31
33
|
def _download_dataset(self):
|
|
32
34
|
"""
|
|
33
35
|
Downloads the dataset for either the DIGIT sensor.
|
|
@@ -21,13 +21,15 @@ class GelSightMini(TactileSensorDataset):
|
|
|
21
21
|
def __init__(self, root: Union[str, Path] = Path("."), download=False, add_coordinate_embeddings=True, subtract_blank=True, transform=None):
|
|
22
22
|
validate_root(root)
|
|
23
23
|
|
|
24
|
-
self.
|
|
24
|
+
self.root = root
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
self.dataset_path = os.path.join(self.root, "gsmini_calibration_data")
|
|
27
27
|
|
|
28
28
|
if download:
|
|
29
29
|
self._download_dataset()
|
|
30
30
|
|
|
31
|
+
super().__init__(root=self.dataset_path, add_coordinate_embeddings=add_coordinate_embeddings, subtract_blank=subtract_blank, transform=transform)
|
|
32
|
+
|
|
31
33
|
def _download_dataset(self):
|
|
32
34
|
"""
|
|
33
35
|
Downloads the dataset for the GelSight Mini sensor.
|
|
@@ -9,7 +9,7 @@ from torchvision import transforms
|
|
|
9
9
|
from ..lib.precompute_gradients import precompute_gradients
|
|
10
10
|
from ..lib.get_gradient_map import get_gradient_map
|
|
11
11
|
from ..lib.add_coordinate_embeddings import add_coordinate_embeddings
|
|
12
|
-
from ..lib.validate_parameters import validate_root
|
|
12
|
+
from ..lib.validate_parameters import validate_root, validate_dataset
|
|
13
13
|
|
|
14
14
|
class TactileSensorDataset(Dataset):
|
|
15
15
|
"""
|
|
@@ -22,12 +22,13 @@ class TactileSensorDataset(Dataset):
|
|
|
22
22
|
transform (callable, optional): A function/transform that takes in an PIL image and returns a transformed version. Default: ``transforms.ToTensor()``
|
|
23
23
|
"""
|
|
24
24
|
def __init__(self, root: Union[str, Path], add_coordinate_embeddings=True, subtract_blank=True, transform=None):
|
|
25
|
-
|
|
25
|
+
validate_dataset(root, subtract_blank)
|
|
26
26
|
|
|
27
27
|
self.root = root
|
|
28
28
|
self.annotation_path = os.path.join(root, "annotations", "annotations.csv")
|
|
29
29
|
self.metadata_path = os.path.join(root, "annotations", "metadata.json")
|
|
30
|
-
|
|
30
|
+
if subtract_blank:
|
|
31
|
+
self.blank_image_path = os.path.join(root, "blank_images", "blank.png")
|
|
31
32
|
self.add_coordinate_embeddings = add_coordinate_embeddings
|
|
32
33
|
self.subtract_blank = subtract_blank
|
|
33
34
|
|