Skip to content

Commit

Permalink
Samples: Automatic updates to public repository
Browse files Browse the repository at this point in the history
Remember to do the following:
    1. Ensure that modified/deleted/new files are correct
    2. Make this commit message relevant for the changes
    3. Force push
    4. Delete branch after PR is merged

If this commit is an update from one SDK version to another,
make sure to create a release tag for previous version.
  • Loading branch information
csu-bot-zivid committed Oct 25, 2024
1 parent dc99df8 commit 4579f19
Show file tree
Hide file tree
Showing 92 changed files with 6,951 additions and 72 deletions.
49 changes: 33 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,16 @@ from the camera can be used.
to the ArUco marker on a Zivid Calibration Board.
- [roi\_box\_via\_checkerboard](https://github.com/zivid/zivid-python-samples/tree/master/source/applications/advanced/roi_box_via_checkerboard.py) - Filter the point cloud based on a ROI box given relative
to the Zivid Calibration Board.
- [transform\_point\_cloud\_from\_millimeters\_to\_meters](https://github.com/zivid/zivid-python-samples/tree/master/source/applications/advanced/transform_point_cloud_from_millimeters_to_meters.py) - Transform point cloud data from millimeters to meters.
- [transform\_point\_cloud\_via\_aruco\_marker](https://github.com/zivid/zivid-python-samples/tree/master/source/applications/advanced/transform_point_cloud_via_aruco_marker.py) - Transform a point cloud from camera to ArUco marker
coordinate frame by estimating the marker's pose from the
point cloud.
- [transform\_point\_cloud\_via\_checkerboard](https://github.com/zivid/zivid-python-samples/tree/master/source/applications/advanced/transform_point_cloud_via_checkerboard.py) - Transform a point cloud from camera to checkerboard (Zivid
Calibration Board) coordinate frame by getting checkerboard
pose from the API.
- **hand\_eye\_calibration**
- [hand\_eye\_gui](https://github.com/zivid/zivid-python-samples/tree/master/source/applications/advanced/hand_eye_calibration/hand_eye_gui.py) - Hand-Eye Calibration GUI
- [pose\_conversion\_gui](https://github.com/zivid/zivid-python-samples/tree/master/source/applications/advanced/hand_eye_calibration/pose_conversion_gui.py) - Convert between different rotation formats with a GUI:
- [pose\_conversions](https://github.com/zivid/zivid-python-samples/tree/master/source/applications/advanced/hand_eye_calibration/pose_conversions.py) - Convert to/from Transformation Matrix (Rotation Matrix
+ Translation Vector).
- [robodk\_hand\_eye\_calibration](https://github.com/zivid/zivid-python-samples/tree/master/source/applications/advanced/hand_eye_calibration/robodk_hand_eye_calibration/robodk_hand_eye_calibration.py) - Generate a dataset and perform hand-eye calibration
Expand All @@ -142,14 +145,18 @@ from the camera can be used.
- **ur\_hand\_eye\_calibration**
- [universal\_robots\_perform\_hand\_eye\_calibration](https://github.com/zivid/zivid-python-samples/tree/master/source/applications/advanced/hand_eye_calibration/ur_hand_eye_calibration/universal_robots_perform_hand_eye_calibration.py) - Script to generate a dataset and perform hand-eye
calibration using a Universal Robot UR5e robot.
- **sample\_utils**
- [calibration\_board\_utils](https://github.com/zivid/zivid-python-samples/tree/master/source/sample_utils/calibration_board_utils.py) - Utility functions for the Zivid calibration board.
- [display](https://github.com/zivid/zivid-python-samples/tree/master/source/sample_utils/display.py) - Display relevant data for Zivid Samples.
- [paths](https://github.com/zivid/zivid-python-samples/tree/master/source/sample_utils/paths.py) - Get relevant paths for Zivid Samples.
- [robodk\_tools](https://github.com/zivid/zivid-python-samples/tree/master/source/sample_utils/robodk_tools.py) - Robot Control Module
- [save\_load\_matrix](https://github.com/zivid/zivid-python-samples/tree/master/source/sample_utils/save_load_matrix.py) - Save and load Zivid 4x4 transformation matrices from and to
YAML files.
- [white\_balance\_calibration](https://github.com/zivid/zivid-python-samples/tree/master/source/sample_utils/white_balance_calibration.py) - Balance color for 2D capture using white surface as reference.
- **modules**
- **zividsamples**
- [calibration\_board\_utils](https://github.com/zivid/zivid-python-samples/tree/master/modules/zividsamples/calibration_board_utils.py) - Utility functions for the Zivid calibration board.
- [display](https://github.com/zivid/zivid-python-samples/tree/master/modules/zividsamples/display.py) - Display relevant data for Zivid Samples.
- [paths](https://github.com/zivid/zivid-python-samples/tree/master/modules/zividsamples/paths.py) - Get relevant paths for Zivid Samples.
- [robodk\_tools](https://github.com/zivid/zivid-python-samples/tree/master/modules/zividsamples/robodk_tools.py) - Robot Control Module
- [save\_load\_matrix](https://github.com/zivid/zivid-python-samples/tree/master/modules/zividsamples/save_load_matrix.py) - Save and load Zivid 4x4 transformation matrices from and
to YAML files.
- [transformation\_matrix](https://github.com/zivid/zivid-python-samples/tree/master/modules/zividsamples/transformation_matrix.py) - Convenience functions and a class for 4x4 transformation
matrices.
- [white\_balance\_calibration](https://github.com/zivid/zivid-python-samples/tree/master/modules/zividsamples/white_balance_calibration.py) - Balance color for 2D capture using white surface as
reference.
- **applications**
- **advanced**
- **robot\_guidance**
Expand All @@ -175,20 +182,30 @@ The recommended Python version for these samples is 3.7 - 3.9.
2. [Download Zivid Sample
Data](https://support.zivid.com/latest//api-reference/samples/sample-data.html).

3. Install the runtime requirements using IDE or command line:
3. Check out the Zivid Python samples repository:

``` sourceCode bash
pip install -r requirements.txt
git clone http://github.com/zivid/zivid-python-samples.git
```
4. Add the directory source to PYTHONPATH. Navigate to the root of the
repository and run:
- PowerShell: `$env:PYTHONPATH=$env:PYTHONPATH + ";$PWD\\source"`
- cmd: `set PYTHONPATH="$PYTHONPATH;$PWD\\source"`
- bash: `export PYTHONPATH="$PYTHONPATH:$PWD/source"`
4. Install the runtime requirements using IDE or command line:
>
>
> ``` sourceCode bash
> cd zivid-python-samples
> pip install -r requirements.txt
> ```
5. Open and run one of the samples.
-----
Note:
Running GUI samples on Windows should be done via `pythonw`.
-----
## Support
Expand Down
4 changes: 3 additions & 1 deletion continuous-integration/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ function install_www_deb {
install_www_deb "https://downloads.zivid.com/sdk/releases/2.13.1+18e79e79-1/u${VERSION_ID:0:2}/zivid_2.13.1+18e79e79-1_amd64.deb" || exit

python3 -m pip install --upgrade pip || exit
python3 -m pip install --requirement "$ROOT_DIR/requirements.txt" || exit
pushd "$ROOT_DIR" || exit
python3 -m pip install --requirement "./requirements.txt" || exit
popd || exit

echo Success! ["$(basename $0)"]
41 changes: 41 additions & 0 deletions modules/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[tool.black]
line-length = 120

[project]
name = "zivid_samples_extra_modules"
version = "0.1.0"
description = "Extra modules for Zivid Python samples"
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"importlib_resources; python_version < '3.9'",
"matplotlib",
"nptyping",
"numpy",
"open3d; python_version <= '3.11'",
"opencv-python",
"pyyaml",
"pyqt5",
"robodk",
"scipy",
"zivid"
]

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
where = ["."]

[tool.setuptools.package-data]
"zividsamples" = ["images/*.png", "images/**/*.png", "images/*.ico", "images/**/*.ico"]
Empty file.
File renamed without changes.
187 changes: 187 additions & 0 deletions modules/zividsamples/gui/buttons_widget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
from typing import List

from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QApplication, QGroupBox, QHBoxLayout, QLabel, QPushButton, QVBoxLayout, QWidget
from zividsamples.gui.hand_eye_configuration import HandEyeConfiguration


class CameraButtonsWidget(QWidget):
connect_button_clicked = pyqtSignal()
capture_button_clicked = pyqtSignal()

def __init__(
self,
capture_button_text="Capture",
already_connected: bool = False,
parent=None,
):
super().__init__(parent)

# Define buttons
connect_button_text = "Connected" if already_connected else "Connect"
self.connect_button = QPushButton(connect_button_text)
self.connect_button.setCheckable(True)
self.connect_button.setChecked(already_connected)
self.connect_button.setStyleSheet("background-color: green;" if already_connected else "")
self.connect_button.setObjectName("Camera-connect_button")
self.capture_button = QPushButton(capture_button_text)
self.capture_button.setCheckable(True)
self.capture_button.setEnabled(already_connected)
self.capture_button.setObjectName("Camera-capture_button")

self.information_label = QLabel()
self.information_label.hide()

# Connect signals
self.capture_button.clicked.connect(self.on_capture_button_clicked)
self.connect_button.clicked.connect(self.on_connect_button_clicked)

# Add buttons to layout
capture_group_box = QGroupBox("Camera")
capture_group_box_layout = QVBoxLayout()
capture_group_box.setLayout(capture_group_box_layout)

self.buttons_layout = QHBoxLayout()
self.buttons_layout.addWidget(self.connect_button)
self.buttons_layout.addWidget(self.capture_button)
capture_group_box_layout.addLayout(self.buttons_layout)
capture_group_box_layout.addWidget(self.information_label)

layout = QHBoxLayout()
layout.addWidget(capture_group_box)

self.setLayout(layout)

def on_capture_button_clicked(self):
self.capture_button.setChecked(True)
self.capture_button.setStyleSheet("background-color: yellow;")
QApplication.processEvents()
self.capture_button_clicked.emit()
self.capture_button.setChecked(False)
self.capture_button.setStyleSheet("")

def on_connect_button_clicked(self):
self.connect_button.setChecked(True)
self.connect_button.setStyleSheet("background-color: yellow;")
QApplication.processEvents()
self.connect_button_clicked.emit()

def set_connection_status(self, connected: bool):
self.connect_button.setText("Connected" if connected else "Connect")
self.connect_button.setChecked(connected)
self.connect_button.setStyleSheet("background-color: green;" if connected else "")
self.capture_button.setEnabled(connected)

def set_information(self, text: str):
if text == "":
self.information_label.hide()
else:
self.information_label.show()
self.information_label.setText(text)

def disable_buttons(self):
self.connect_button.setEnabled(False)
self.capture_button.setEnabled(False)

def enable_buttons(self):
self.connect_button.setEnabled(True)
self.capture_button.setEnabled(True)

def get_tab_widgets_in_order(self) -> List[QWidget]:
return [self.connect_button, self.capture_button]


class HandEyeCalibrationButtonsWidget(QWidget):
use_data_button_clicked = pyqtSignal()
calibrate_button_clicked = pyqtSignal()

def __init__(self, parent=None):
super().__init__(parent)

# Define buttons
self.use_data_button = QPushButton("Use Data")
self.use_data_button.setObjectName("HandEye-use_data_button")
self.calibrate_button = QPushButton("Calibrate")
self.calibrate_button.setObjectName("HandEye-calibrate_button")

# Connect signals
self.use_data_button.clicked.connect(self.on_use_data_button_clicked)
self.calibrate_button.clicked.connect(self.on_calibrate_button_clicked)

# Add buttons to layout
calibrate_group_box = QGroupBox("Calibrate")
calibrate_group_box_layout = QHBoxLayout()
calibrate_group_box.setLayout(calibrate_group_box_layout)

calibrate_group_box_layout.addWidget(self.use_data_button)
calibrate_group_box_layout.addWidget(self.calibrate_button)

buttons_layout = QHBoxLayout()
buttons_layout.addWidget(calibrate_group_box)

self.setLayout(buttons_layout)

def on_calibrate_button_clicked(self):
self.calibrate_button.setStyleSheet("background-color: yellow;")
QApplication.processEvents()
self.calibrate_button_clicked.emit()
self.calibrate_button.setStyleSheet("")

def on_use_data_button_clicked(self):
self.use_data_button.setStyleSheet("background-color: yellow;")
QApplication.processEvents()
self.use_data_button_clicked.emit()
self.use_data_button.setStyleSheet("")

def disable_buttons(self):
self.use_data_button.setEnabled(False)
self.calibrate_button.setEnabled(False)

def enable_buttons(self):
self.use_data_button.setEnabled(True)
self.calibrate_button.setEnabled(True)

def get_tab_widgets_in_order(self) -> List[QWidget]:
return [self.use_data_button, self.calibrate_button]


class HandEyeVerificationButtonsWidget(QWidget):
project_button_clicked = pyqtSignal()

def __init__(
self,
hand_eye_configuration: HandEyeConfiguration,
parent=None,
):
super().__init__(parent)

# Define buttons
self.project_button = QPushButton()
self.project_button.setCheckable(True)
self.project_button.setDisabled(True)
self.on_hand_eye_configuration_updated(hand_eye_configuration)

# Connect signals
self.project_button.clicked.connect(self.on_project_button_clicked)

# Add buttons to layout
verify_group_box = QGroupBox("Projection")
verify_group_box_layout = QHBoxLayout()
verify_group_box.setLayout(verify_group_box_layout)

verify_group_box_layout.addWidget(self.project_button)

buttons_layout = QHBoxLayout()
buttons_layout.addWidget(verify_group_box)

self.setLayout(buttons_layout)

def on_project_button_clicked(self):
self.project_button_clicked.emit()
if self.project_button.isChecked():
self.project_button.setStyleSheet("background-color: green;")
else:
self.project_button.setStyleSheet("")

def on_hand_eye_configuration_updated(self, hand_eye_configuration: HandEyeConfiguration):
self.project_button.setText(f"Project on {hand_eye_configuration.calibration_object.name}")
Loading

0 comments on commit 4579f19

Please sign in to comment.