|
29 | 29 | TargetParams, |
30 | 30 | VolumeParams, |
31 | 31 | Frame, |
32 | | - correspondences, |
33 | 32 | MatchedCoords, |
34 | 33 | preprocess_image, |
35 | 34 | point_positions, |
|
39 | 38 | default_naming, |
40 | 39 | convert_arr_pixel_to_metric, |
41 | 40 | ) |
| 41 | +from openptv_python.tracking_frame_buf import sort_target_y |
| 42 | +from openptv_python.correspondences import py_correspondences |
42 | 43 |
|
43 | 44 | """ |
44 | 45 | example from Tracker documentation: |
@@ -449,27 +450,15 @@ def py_detection_proc_c( |
449 | 450 | return detections, corrected |
450 | 451 |
|
451 | 452 |
|
452 | | -def py_correspondences_proc_c(exp): |
| 453 | +def py_correspondences_proc_c(exp, frame=DEFAULT_FRAME_NUM): |
453 | 454 | """Provides correspondences |
454 | 455 | """ |
455 | | - frame = Frame(exp.num_cams) |
456 | | - for i_cam, targs in enumerate(exp.detections): |
457 | | - frame.targets[i_cam] = targs |
458 | | - try: |
459 | | - frame.num_targets[i_cam] = len(targs) |
460 | | - except TypeError: |
461 | | - frame.num_targets[i_cam] = getattr(targs, "num_targs", 0) |
462 | | - |
463 | | - try: |
464 | | - corrected = [ |
465 | | - corr.coords if hasattr(corr, "coords") else corr for corr in exp.corrected |
466 | | - ] |
467 | | - except TypeError: |
468 | | - corrected = exp.corrected |
469 | | - match_counts = [0] * exp.num_cams |
470 | | - |
471 | | - sorted_pos, sorted_corresp, num_targs = correspondences( |
472 | | - frame, corrected, exp.vpar, exp.cpar, exp.cals, match_counts |
| 456 | + sorted_pos, sorted_corresp, num_targs = py_correspondences( |
| 457 | + exp.detections, |
| 458 | + exp.corrected, |
| 459 | + exp.cals, |
| 460 | + exp.vpar, |
| 461 | + exp.cpar, |
473 | 462 | ) |
474 | 463 |
|
475 | 464 | # img_base_names = [exp.spar.get_img_base_name(i) for i in range(exp.num_cams)] |
@@ -670,19 +659,18 @@ def py_sequence_loop(exp) -> None: |
670 | 659 | targs = target_recognition(high_pass, tpar, i_cam, cpar) |
671 | 660 |
|
672 | 661 | if len(targs) > 0: |
673 | | - targs.sort_y() |
| 662 | + targs = sort_target_y(targs) |
674 | 663 |
|
675 | 664 | detections.append(targs) |
676 | 665 | matched_coords = MatchedCoords(targs, cpar, cals[i_cam]) |
677 | 666 | pos, _ = matched_coords.as_arrays() |
678 | 667 | corrected.append(matched_coords) |
679 | 668 |
|
680 | | - # AFter we finished all targs, we can move to correspondences |
681 | | - sorted_pos, sorted_corresp, _ = correspondences( |
682 | | - detections, corrected, cals, vpar, cpar |
683 | | - ) |
684 | | - for i_cam in range(num_cams): |
685 | | - write_targets(detections[i_cam], short_file_bases[i_cam], frame) |
| 669 | + # Keep the processed frame data on the experiment object so the |
| 670 | + # correspondence wrapper can use the current unified API contract. |
| 671 | + exp.detections = detections |
| 672 | + exp.corrected = corrected |
| 673 | + sorted_pos, sorted_corresp, _ = py_correspondences_proc_c(exp, frame) |
686 | 674 | print( |
687 | 675 | "Frame " |
688 | 676 | + str(frame) |
|
0 commit comments