Skip to content

Mocksim merge #18

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

Open
wants to merge 65 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
7625d0b
start generic stage interface
campagnola Jan 4, 2023
addba05
Merge branch 'master' of github.com:AllenNeuralDynamics/parallax into…
campagnola Feb 10, 2023
0cca383
mock stage initial function
campagnola Feb 10, 2023
ecbcd95
add mock camera prototype
campagnola Feb 9, 2023
1bc6fa1
add radial distortion
campagnola Feb 9, 2023
c173639
fix distortion
campagnola Feb 9, 2023
4900969
add stereo rendering
campagnola Feb 9, 2023
3be68e2
tangential distortion + invert attempt
campagnola Feb 9, 2023
1761738
minor edits
campagnola Feb 10, 2023
c661925
moved mock code into package, mock camera test script is working again
campagnola Feb 10, 2023
8e35419
mock camera is rendering
campagnola Feb 10, 2023
1f7caed
mock sim working
campagnola Feb 10, 2023
f14092a
Update .gitignore
campagnola Feb 11, 2023
3eae984
Don't change CWD if possible -- this is global
campagnola Feb 11, 2023
903a987
Add config system with calibration path + mock sim options
campagnola Feb 11, 2023
3f41e1e
GUI updates:
campagnola Feb 11, 2023
9649654
Get calibration working again
campagnola Feb 11, 2023
01457ef
mock sim tweaks
campagnola Feb 11, 2023
3f5e0d5
Calibration working correctly on mock stage
campagnola Feb 12, 2023
cb0268b
add console command history and editor support
campagnola Feb 12, 2023
d089a40
move more calibration code to individual camera transforms
campagnola Feb 12, 2023
e84a6c5
make it easier to access selected calibration
campagnola Feb 12, 2023
a44d570
fix esc key
campagnola Feb 12, 2023
c29c569
store CS names with calibration
campagnola Feb 13, 2023
7a86da3
more efficient mock graphics
campagnola Feb 13, 2023
c5fe533
show stage position as it moves
campagnola Feb 13, 2023
6e8c8dc
use system names in calibration file name
campagnola Feb 13, 2023
5115afa
minor updates
campagnola Feb 13, 2023
8b23e35
Autoload calibrations, add move to selected button
campagnola Feb 13, 2023
fd44984
update calibrations after generating a new one
campagnola Feb 13, 2023
30f1557
Add extra move commands
campagnola Feb 13, 2023
e780f01
fix mock stage speed
campagnola Feb 13, 2023
b67fb6b
Add button for copying selected point
campagnola Feb 13, 2023
948cf91
make mock sim cmera grab threada-safe
campagnola Feb 13, 2023
762dba2
easier way to get calibrations per stage
campagnola Feb 13, 2023
0e0461e
Add tool for collecting training data
campagnola Feb 13, 2023
77cb9a4
bail out of training data collection if user cancels
campagnola Feb 14, 2023
70bc5c0
remove notes file
campagnola Feb 14, 2023
a7e2623
Add training data collector
campagnola Feb 14, 2023
56ca49a
minor fixes
campagnola Feb 14, 2023
df1f28f
added script for annotating training images
campagnola Feb 14, 2023
5cfaf2c
Merge branch 'training-data' into mock-sim
campagnola Feb 15, 2023
adfe9f6
Add template based autocalibration
campagnola Feb 15, 2023
f469b67
Add fast template matching
campagnola Feb 15, 2023
11b9994
move mock autocalibration to CalibrationWorker
campagnola Feb 15, 2023
ff8f580
Merge remote-tracking branch 'ai/master' into mocksim-merge
campagnola Mar 6, 2023
ca3fd15
minor fixes
campagnola Mar 6, 2023
c98ff9d
instantiate MockCameras even if PySpin is installed
chronopoulos Mar 7, 2023
83843d0
config.py: dont assume these directories exist
chronopoulos Mar 7, 2023
667ae12
rm "assert len(calibrations) > 0"
chronopoulos Mar 7, 2023
1f29ae7
remove call to CalibrationDialog.get_name
chronopoulos Mar 8, 2023
701bd16
ScreenWidget: update camera, foco menus on init
chronopoulos Mar 8, 2023
017eebb
fix 'ScreenWidget' object has no attribute 'screen_widget'
chronopoulos Mar 8, 2023
cf77561
fix blank buttons in ControlPanel
chronopoulos Mar 8, 2023
7009cfa
implement start_accuracy_test
chronopoulos Mar 8, 2023
57f56ac
StageDropdown: s/get_current_stage/current_stage
chronopoulos Mar 9, 2023
ea383e3
model: add {set,clear}_{lcorr,rcorr} methods
chronopoulos Mar 9, 2023
4896a39
fix accuracy test
chronopoulos Mar 9, 2023
6cedd8e
Fix console command history
campagnola Mar 22, 2023
be1ebfa
Fix delayed render
campagnola Mar 22, 2023
ef6e030
fix camera calibration test in mock_camera
campagnola Mar 23, 2023
b4a7397
move mock_camera to tools
campagnola Mar 23, 2023
04efbb1
Use better initial guesses for camera calibration
campagnola Mar 23, 2023
6ee3d7c
fix simple camera calibration in mock_camera
campagnola Mar 23, 2023
73e4e1a
fix mock_camera script update on mouse drag
campagnola Mar 24, 2023
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: 5 additions & 5 deletions parallax/accuracy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ def __init__(self, model, parent=None):
self.setMinimumWidth(300)

