Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
e10harvey committed Feb 13, 2025
1 parent 339a5cb commit e6cabd9
Show file tree
Hide file tree
Showing 272 changed files with 3,989 additions and 3,988 deletions.
8 changes: 4 additions & 4 deletions opencsp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ def apply_command_line_arguments(settings_from_ini: configparser.ConfigParser) -

# parse the command line
parser = argparse.ArgumentParser(
prog="OpenCSP/__init__.py", description='OpenCSP settings parser', add_help=False, exit_on_error=False
prog="OpenCSP/__init__.py", description="OpenCSP settings parser", add_help=False, exit_on_error=False
)
parser.add_argument(
'--dir-input',
"--dir-input",
dest="dir_input",
default="",
type=str,
help="Use the given directory value as the input directory instead of [opencsp_root_path]/[large_data_example_dir].",
)
parser.add_argument(
'--dir-output',
"--dir-output",
dest="dir_output",
default="",
type=str,
Expand Down Expand Up @@ -125,4 +125,4 @@ def apply_command_line_arguments(settings_from_ini: configparser.ConfigParser) -
print(f"opencsp_settings[{section}][{key}]={opencsp_settings[section][key]}")

opencsp_settings = apply_command_line_arguments(opencsp_settings)
__all__ = ['opencsp_settings']
__all__ = ["opencsp_settings"]
172 changes: 86 additions & 86 deletions opencsp/app/camera_calibration/CameraCalibration.py

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions opencsp/app/camera_calibration/lib/ViewAnnotatedImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, root: tkinter.Tk, images: list[ndarray], image_names: list[st
self.idx_im = 0

# Set title
self.root.title('View Annotated Images')
self.root.title("View Annotated Images")

# Get screen height/width
screen_width = root.winfo_screenwidth()
Expand All @@ -44,7 +44,7 @@ def __init__(self, root: tkinter.Tk, images: list[ndarray], image_names: list[st
self.height = screen_height - 160

# Set size of GUI
self.root.geometry(f'{screen_width - 60:d}x{screen_height - 80:d}+20+0')
self.root.geometry(f"{screen_width - 60:d}x{screen_height - 80:d}+20+0")

# Set escape to exit window
self.root.bind("<Escape>", lambda e: self.close())
Expand All @@ -53,23 +53,23 @@ def __init__(self, root: tkinter.Tk, images: list[ndarray], image_names: list[st

# Create image title
self.var_title = tkinter.StringVar(value=image_names[self.idx_im])
title = tkinter.Label(root, textvariable=self.var_title, font=('calibre', 15, 'bold'))
title = tkinter.Label(root, textvariable=self.var_title, font=("calibre", 15, "bold"))

# Create drawing canvas
self.canvas = tkinter.Canvas(root, width=self.width, height=self.height)
self.canvas.configure(background='white')
self.canvas.configure(background="white")

self.canvas_image = self.canvas.create_image(0, 0, anchor='nw')
self.canvas_image = self.canvas.create_image(0, 0, anchor="nw")

# Create buttons
btn_1 = tkinter.Button(root, text='Previous', width=20, command=self.show_prev)
btn_2 = tkinter.Button(root, text='Next', width=20, command=self.show_next)
btn_1 = tkinter.Button(root, text="Previous", width=20, command=self.show_prev)
btn_2 = tkinter.Button(root, text="Next", width=20, command=self.show_next)

# Place widgets
title.grid(row=0, column=0, columnspan=2, sticky='ew')
title.grid(row=0, column=0, columnspan=2, sticky="ew")
self.canvas.grid(row=1, column=0, columnspan=2)
btn_1.grid(row=2, column=0, sticky='e')
btn_2.grid(row=2, column=1, sticky='w')
btn_1.grid(row=2, column=0, sticky="e")
btn_2.grid(row=2, column=1, sticky="w")

# Show first image
self.update_image()
Expand Down Expand Up @@ -97,7 +97,7 @@ def update_image(self):
width = int(self.height * asp_cur)
height = self.height

image = Image.fromarray(image_array, 'RGB').resize(size=(width, height))
image = Image.fromarray(image_array, "RGB").resize(size=(width, height))
image_tk = ImageTk.PhotoImage(image)

# Display TK image
Expand Down
24 changes: 12 additions & 12 deletions opencsp/app/camera_calibration/lib/calibration_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,28 +133,28 @@ def calc_dx_dy(dist_coef):
ax1.quiver(mx[y1::N, x1::N], my[y1::N, x1::N], dx_rad[y1::N, x1::N], dy_rad[y1::N, x1::N])
ax1.set_ylim(0, img_shape[1])
ax1.set_xlim(0, img_shape[0])
ax1.set_xlabel('X (pixel)')
ax1.set_ylabel('Y (pixel)')
ax1.set_title('Radial Distortion')
ax1.axis('image')
ax1.set_xlabel("X (pixel)")
ax1.set_ylabel("Y (pixel)")
ax1.set_title("Radial Distortion")
ax1.axis("image")
ax1.grid()

# Plot tangential distortion
ax2.quiver(mx[y1::N, x1::N], my[y1::N, x1::N], dx_tan[y1::N, x1::N], dy_tan[y1::N, x1::N])
ax2.set_ylim(0, img_shape[1])
ax2.set_xlim(0, img_shape[0])
ax2.set_xlabel('X (pixel)')
ax2.set_ylabel('Y (pixel)')
ax2.set_title('Tangential Distortion')
ax2.axis('image')
ax2.set_xlabel("X (pixel)")
ax2.set_ylabel("Y (pixel)")
ax2.set_title("Tangential Distortion")
ax2.axis("image")
ax2.grid()

# Plot total distortion
ax3.quiver(mx[y1::N, x1::N], my[y1::N, x1::N], dx_tot[y1::N, x1::N], dy_tot[y1::N, x1::N])
ax3.set_ylim(0, img_shape[1])
ax3.set_xlim(0, img_shape[0])
ax3.set_xlabel('X (pixel)')
ax3.set_ylabel('Y (pixel)')
ax3.set_title('Total Distortion')
ax3.axis('image')
ax3.set_xlabel("X (pixel)")
ax3.set_ylabel("Y (pixel)")
ax3.set_title("Total Distortion")
ax3.axis("image")
ax3.grid()
48 changes: 24 additions & 24 deletions opencsp/app/camera_calibration/test/test_camera_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ def setup_class(cls, regenerate=False):
If true, saves data in output location instead of running unit tests, by default False
"""
# Get test data location
base_dir = os.path.join(os.path.dirname(__file__), 'data')
base_dir = os.path.join(os.path.dirname(__file__), "data")

# Pattern to search for captured images
image_pattern = os.path.join(base_dir, 'images/*.png')
test_data_file = os.path.join(base_dir, 'data_test.h5')
image_pattern = os.path.join(base_dir, "images/*.png")
test_data_file = os.path.join(base_dir, "data_test.h5")

# Define number of checkerboard corners
npts = (18, 23)

# Define camera name
cam_name = 'Test Camera'
cam_name = "Test Camera"

# Find all files
files = glob(image_pattern)
Expand Down Expand Up @@ -76,15 +76,15 @@ def setup_class(cls, regenerate=False):

# Save or load test data
datasets = [
'p_image_points',
'p_object_points',
'intrinsic_matrix',
'distortion_coeffs',
'image_shape_xy',
'r_cam_object',
'v_cam_object_cam',
'calibration_error',
'reprojection_errors',
"p_image_points",
"p_object_points",
"intrinsic_matrix",
"distortion_coeffs",
"image_shape_xy",
"r_cam_object",
"v_cam_object_cam",
"calibration_error",
"reprojection_errors",
]

# Save calculated image and object points
Expand Down Expand Up @@ -113,24 +113,24 @@ def setup_class(cls, regenerate=False):
]

save_hdf5_datasets(data, datasets, test_data_file)
print('Test data was created and saved to:', test_data_file)
print("Test data was created and saved to:", test_data_file)

else:
print('Performing tests...')
print("Performing tests...")

# Load saved data
data = load_hdf5_datasets(datasets, test_data_file)

# Save expected data in class
cls.p_image_points_exp = data['p_image_points']
cls.Pxyz_object_points_exp = data['p_object_points']
cls.intrinsic_matrix_exp = data['intrinsic_matrix']
cls.distortion_coeffs_exp = data['distortion_coeffs']
cls.image_shape_xy_exp = data['image_shape_xy']
cls.R_cam_object_exp = data['r_cam_object']
cls.V_cam_object_cam_exp = data['v_cam_object_cam']
cls.calibration_error_exp = data['calibration_error']
cls.reprojection_errors_exp = data['reprojection_errors']
cls.p_image_points_exp = data["p_image_points"]
cls.Pxyz_object_points_exp = data["p_object_points"]
cls.intrinsic_matrix_exp = data["intrinsic_matrix"]
cls.distortion_coeffs_exp = data["distortion_coeffs"]
cls.image_shape_xy_exp = data["image_shape_xy"]
cls.R_cam_object_exp = data["r_cam_object"]
cls.V_cam_object_cam_exp = data["v_cam_object_cam"]
cls.calibration_error_exp = data["calibration_error"]
cls.reprojection_errors_exp = data["reprojection_errors"]

def test_image_points(self):
np.testing.assert_allclose(self.p_image_points, self.p_image_points_exp)
Expand Down
Loading

0 comments on commit e6cabd9

Please sign in to comment.