@@ -591,10 +591,8 @@ def py_correspondences_proc_c(exp, frame=DEFAULT_FRAME_NUM):
591591 short_file_bases = exp .target_filenames
592592 print (f"short_file_bases: { short_file_bases } " )
593593 _ensure_target_output_writable (short_file_bases )
594- native_detections = bool (exp .detections ) and type (exp .detections [0 ]).__module__ .startswith ("optv." )
595- if not native_detections :
596- for i_cam in range (exp .num_cams ):
597- write_targets (exp .detections [i_cam ], short_file_bases [i_cam ], frame )
594+ for i_cam in range (exp .num_cams ):
595+ write_targets (exp .detections [i_cam ], short_file_bases [i_cam ], frame )
598596
599597 print (
600598 f"Frame { frame } had { [s .shape [1 ] for s in sorted_pos ]!r} correspondences."
@@ -832,12 +830,17 @@ def py_sequence_loop(exp) -> None:
832830 flat = np .array (
833831 [corr .get_by_pnrs (corresp ) for corr , corresp in zip (corrected , sorted_corresp )]
834832 )
835- legacy_cals = [from_native_calibration (cal ) for cal in exp .cals ]
836- legacy_cpar = _to_python_cpar (exp .cpar )
837- legacy_vpar = _to_python_vpar (exp .vpar )
833+ if should_use_native ("orientation" ):
834+ legacy_cals = exp .cals
835+ legacy_cpar = exp .cpar
836+ legacy_vpar = exp .vpar
837+ else :
838+ legacy_cals = [from_native_calibration (cal ) for cal in exp .cals ]
839+ legacy_cpar = _to_python_cpar (exp .cpar )
840+ legacy_vpar = _to_python_vpar (exp .vpar )
838841 pos , _ = point_positions (
839842 flat .transpose (1 , 0 , 2 ),
840- get_multimedia_par ( legacy_cpar ) ,
843+ legacy_cpar ,
841844 legacy_cals ,
842845 legacy_vpar ,
843846 )
@@ -983,18 +986,25 @@ def _sum_grey_value(target):
983986 return target .sum_grey_value ()
984987 return target .sumg
985988
986- with open (output_path , "w" , encoding = "utf-8" ) as file :
987- file .write (f"{ num_targets } \n " )
988- for target in target_list :
989- pnr = int (_value (getattr (target , "pnr" )))
990- x , y = _pos (target )
991- n , nx , ny = _pixel_counts (target )
992- sumg = int (_sum_grey_value (target ))
993- tnr = int (_value (getattr (target , "tnr" )))
994- file .write (
995- f"{ pnr :4d} { float (x ):9.4f} { float (y ):9.4f} "
996- f"{ int (n ):5d} { int (nx ):5d} { int (ny ):5d} { sumg :5d} { tnr :5d} \n "
989+ target_arr = np .array (
990+ [
991+ (
992+ _value (getattr (target , "pnr" )),
993+ * _pos (target ),
994+ * _pixel_counts (target ),
995+ _sum_grey_value (target ),
996+ _value (getattr (target , "tnr" )),
997997 )
998+ for target in target_list
999+ ]
1000+ )
1001+ np .savetxt (
1002+ output_path ,
1003+ target_arr ,
1004+ fmt = "%4d %9.4f %9.4f %5d %5d %5d %5d %5d" ,
1005+ header = f"{ num_targets } " ,
1006+ comments = "" ,
1007+ )
9981008 success = True
9991009 except OSError as exc :
10001010 _raise_output_write_error (output_path , exc )
0 commit comments