def start_accuracy_test(self):
print('TODO: start_accuracy_test')
self.model.start_accuracy_test(self.get_params())

def get_params(self):
params = {}
params['stage'] = self.stage_dropdown.get_current_stage()
params['stage'] = self.stage_dropdown.current_stage()
params['cal'] = self.model.calibrations[self.cal_dropdown.currentText()]
params['npoints'] = int(self.npoints_edit.text())
params['extent_um'] = float(self.extent_edit.text())
Expand Down Expand Up @@ -230,9 +230,9 @@ def __init__(self, params):

self.ready_to_go = False

def register_corr_points(self, lcorr, rcorr):
xyz_recon = self.cal.triangulate(lcorr, rcorr)
self.results.append(self.last_stage_point + xyz_recon.tolist())
def register_corr_points(self, corr_pt):
xyz_recon = self.cal.triangulate(corr_pt)
self.results.append(self.last_stage_point + xyz_recon.coordinates.tolist())

def carry_on(self):
self.ready_to_go = True
Expand Down
2 changes: 1 addition & 1 deletion parallax/calibration_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def run(self):
tip_pos = self.stage.get_tip_position()
pts = {}
for screen in Model.instance.main_window.screens():
camera = screen.screen_widget.camera
camera = screen.camera
pos = camera.camera_tr.map(tip_pos.coordinates)
pts[camera.name()] = pos[:2]
self.suggested_corr_points.emit(pts)
Expand Down
9 changes: 4 additions & 5 deletions parallax/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@

def list_cameras():
cameras = []
cameras.extend([
MockCamera(camera_params={'pitch': 70, 'yaw': 120}),
MockCamera(camera_params={'pitch': 70, 'yaw': 150}),
])
if PySpin is not None:
cameras.extend(PySpinCamera.list_cameras())
else:
cameras.extend([
MockCamera(camera_params={'pitch': 70, 'yaw': 120}),
MockCamera(camera_params={'pitch': 70, 'yaw': 150}),
])
return cameras


Expand Down
4 changes: 2 additions & 2 deletions parallax/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"show_axes": True,
"auto_select_corr_points": True,
},
"calibration_path": "./calibrations",
"console_history_file": "./console_history",
"calibration_path": "./",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you prefer calibrations here, or was tere another reason to make this change?

"console_history_file": "./",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console_history is a file; this should be left as-is

"console_edit_command": "code -g {fileName}:{lineNum}",
}

Expand Down
4 changes: 2 additions & 2 deletions parallax/control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ def __init__(self, model):
self.dropdown.activated.connect(self.handle_stage_selection)

