ElvinC / gyroflow

[INACTIVE LEGACY VERSION, FIND THE PROJECT HERE: https://github.com/gyroflow/gyroflow] Video stabilization using IMU motion data from internal or external logs
http://gyroflow.xyz
GNU General Public License v3.0
610 stars 89 forks source link

Dev branch CLI feature - sync error #113

Open SpoddyCoder opened 2 years ago

SpoddyCoder commented 2 years ago

Testing out @MiniGod 's CLI feature on the dev branch (https://github.com/ElvinC/gyroflow/pull/104).

Using DJI Air Unit source video file and betaflight CSV. Tried a number of invocations, but output of minimal example below - error is during the sync phase, which goes onto repeat forever (only included the a small part of the 2nd repeat).

poetry run python cli.py video.mp4 \
  --gyro video.csv \
  --camera camera_presets/DJI/DJI_DJI_FPV_Air_Unit_1080p_4by3.json \
  --sync 5 \
  --sync -15 \
  --sync-search-size 0.3

video.mp4 video.gyroflow.mp4 0.2 5
video.csv has log video.csv with type 'Blackbox CSV file'
Preset name: DJI _DJI FPV Air Unit__1080p 4by3
Note: Crop 1120x630 with 2x scale for calm flying
Made with 23 frames using calibrator version 0.2.1-alpha on date 2021-02-12
Note: Versions don't match. Calibrator: 0.3.0-beta-dev, Preset: 0.2.1-alpha. Should be fine though.
video.csv
Blackbox CSV file
Blackbox CSV file
average_frame_duration: 0.0005000000601974476
missing_runs: []
Appending 59.17091..=92.394914
average_frame_duration: 0.0005000000601974476
missing_runs: []
Appending 59.17091..=92.394914
2
Starting parallel auto sync
video.mp4 video.gyroflow.mp4video.mp4  0.2video.gyroflow.mp4  50.2 5

video.csv has log video.csv with type 'Blackbox CSV file'
video.csv has log video.csv with type 'Blackbox CSV file'
Preset name: DJI _DJI FPV Air Unit__1080p 4by3
Note: Crop 1120x630 with 2x scale for calm flying
Made with 23 frames using calibrator version 0.2.1-alpha on date 2021-02-12
Note: Versions don't match. Calibrator: 0.3.0-beta-dev, Preset: 0.2.1-alpha. Should be fine though.
Preset name: DJI _DJI FPV Air Unit__1080p 4by3
Note: Crop 1120x630 with 2x scale for calm flying
Made with 23 frames using calibrator version 0.2.1-alpha on date 2021-02-12
Note: Versions don't match. Calibrator: 0.3.0-beta-dev, Preset: 0.2.1-alpha. Should be fine though.
video.csv
video.csv
Blackbox CSV file
Blackbox CSV file
Blackbox CSV file
Blackbox CSV file
average_frame_duration: 0.0005000000601974476
average_frame_duration: 0.0005000000601974476
missing_runs: []
missing_runs: []Appending 59.17091..=92.394914

Appending 59.17091..=92.394914
average_frame_duration: 0.0005000000601974476average_frame_duration: 0.0005000000601974476

missing_runs: []
Appending 59.17091..=92.394914missing_runs: []

Appending 59.17091..=92.394914
2
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python39\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Python39\lib\multiprocessing\spawn.py", line 125, in _main
    prepare(preparation_data)
  File "C:\Python39\lib\multiprocessing\spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Python39\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "C:\Python39\lib\runpy.py", line 268, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "C:\Python39\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "C:\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "E:\Temp-Dev\GyroFlow\gyroflow\cli.py", line 122, in <module>
    success = stab.full_auto_sync_parallel(
  File "E:\Temp-Dev\GyroFlow\gyroflow\stabilizer.py", line 671, in full_auto_sync_parallel
    sync_results = ps.begin_sync_parallel()
  File "E:\Temp-Dev\GyroFlow\gyroflow\stabilizer.py", line 2618, in begin_sync_parallel
    pool = mp.Pool(n_proc)
  File "C:\Python39\lib\multiprocessing\context.py", line 119, in Pool
    return Pool(processes, initializer, initargs, maxtasksperchild,
  File "C:\Python39\lib\multiprocessing\pool.py", line 212, in __init__
    self._repopulate_pool()
  File "C:\Python39\lib\multiprocessing\pool.py", line 303, in _repopulate_pool
    return self._repopulate_pool_static(self._ctx, self.Process,
  File "C:\Python39\lib\multiprocessing\pool.py", line 326, in _repopulate_pool_static
    w.start()
  File "C:\Python39\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Python39\lib\multiprocessing\context.py", line 327, in _Popen
    return Popen(process_obj)
  File "C:\Python39\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "C:\Python39\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
    _check_not_importing_main()
  File "C:\Python39\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
    raise RuntimeError('''
RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
2
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python39\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Python39\lib\multiprocessing\spawn.py", line 125, in _main
    prepare(preparation_data)
  File "C:\Python39\lib\multiprocessing\spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Python39\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "C:\Python39\lib\runpy.py", line 268, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "C:\Python39\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "C:\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "E:\Temp-Dev\GyroFlow\gyroflow\cli.py", line 122, in <module>
    success = stab.full_auto_sync_parallel(
  File "E:\Temp-Dev\GyroFlow\gyroflow\stabilizer.py", line 671, in full_auto_sync_parallel
    sync_results = ps.begin_sync_parallel()
  File "E:\Temp-Dev\GyroFlow\gyroflow\stabilizer.py", line 2618, in begin_sync_parallel
    pool = mp.Pool(n_proc)
  File "C:\Python39\lib\multiprocessing\context.py", line 119, in Pool
    return Pool(processes, initializer, initargs, maxtasksperchild,
  File "C:\Python39\lib\multiprocessing\pool.py", line 212, in __init__
    self._repopulate_pool()
  File "C:\Python39\lib\multiprocessing\pool.py", line 303, in _repopulate_pool
    return self._repopulate_pool_static(self._ctx, self.Process,
  File "C:\Python39\lib\multiprocessing\pool.py", line 326, in _repopulate_pool_static
    w.start()
  File "C:\Python39\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Python39\lib\multiprocessing\context.py", line 327, in _Popen
    return Popen(process_obj)
  File "C:\Python39\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "C:\Python39\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
    _check_not_importing_main()
  File "C:\Python39\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
    raise RuntimeError('''
RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
video.mp4 video.gyroflow.mp4 0.2 5
video.csv has log video.csv with type 'Blackbox CSV file'
video.mp4 Preset name: DJI _DJI FPV Air Unit__1080p 4by3video.gyroflow.mp4
Note: Crop 1120x630 with 2x scale for calm flying
Made with 23 frames using calibrator version 0.2.1-alpha on date 2021-02-120.2
 Note: Versions don't match. Calibrator: 0.3.0-beta-dev, Preset: 0.2.1-alpha. Should be fine though.5

video.csv has log video.csv with type 'Blackbox CSV file'
Preset name: DJI _DJI FPV Air Unit__1080p 4by3
Note: Crop 1120x630 with 2x scale for calm flying
Made with 23 frames using calibrator version 0.2.1-alpha on date 2021-02-12
Note: Versions don't match. Calibrator: 0.3.0-beta-dev, Preset: 0.2.1-alpha. Should be fine though.
video.csv
video.csv
Blackbox CSV file
Blackbox CSV file
average_frame_duration: 0.0005000000601974476
missing_runs: []
Appending 59.17091..=92.394914
average_frame_duration: 0.0005000000601974476
Blackbox CSV file
Blackbox CSV file
average_frame_duration: 0.0005000000601974476
missing_runs: []
Appending 59.17091..=92.394914
missing_runs: []
Appending 59.17091..=92.394914
average_frame_duration: 0.0005000000601974476
missing_runs: []
Appending 59.17091..=92.394914
FreddyX078 commented 2 years ago

Got the same error with footage from Sony A7S3. GUI does not produce this error.

tomstom commented 2 years ago

I checked the cli.py and the following line causes the issue in my case:

success = stab.full_auto_sync_parallel(
        max_fitting_error = args.auto_sync_error_margin,
        max_points=args.auto_sync,
        n_frames=args.sync_analyze_frames,
        sync_points=sync_points,
        debug_plots=False
    )

I changed it to: success = stab.full_auto_sync(max_fitting_error = args.auto_sync_error_margin,max_points=args.auto_sync,debug_plots=False) and in the full_auto_sync function in stabalizer.py I changed the return to: return self.multi_sync_fit(max_fitting_error = max_fitting_error,debug_plots=debug_plots) #otherwise the gui starts

But remark: I think with this changes only the auto sync will work...