|
21 | 21 | from optv.segmentation import target_recognition
|
22 | 22 | from optv.tracking_framebuf import TargetArray
|
23 | 23 | from optv.tracker import Tracker, default_naming
|
24 |
| -from optv.imgcoord import image_coordinates |
25 | 24 |
|
26 | 25 | from skimage.io import imread
|
27 | 26 | from skimage import img_as_ubyte
|
@@ -164,31 +163,18 @@ def py_correspondences_proc_c(exp):
|
164 | 163 | def py_determination_proc_c(n_cams, sorted_pos, sorted_corresp, corrected):
|
165 | 164 | """Returns 3d positions"""
|
166 | 165 |
|
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) |
181 | 167 |
|
182 | 168 | # Distinction between quad/trip irrelevant here.
|
183 | 169 | sorted_pos = np.concatenate(sorted_pos, axis=1)
|
184 | 170 | sorted_corresp = np.concatenate(sorted_corresp, axis=1)
|
185 | 171 |
|
186 | 172 | 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) |
188 | 174 | ])
|
189 | 175 | pos, rcm = point_positions(flat.transpose(1, 0, 2), cpar, cals, vpar)
|
190 | 176 |
|
191 |
| - if len(cals) < 4: |
| 177 | + if n_cams < 4: |
192 | 178 | print_corresp = -1 * np.ones((4, sorted_corresp.shape[1]))
|
193 | 179 | print_corresp[:len(cals), :] = sorted_corresp
|
194 | 180 | else:
|
@@ -636,75 +622,77 @@ def py_calibration(sel):
|
636 | 622 |
|
637 | 623 |
|
638 | 624 |
|
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 | +# """ |
643 | 629 |
|
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 |
648 | 634 |
|
649 |
| - c = exp.calParams.img_ori[i_cam][-9] # Get camera id |
| 635 | +# c = exp.calParams.img_ori[i_cam][-9] # Get camera id |
650 | 636 |
|
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" |
653 | 639 |
|
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) |
657 | 643 |
|
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)) |
662 | 648 |
|
663 |
| - num_known = len(known) |
664 |
| - num_detect = len(detected) |
| 649 | +# num_known = len(known) |
| 650 | +# num_detect = len(detected) |
665 | 651 |
|
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)) |
671 | 657 |
|
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))) |
675 | 661 |
|
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) |
679 | 665 |
|
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) |
683 | 669 |
|
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] |
688 | 674 |
|
689 |
| - targ.set_pnr(tix) |
690 |
| - targ.set_pos(det[1:]) |
| 675 | +# targ.set_pnr(tix) |
| 676 | +# targ.set_pos(det[1:]) |
691 | 677 |
|
692 |
| - # backup the ORI/ADDPAR files first |
693 |
| - exp.backup_ori_files() |
| 678 | +# # backup the ORI/ADDPAR files first |
| 679 | +# exp.backup_ori_files() |
694 | 680 |
|
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] |
698 | 684 |
|
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) |
702 | 688 |
|
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" |
705 | 693 |
|
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") |
708 | 696 |
|
709 | 697 |
|
710 | 698 | def read_targets(file_base: str, frame: int=123456789) -> TargetArray:
|
|
0 commit comments