Skip to content

Commit 84db4d8

Browse files
committed
py_multiplane never called
1 parent 879fa07 commit 84db4d8

File tree

1 file changed

+57
-69
lines changed

1 file changed

+57
-69
lines changed

pyptv/ptv.py

Lines changed: 57 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from optv.segmentation import target_recognition
2222
from optv.tracking_framebuf import TargetArray
2323
from optv.tracker import Tracker, default_naming
24-
from optv.imgcoord import image_coordinates
2524

2625
from skimage.io import imread
2726
from skimage import img_as_ubyte
@@ -164,31 +163,18 @@ def py_correspondences_proc_c(exp):
164163
def py_determination_proc_c(n_cams, sorted_pos, sorted_corresp, corrected):
165164
"""Returns 3d positions"""
166165

167-
# Control parameters
168-
cpar = ControlParams(n_cams)
169-
cpar.read_control_par(b"parameters/ptv.par")
170-
171-
# Volume parameters
172-
vpar = VolumeParams()
173-
vpar.read_volume_par(b"parameters/criteria.par")
174-
175-
cals = []
176-
for i_cam in range(n_cams):
177-
cal = Calibration()
178-
tmp = cpar.get_cal_img_base_name(i_cam)
179-
cal.from_file(tmp + b".ori", tmp + b".addpar")
180-
cals.append(cal)
166+
cpar, spar, vpar, track_par, tpar, cals, epar = py_start_proc_c(n_cams)
181167

182168
# Distinction between quad/trip irrelevant here.
183169
sorted_pos = np.concatenate(sorted_pos, axis=1)
184170
sorted_corresp = np.concatenate(sorted_corresp, axis=1)
185171

186172
flat = np.array([
187-
corrected[i].get_by_pnrs(sorted_corresp[i]) for i in range(len(cals))
173+
corrected[i].get_by_pnrs(sorted_corresp[i]) for i in range(n_cams)
188174
])
189175
pos, rcm = point_positions(flat.transpose(1, 0, 2), cpar, cals, vpar)
190176

191-
if len(cals) < 4:
177+
if n_cams < 4:
192178
print_corresp = -1 * np.ones((4, sorted_corresp.shape[1]))
193179
print_corresp[:len(cals), :] = sorted_corresp
194180
else:
@@ -636,75 +622,77 @@ def py_calibration(sel):
636622

637623

638624

639-
def py_multiplanecalibration(exp):
640-
"""Performs multiplane calibration, in which for all cameras the pre-processed plane in multiplane.par al combined.
641-
Overwrites the ori and addpar files of the cameras specified in cal_ori.par of the multiplane parameter folder
642-
"""
625+
# def py_multiplanecalibration(exp):
626+
# """Performs multiplane calibration, in which for all cameras the pre-processed plane in multiplane.par al combined.
627+
# Overwrites the ori and addpar files of the cameras specified in cal_ori.par of the multiplane parameter folder
628+
# """
643629

644-
for i_cam in range(exp.n_cams): # iterate over all cameras
645-
all_known = []
646-
all_detected = []
647-
for i in range(exp.MultiParams.n_planes): # combine all single planes
630+
# for i_cam in range(exp.n_cams): # iterate over all cameras
631+
# all_known = []
632+
# all_detected = []
633+
# for i in range(exp.MultiParams.n_planes): # combine all single planes
648634

649-
c = exp.calParams.img_ori[i_cam][-9] # Get camera id
635+
# c = exp.calParams.img_ori[i_cam][-9] # Get camera id
650636

651-
file_known = exp.MultiParams.plane_name[i] + str(c) + ".tif.fix"
652-
file_detected = exp.MultiParams.plane_name[i] + str(c) + ".tif.crd"
637+
# file_known = exp.MultiParams.plane_name[i] + str(c) + ".tif.fix"
638+
# file_detected = exp.MultiParams.plane_name[i] + str(c) + ".tif.crd"
653639

