Skip to content

Change file structure + Modularize codes + Fix reticle detection qThread bug #137

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

Merged
merged 65 commits into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
b05faf5
remove 'img' folder and use 'ui/resource/'
hannalee2 Apr 1, 2025
8514db9
move 'debug_image' folder to 'debug/debug_image'
hannalee2 Apr 1, 2025
847bb53
Change the file structure
hannalee2 Apr 1, 2025
f3d3c32
Define path configs (ui_dir, debug_dir, etc) in config_path.py and us…
hannalee2 Apr 1, 2025
376d452
Move debug log file setup to config_path.py from __main__()
hannalee2 Apr 1, 2025
c8ff38f
Pass flake8 and interrogate
hannalee2 Apr 1, 2025
6e43e65
Update tag release
hannalee2 Apr 1, 2025
b45bf4c
Move src files under subfolder
hannalee2 Apr 2, 2025
7126041
Move CLI setup to config/cli.py
hannalee2 Apr 2, 2025
d4eb63b
Move print args info to cli.py
hannalee2 Apr 2, 2025
f235cf5
Merge branch 'feature-file-structure' into dev
hannalee2 Apr 3, 2025
6d1b82e
Add ASCII art and add cli args option for test mode
hannalee2 Apr 3, 2025
26ca859
Remove unused codes
hannalee2 Apr 3, 2025
49977cb
Pass args into model
hannalee2 Apr 3, 2025
b3dc7b4
Change logger level
hannalee2 Apr 3, 2025
efa5251
Pass test_mode args to reticle detection modules
hannalee2 Apr 3, 2025
7ccfcd3
Concise reticle detection process() function
hannalee2 Apr 3, 2025
8cc55eb
Draw the processed image on test_mode
hannalee2 Apr 3, 2025
a7ef0f7
Added qvec/tvec print function and uncommnet
hannalee2 Apr 25, 2025
407d308
Remove dilate function to get tight mask to the reticle glass
hannalee2 Apr 25, 2025
39651b9
Change the allowed time for the retice detection
hannalee2 Apr 25, 2025
ee237c5
Change the function name and module-level constant
hannalee2 Apr 25, 2025
1bc92b5
Implement the camera base binding
hannalee2 Apr 25, 2025
d2ca773
Use camera base binding for mockCamera and VideoSource
hannalee2 Apr 25, 2025
0b60201
Use camera base binding
hannalee2 Apr 25, 2025
58bb1fb
Added num_mock_cameras args option on CLI
hannalee2 Apr 25, 2025
90f403b
Allow mutlple mock cameras for test
hannalee2 Apr 26, 2025
66c7d0d
Multiplemock camera features
hannalee2 Apr 27, 2025
df79ee6
Move camera modules to parallax/camera/ folder
hannalee2 Apr 27, 2025
b5c7243
Add ScreenWidgetManger module to delegate functions from mainWindow
hannalee2 Apr 28, 2025
c65848d
Change user_setting_manager module to classmethod
hannalee2 Apr 28, 2025
e812a22
Call display screens from ScreenWidgetManager
hannalee2 Apr 28, 2025
fa5c1b7
Move the settings_refresh_timer to widget_manager
hannalee2 Apr 28, 2025
2cf64ed
Added screen_setting module
hannalee2 Apr 28, 2025
51cf03e
Update screen setting menu
hannalee2 Apr 28, 2025
515bb91
Update camera name on screens on switch
hannalee2 Apr 28, 2025
e8385d8
Remove unused codes
hannalee2 Apr 28, 2025
d6aae1b
Remove unused codes
hannalee2 Apr 29, 2025
86bb988
Implemented user selected img display on the test mode
hannalee2 Apr 29, 2025
8c84ea8
Mock camera sends fresh frame on request
hannalee2 Apr 29, 2025
2f3e5b0
Update TODO comments
hannalee2 Apr 29, 2025
168eb41
Implement reticle_detect_handler modules (reticle detection button ha…
hannalee2 Apr 29, 2025
241589f
Change the file name
hannalee2 Apr 29, 2025
c773e07
remove unused lib
hannalee2 Apr 29, 2025
646a704
remove QWidget instance
hannalee2 Apr 29, 2025
2f3c303
Add probe calibration handler widget
hannalee2 Apr 30, 2025
1e4f12e
Implemented probe_calibration_handler
hannalee2 Apr 30, 2025
94fddde
remove stage_widget module. (moved to control_panel)
hannalee2 Apr 30, 2025
59fb867
Remove debug print msg
hannalee2 Apr 30, 2025
d5d243f
Change CLI args name for number of mock cameras
hannalee2 Apr 30, 2025
20f1a10
Chang the logger level
hannalee2 Apr 30, 2025
086cfde
fixbug - reset reticle detection button to False
hannalee2 Apr 30, 2025
a6d8dae
Change orer in returning reticle detection default status
hannalee2 May 1, 2025
b681349
Fix the reticle detection freezing
hannalee2 May 2, 2025
ff3b6ff
Add default unning_flag lambda to functions
hannalee2 May 2, 2025
96d878d
Fix the module location
hannalee2 May 2, 2025
944c545
Fix the calculator test codes
hannalee2 May 2, 2025
e99ad8c
Pass camera test
hannalee2 May 2, 2025
d7c7235
Add default value for model args
hannalee2 May 2, 2025
43303d2
Remove the deprecate functions
hannalee2 May 2, 2025
0363742
Fix the user setting manager test codes
hannalee2 May 3, 2025
aa9a31c
Linters: Pass flake8
hannalee2 May 3, 2025
aa97163
Update release version
hannalee2 May 3, 2025
136fffe
Change logger lever to WARNING from DEBUG
hannalee2 May 5, 2025
d3c66d8
Allosw video source for the mockCamera
hannalee2 May 5, 2025
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
10 changes: 3 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ parallax/*.png
*.npz
*.pkl
*.csv
data
training
env
gitkey
Expand All @@ -15,19 +14,16 @@ gitkey.pub
# Distribution / packaging
*.egg-info
build/
debug/
debug_images/
wheels/
lib/
dist/

# Sphinx documentation
docs/_build/

# User-settings
ui/settings.json
ui/stage_server_config.json
ui/reticle_metadata.json
# User-specific files
data
debug

# Unit test / coverage reports
.coverage
Expand Down
Binary file removed img/arrow-right.png
Binary file not shown.
Binary file removed img/gear.png
Binary file not shown.
Binary file removed img/recordingButton.png
Binary file not shown.
Binary file removed img/sextant.png
Binary file not shown.
Binary file removed img/snapshotButton_white.png
Binary file not shown.
Binary file removed img/stop-sign.png
Binary file not shown.
Binary file removed img/target.png
Binary file not shown.
2 changes: 1 addition & 1 deletion parallax/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os

__version__ = "1.5.1"
__version__ = "1.7.0"

# allow multiple OpenMP instances
os.environ["KMP_DUPLICATE_LIB_OK"] = "True"
80 changes: 15 additions & 65 deletions parallax/__main__.py
Original file line number Diff line number Diff line change
@@ -1,85 +1,35 @@
"""
Parallax: A GUI application for controlling hardware devices.
"""

import argparse
import atexit
import logging
import os

from PyQt5.QtWidgets import QApplication

from parallax.main_window_wip import MainWindow as MainWindowV2
from parallax.model import Model


def setup_logging():
"""Set up logging to file."""
logger = logging.getLogger()
logger.handlers.clear()
logger.setLevel(logging.WARNING)

# Create the directory if it doesn't exist
package_dir = os.path.dirname(os.path.abspath(__file__))
debug_dir = os.path.join(os.path.dirname(package_dir), "debug")
os.makedirs(debug_dir, exist_ok=True)
log_file_path = os.path.join(debug_dir, "parallax_debug.log")

with open(log_file_path, "w"):
pass # Clear the log file

log_handler = logging.FileHandler(log_file_path)
log_handler.setLevel(logging.DEBUG)
log_handler.setFormatter(
logging.Formatter(
fmt="%(asctime)s:%(name)s:%(levelname)s: %(message)s"
)
)
logger.addHandler(log_handler)
from .main_window import MainWindow
from .model import Model
from .config.config_path import setup_logging, PARALLAX_ASCII
from .config.cli import parse_args, print_arg_info


# Main function to run the Parallax application
if __name__ == "__main__":
# Parse command line arguments to configure application behavior
parser = argparse.ArgumentParser()
parser.add_argument(
"-d",
"--dummy",
action="store_true",
help="Dummy mode for testing without hardware",
)
# Print the ASCII art
print(PARALLAX_ASCII)

parser.add_argument(
"-b",
"--bundle_adjustment",
action="store_true",
help="Enable bundle adjustment feature",
)
args = parser.parse_args()
# Parse command line arguments
args = parse_args()
print_arg_info(args)

# Print a message if running in dummy mode (no hardware interaction)
if args.dummy:
print("\nRunning in dummy mode; hardware devices not accessible.")
# Print a message if bundle adjustment is enabled
if args.bundle_adjustment:
print("\nBundle adjustment feature enabled.")

# Set up logging as configured in the setup_logging function
# Set up logging
setup_logging()

# Initialize the Qt application
app = QApplication([])

# Initialize the data model with version "V2"
model = Model(version="V2", dummy=args.dummy, bundle_adjustment=args.bundle_adjustment)
main_window = MainWindowV2(model, dummy=args.dummy) # main window

# Show the main window on screen
# Initialize the model and main window
model = Model(args)
main_window = MainWindow(model)
main_window.show()
# Start the Qt application's main loop
app.exec()

# Register cleanup functions to be called on program termination
atexit.register(model.clean) # Clean up resources used by the model
# Save user configurations on exit
# Clean up on exit
atexit.register(model.clean)
atexit.register(main_window.save_user_configs)
Empty file added parallax/cameras/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@ def get_origin_xyz(self):
x = tuple(imgpts[0].ravel().astype(int))
y = tuple(imgpts[1].ravel().astype(int))
z = tuple(imgpts[2].ravel().astype(int))

"""
# Uncomment to print quaternion and translation vector
R, _ = cv2.Rodrigues(rvecs)
quat = Rscipy.from_matrix(R).as_quat() # [QX, QY, QZ, QW]
QX, QY, QZ, QW = quat
TX, TY, TZ = tvecs.flatten()
print(f"{self.name}: {QW} {QX} {QY} {QZ} {TX} {TY} {TZ}")
"""

return origin, x, y, z
else:
return None
Expand Down Expand Up @@ -378,7 +388,7 @@ def change_coords_system_from_camA_to_global(self, camA, camB, points_3d_AB, pri
"""
logger.debug(f"=== {camA}, World to Camera transformation ====")
logger.debug(f"rvecs: {self.rvecA}")
logger.debug(f"tvecs: {self.rvecA}")
logger.debug(f"tvecs: {self.tvecA}")

if print_results:
print(f"=== {camA}, World to Camera transformation ====")
Expand Down
Loading
Loading