Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mount doc #132

Merged
merged 9 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Added
- Fallback for normalization if data not in 8bit range (``lensless.utils.io.save_image``).
- Add utilities for fabricating masks with 3D printing (``lensless.hardware.fabrication``).
- WandB support.
- Script for Mask adapter generation and update new mount in doc

Changed
~~~~~~~
Expand Down
16 changes: 16 additions & 0 deletions docs/source/fabrication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
:alt: Mount components.
:align: center


Note that the most recent version of the mount looks like this, with the addition of stoppers,
to prevent the mask from scratching the Pi Camera.
This new version of the mount can be found `here <https://drive.switch.ch/index.php/s/QYH9vSqPd21DIHQ>`_
ebezzam marked this conversation as resolved.
Show resolved Hide resolved

.. image:: mount_V4.png
ebezzam marked this conversation as resolved.
Show resolved Hide resolved
:alt: New Inner Mount w/ Stopper.
:align: center

Mask3DModel
~~~~~~~~~~~
Expand All @@ -22,6 +30,14 @@
:members:
:special-members: __init__

Because newer versions of the masks' size are smaller, the following adapter enables
them to be used with the current mounts design.

.. image:: mask_adapter.png
ebezzam marked this conversation as resolved.
Show resolved Hide resolved
:alt: Mask Adapter.
:align: center


MultiLensMold
~~~~~~~~~~~~~

Expand Down
55 changes: 55 additions & 0 deletions lensless/hardware/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from lensless.utils.image import print_image_info
from lensless.utils.io import load_image
import logging
import cadquery as cq

logging.getLogger("paramiko").setLevel(logging.WARNING)

Expand Down Expand Up @@ -387,3 +388,57 @@ def set_mask_sensor_distance(
client.close()

client.close()

def create_mask_adapter(width, height, fp):
"""
Create and store an adapter for a mask given its measurements.

Parameters
----------
width : float
The length of the mask's width in mm.
height : float
The length of the mask's height in mm.
fp : string
The folder in which to store the generated stl file.
"""
# Hard coded size of the inner-mount hole
mount_w, mount_h, mount_d = (12.9, 1.4, 9.90)
epsilon = 1

assert width < mount_w - epsilon, "mask width too big"
assert height < mount_h - epsilon, "mask height too big"
assert os.path.exists(fp), "folder does not exist"

file_name = os.path.join(fp, "mask_adapter.stl")

# Prevent accidental overwrite
if(os.path.isfile(file_name)):
print ("Warning: already find mask_adapter.stl at " + fp)
if (input("Overwrite ? y/n") != "y"):
print("Abort adapter generation.")
return

# Construct the outer layer of the mask
adapter = (
cq.Workplane("front")
.rect(mount_w, mount_d)
.rect(width,height)
.extrude(mount_h)
)

dent_dim = 0.4 # Width and height of dent

# Construct the dent to keep the mask secure
dent = (
cq.Workplane("front")
.rect(width,height)
.rect(width - 2*dent_dim, height - 2*dent_dim)
.extrude(dent_dim)
)

# Join the 2 shape in one
adapter = adapter.union(dent)

# Save into path
cq.exporters.export(adapter, file_name)