654-
# Load calibration point information from plane i
655-
known = np.loadtxt(file_known)
656-
detected = np.loadtxt(file_detected)
640+
# # Load calibration point information from plane i
641+
# known = np.loadtxt(file_known)
642+
# detected = np.loadtxt(file_detected)
657643

658-
if np.any(detected == -999):
659-
raise ValueError(
660-
("Using undetected points in {} will cause " +
661-
"silliness. Quitting.").format(file_detected))
644+
# if np.any(detected == -999):
645+
# raise ValueError(
646+
# ("Using undetected points in {} will cause " +
647+
# "silliness. Quitting.").format(file_detected))
662648

663-
num_known = len(known)
664-
num_detect = len(detected)
649+
# num_known = len(known)
650+
# num_detect = len(detected)
665651

666-
if num_known != num_detect:
667-
raise ValueError(
668-
"Number of detected points (%d) does not match" +
669-
" number of known points (%d) for %s, %s" %
670-
(num_known, num_detect, file_known, file_detected))
652+
# if num_known != num_detect:
653+
# raise ValueError(
654+
# "Number of detected points (%d) does not match" +
655+
# " number of known points (%d) for %s, %s" %
656+
# (num_known, num_detect, file_known, file_detected))
671657

672-
if len(all_known) > 0:
673-
detected[:, 0] = (all_detected[-1][-1, 0] + 1 +
674-
np.arange(len(detected)))
658+
# if len(all_known) > 0:
659+
# detected[:, 0] = (all_detected[-1][-1, 0] + 1 +
660+
# np.arange(len(detected)))
675661

676-
# Append to list of total known and detected points
677-
all_known.append(known)
678-
all_detected.append(detected)
662+
# # Append to list of total known and detected points
663+
# all_known.append(known)
664+
# all_detected.append(detected)
679665

680-
# Make into the format needed for full_calibration.
681-
all_known = np.vstack(all_known)[:, 1:]
682-
all_detected = np.vstack(all_detected)
666+
# # Make into the format needed for full_calibration.
667+
# all_known = np.vstack(all_known)[:, 1:]
668+
# all_detected = np.vstack(all_detected)
683669

684-
targs = TargetArray(len(all_detected))
685-
for tix in range(len(all_detected)):
686-
targ = targs[tix]
687-
det = all_detected[tix]
670+
# targs = TargetArray(len(all_detected))
671+
# for tix in range(len(all_detected)):
672+
# targ = targs[tix]
673+
# det = all_detected[tix]
688674

689-
targ.set_pnr(tix)
690-
targ.set_pos(det[1:])
675+
# targ.set_pnr(tix)
676+
# targ.set_pos(det[1:])
691677

692-
# backup the ORI/ADDPAR files first
693-
exp.backup_ori_files()
678+
# # backup the ORI/ADDPAR files first
679+
# exp.backup_ori_files()
694680

695-
op = par.OrientParams()
696-
op.read()
697-
flags = [name for name in NAMES if getattr(op, name) == 1]
681+
# op = par.OrientParams()
682+
# op.read()
683+
# flags = [name for name in NAMES if getattr(op, name) == 1]
698684

699-
# Run the multiplane calibration
700-
residuals, targ_ix, err_est = full_calibration(exp.cals[i_cam], all_known,
701-
targs, exp.cpar, flags)
685+
# # Run the multiplane calibration
686+
# residuals, targ_ix, err_est = full_calibration(exp.cals[i_cam], all_known,
687+
# targs, exp.cpar, flags)
702688

703-
# Save the results
704-
689+
# # Save the results
690+
# ori = exp.calParams.img_ori[i_cam]
691+
# addpar = ori + ".addpar"
692+
# ori = ori + ".ori"
705693

706-
exp.cals[i_cam].write(ori.encode(), addpar.encode())
707-
print("End multiplane")
694+
# exp.cals[i_cam].write(ori.encode(), addpar.encode())
695+
# print("End multiplane")
708696

709697

710698
def read_targets(file_base: str, frame: int=123456789) -> TargetArray:

0 commit comments

Comments
 (0)