Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
/.venv
/.venv39
/exit
*.log
*.log
*.cu3s
.history/*
output/
save/
.ipynb_checkpoints/
tiff_export
pansharpen_export/
view_export
envi_export/
cube_export/
125 changes: 93 additions & 32 deletions Example_1_Take_Snapshot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,31 @@
"execution_count": null,
"id": "b3391452-d716-4fb2-8977-fa95b09b54ff",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cuvis Python SDK Example 1\n",
"Initializing Cuvis\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\Users\\nima.ghorbani\\code-repos\\cuvis.python.examples\\.venv\\Lib\\site-packages\\cuvis\\General.py:4: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.\n",
" import pkg_resources\n"
]
}
],
"source": [
"# If the import of cuvis fails, the most common cause is a mismatch between\n",
"# the _cuvis_ python package and the installed version of the Cuvis SDK.\n",
"# Try re-installing both and make sure that the version numbers match exactly\n",
"import cuvis\n",
"import time\n",
"\n",
"print(\"Cuvis Python SDK Example 1\")\n",
"\n",
"# Initialize the Cuvis SDK using a settings-directory\n",
Expand All @@ -53,19 +71,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 20,
"id": "d345b826-29ba-4090-a7fa-4a016bd62905",
"metadata": {},
"outputs": [],
"source": [
"# Snapshot setup / User input\n",
"# Enter your data here!\n",
"import os\n",
"\n",
"snapshot_integration_time_ms = 100\n",
"save_directory = \"./directory to save the measurements to here\"\n",
"save_directory = \"./output\" # set to a location where you want to save the data\n",
"\n",
"has_camera = False # Set to True if you have a camera connected\n",
"camera_serial_number_str = \"Your camera serial here\"\n",
"\n",
"# If using demo data instead of a physical camera, change this to your download location:\n",
"demo_session_file = \"/SDK_Training_Example_Data/WinterUlm_X20P.cu3s\"\n",
"demo_session_file = \"./SDK_Training_Example_Data/WinterUlm_X20P.cu3s\"\n",
"assert os.path.exists(demo_session_file), f\"Demo session file not found: {demo_session_file}\"\n",
"\n",
"camera_calibration_file_path = F\"./factory/{camera_serial_number_str}.cu3c\""
]
Expand All @@ -88,14 +111,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 21,
"id": "34fdcae0-4b4b-49a3-b426-8bfa78f3d716",
"metadata": {},
"outputs": [],
"source": [
"# Skip this if working without a physical camera\n",
"print(\"Load camera calibration file\")\n",
"calib = cuvis.SessionFile(camera_calibration_file_path)"
"if has_camera:\n",
" print(\"Load camera calibration file\")\n",
" calib = cuvis.SessionFile(camera_calibration_file_path)"
]
},
{
Expand All @@ -112,10 +136,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 22,
"id": "05024d39-f138-42c7-abdc-9cd0a5c5b581",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Create CubeExporter\n"
]
}
],
"source": [
"# Setup the Cube Exporter for saving the measurements to disk in the SessionFile format (.cu3s)\n",
"print(\"Create CubeExporter\")\n",
Expand Down Expand Up @@ -144,25 +176,27 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 23,
"id": "b47e7223-b588-4b4d-8059-f15b44c8cfb2",
"metadata": {},
"outputs": [],
"source": [
"# Skip this if working without a physical camera\n",
"print(\"Loading Acquisition Context\")\n",
"acq = cuvis.AcquisitionContext(calib)\n",
"if has_camera:\n",
" # Create an AcquisitionContext to connect to the camera\n",
" print(\"Loading Acquisition Context\")\n",
" acq = cuvis.AcquisitionContext(calib)\n",
"\n",
"# Wait for camera connection to be established\n",
"print(\"Connecting with camera\")\n",
"while(not acq.ready):\n",
" time.sleep(1)\n",
" print(\".\", end=\"\")\n",
"print(\"\\nCamera connected!\")\n",
" # Wait for camera connection to be established\n",
" print(\"Connecting with camera\")\n",
" while(not acq.ready):\n",
" time.sleep(1)\n",
" print(\".\", end=\"\")\n",
" print(\"\\nCamera connected!\")\n",
"\n",
"# Set camera to software trigger\n",
"acq.operation_mode = cuvis.OperationMode.Software\n",
"acq.integration_time = snapshot_integration_time_ms"
" # Set camera to software trigger\n",
" acq.operation_mode = cuvis.OperationMode.Software\n",
" acq.integration_time = snapshot_integration_time_ms"
]
},
{
Expand All @@ -181,15 +215,26 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 24,
"id": "4080c54c-6341-4257-bbd4-d555372d8798",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Wait for Acqusition Context to be ready...\n",
"\n",
"Simulated camera loaded!\n"
]
}
],
"source": [
"# Simulated Acquisition: Skip this if working with a physical camera\n",
"session = cuvis.SessionFile(demo_session_file)\n",
"# Initialize the Acquisition Context in simulated camera mode\n",
"acq = cuvis.AcquisitionContext(session, simulate=True)\n",
"if not has_camera:\n",
" session = cuvis.SessionFile(demo_session_file)\n",
" # Initialize the Acquisition Context in simulated camera mode\n",
" acq = cuvis.AcquisitionContext(session, simulate=True)\n",
"\n",
"# Wait for the Acquisition Context to load the demo session file\n",
"print(\"Wait for Acqusition Context to be ready...\")\n",
Expand All @@ -215,10 +260,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 30,
"id": "99a6438c-70b7-4403-9b61-44385ff32a0e",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Measurement reports: AsyncResult.done\n"
]
}
],
"source": [
"# Optional: Name the recording\n",
"acq.session_info = cuvis.SessionData(\"My_Measurement\", 0, 0)\n",
Expand All @@ -234,10 +287,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 31,
"id": "7e6633d5-b1ed-4570-a1b6-5ed1b2dec105",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Measurement exported!\n"
]
}
],
"source": [
"# Export the measurement - write the data to the disk in SessionFile format using the CubeExporter\n",
"if status == cuvis.Async.AsyncResult.done:\n",
Expand All @@ -250,7 +311,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": ".venv (3.12.7)",
"language": "python",
"name": "python3"
},
Expand All @@ -264,7 +325,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.4"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
Loading