-
Notifications
You must be signed in to change notification settings - Fork 11
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
SofastFixed unit tests and test data #63
Changes from all commits
e292ecf
fdbf02b
6b4c8b4
95b18c0
fa6a6c6
f1dce38
f6b94ae
edd5055
aba8fc0
ff99732
87cc0c8
25c31db
792d5d4
a0d84b8
19bd83f
99261f2
1a18211
62441a6
77a2393
3655249
efa006e
87ec271
00269ed
ed6cb6b
d1ec52c
3be9679
879bac7
76c6788
aa68056
5252760
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
"""Generates downsampled dataset used for calibrating the 3d locations of fixed | ||
pattern dots. | ||
"""Generates downsampled dataset for dot_location_calibration | ||
""" | ||
|
||
from glob import glob | ||
from os.path import join, basename | ||
import shutil | ||
from os.path import join, basename, abspath | ||
import sys | ||
|
||
import imageio.v3 as imageio | ||
|
@@ -19,17 +17,14 @@ | |
def generate_data(): | ||
"""Downsamples and saves files""" | ||
# Define file locations | ||
dir_sample_data = join( | ||
opencsp_code_dir(), '../../sample_data/deflectometry/calibration_dot_locations/data_measurement' | ||
dir_cal_data = join( | ||
opencsp_code_dir(), '../../sample_data/deflectometry/sandia_lab/dot_locations_calibration/data_measurement' | ||
) | ||
|
||
files_images = glob(join(dir_sample_data, 'images/*.JPG')) | ||
file_camera_cal = join(dir_sample_data, 'camera_image_calibration.h5') | ||
file_point_locs = join(dir_sample_data, 'point_locations.csv') | ||
file_camera_def = join(dir_sample_data, 'camera_deflectometry.h5') | ||
file_image_def = join(dir_sample_data, 'image_deflectometry_camera.png') | ||
files_images = glob(abspath(join(dir_cal_data, 'images/*.JPG'))) | ||
file_camera_cal = abspath(join(dir_cal_data, 'camera_calibration.h5')) | ||
|
||
dir_save = join(opencsp_code_dir(), 'test/data/measurements_sofast_fixed/dot_location_calibration/measurements') | ||
dir_save = join(opencsp_code_dir(), 'test/data/dot_location_calibration') | ||
|
||
# Downsample marker/dot images | ||
n_downsample = 4 | ||
|
@@ -41,19 +36,13 @@ def generate_data(): | |
im_ds = ddg.downsample_images(im, n_downsample) | ||
# Save | ||
file_save = join(dir_save, 'images', basename(file)) | ||
imageio.imwrite(file_save, im_ds, quality=70) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes, the old struggle. Better images or smaller files? FYI: because .png and .gif images use a pallet of colors, you can sometimes get smaller files with lossless quality by using one of these formats. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the tip! I think these images might be too high of resolution. I tried png and gif and couldn't get the images smaller than JPG. I'll keep this in mind for the future though! |
||
imageio.imwrite(file_save, im_ds, quality=80) | ||
|
||
# Downsample cal camera | ||
print('Downsampling calibration camera...') | ||
cam_cal = ddg.downsample_camera(file_camera_cal, n_downsample) | ||
cam_cal.save_to_hdf(join(dir_save, basename(file_camera_cal))) | ||
|
||
# Save other files | ||
shutil.copy(file_point_locs, join(dir_save, basename(file_point_locs))) | ||
shutil.copy(file_camera_def, join(dir_save, basename(file_camera_def))) | ||
shutil.copy(file_image_def, join(dir_save, basename(file_image_def))) | ||
|
||
|
||
if __name__ == '__main__': | ||
generate_data() | ||
print('Done') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, the "opencsp" way to get the basename is with file_tools.path_components():
This is a little more verbose, and sometimes it is nicer to just use basename. Up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tip! I like that; in this particular instance, I'll probably keep it as-is because it's simpler, but I'll keep this in mind!