self.settings_button = QPushButton()
self.settings_button.setIcon(QIcon('../img/gear.png'))
self.settings_button.setIcon(QIcon('./img/gear.png'))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More robust:

os.path.join(os.path.dirname(parallax.__file__), 'img', 'gear.png'))

self.settings_button.clicked.connect(self.handle_settings)

self.calibration_label = QLabel("")
self.cal_pt_btn = QPushButton('')
self.cal_pt_btn = QPushButton('Copy Calibration Point')
self.cal_pt_btn.clicked.connect(self.copy_cal_pt)

self.xcontrol = AxisControl('x')
Expand Down
7 changes: 3 additions & 4 deletions parallax/geometry_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ def cal_start_stop(self):
stage = dlg.get_stage()
res = dlg.get_resolution()
extent = dlg.get_extent()
name = dlg.get_name()
self.start_cal_thread(stage, res, extent, name)
self.start_cal_thread(stage, res, extent)
elif self.cal_start_stop_button.text() == 'Stop':
self.stop_cal_thread()

Expand Down Expand Up @@ -229,7 +228,7 @@ def show_rbt_tool(self):
self.rbt_tool.show()

def show_suggested_corr_points(self, pts):
screens = {screen.screen_widget.camera.name():screen for screen in self.model.main_window.screens()}
screens = {screen.camera.name():screen for screen in self.model.main_window.screens()}
for cam_name, pt in pts.items():
screens[cam_name].set_selected(pt)


3 changes: 2 additions & 1 deletion parallax/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,6 @@ def save_camera_frames(self):

def update_corr(self):
# send correspondence points to model
pts = [ctrl.screen_widget.get_selected() for ctrl in self.screens]
pts = [ctrl.get_selected() for ctrl in self.screens]
self.model.set_correspondence_points(pts)

22 changes: 16 additions & 6 deletions parallax/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def list_calibrations(self):
for cal in self.calibrations.values():
calibrations.append({'calibration': cal, 'from_cs': cal.from_cs, 'to_cs': cal.to_cs, 'timestamp': cal.timestamp})

assert len(calibrations) > 0
return calibrations

def get_calibration(self, stage):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this gets the most recent calibration associated with a stage

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used for "move to selected" button

Expand Down Expand Up @@ -141,18 +140,29 @@ def add_transform(self, name, transform):
def get_transform(self, name):
return self.transforms[name]

def set_lcorr(self, xc, yc):
self.lcorr = [xc, yc]

def clear_lcorr(self):
self.lcorr = False

def set_rcorr(self, xc, yc):
self.rcorr = [xc, yc]

def clear_rcorr(self):
self.rcorr = False

def handle_accutest_point_reached(self, i, npoints):
self.msg_posted.emit('Accuracy test point %d (of %d) reached.' % (i+1,npoints))
self.clear_lcorr()
self.clear_rcorr()
self.msg_posted.emit('Highlight correspondence points and press C to continue')

def register_corr_points_accutest(self):
lcorr, rcorr = self.lcorr, self.rcorr
if (lcorr and rcorr):
self.accutest_worker.register_corr_points(lcorr, rcorr)
self.msg_posted.emit('Correspondence points registered: (%d,%d) and (%d,%d)' % \
(lcorr[0],lcorr[1], rcorr[0],rcorr[1]))
corr_pt = self.get_image_point()
if corr_pt is not None:
self.accutest_worker.register_corr_points(corr_pt)
self.msg_posted.emit('Correspondence points registered.')
self.accutest_worker.carry_on()
else:
self.msg_posted.emit('Highlight correspondence points and press C to continue')
Expand Down
2 changes: 2 additions & 0 deletions parallax/screen_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def __init__(self, filename=None, model=None, parent=None):
self.detector_menu = self.parallax_menu.addMenu("Detectors")
self.view_box.menu.insertMenu(self.view_box.menu.actions()[0], self.parallax_menu)

self.update_camera_menu()
self.update_focus_control_menu()
self.update_filter_menu()
self.update_detector_menu()

Expand Down