예제 #1
0
def f(errors_by_every_file_path, allowable_error):
    from trem_researcher import TremResearcher
    import numpy as np

    _researcher = TremResearcher(marks_num=5, marks_size_mm=10)

    folders_to_check = [
        r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\X 0',
        r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\X 15',
        r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\X 30',
        r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\X 45',
        r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\X 60',
        r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\X 75',
        r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\Y 0',
        r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\Y 15',
        r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\Y 30',
        r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\Y 45',
        r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\Y 60',
        r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\Y 75'
    ]

    with open((errors_by_every_file_path), 'rb') as file:
        errors = pickle.load(file)

    files_to_calib = []
    for file in errors:
        errors_for_file = np.asarray(
            [np.mean(errors[file][folder]) for folder in errors[file]])
        is_allowable_error = np.abs(errors_for_file) < allowable_error
        if list(is_allowable_error).count(True) == len(is_allowable_error):
            files_to_calib += [file]

    if len(files_to_calib) == 0:
        return {
            allowable_error: {folder: np.nan
                              for folder in folders_to_check}
        }

    print(
        f"Calibrate sample with allowable_error={allowable_error}. Started.\n")
    _researcher.calibrate(images_paths=files_to_calib)
    print(
        f"Calibrate sample with allowable_error={allowable_error}. Finished.\n"
    )

    FRAMES_PER_STEP = 5
    STEP_MM = 5
    get_errors = _researcher.get_errors_finder(
        frames_per_step=FRAMES_PER_STEP,
        step_mm=STEP_MM,
        text_for_log=
        f'Find errors for subsample with allowable error:{allowable_error}.')

    _res = {
        allowable_error: {
            folder: get_errors(_researcher.photo_files(folder))
            for folder in folders_to_check
        }
    }
    return _res
예제 #2
0
def f(calib_settings_path, test_folder):
    from trem_researcher import TremResearcher
    import numpy as np
    import cv2
    _researcher = TremResearcher(marks_num=5, marks_size_mm=10)
    _researcher.load_calib_settings(calib_settings_path)

    FRAMES_PER_STEP = 5
    STEP_MM = 5

    get_errors = _researcher.get_errors_finder(
        frames_per_step=FRAMES_PER_STEP,
        step_mm=STEP_MM,
        text_for_log=f'Find errors for {test_folder.split(sep)[-1]}.')

    return {test_folder: get_errors(_researcher.photo_files(test_folder))}
예제 #3
0
def f(calib_images_path, i):
    from trem_researcher import TremResearcher
    import numpy as np
    import cv2
    _researcher = TremResearcher(marks_num=5, marks_size_mm=10)
    calib_images = _researcher.photo_files(calib_images_path)

    FRAMES_PER_STEP = 5
    STEP_MM = 5

    # folders_to_check = [r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 2\X',
    #                     r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 2\Y']
    folders_to_check = [
        fr'..{sep}Calibration{sep}Check calibration photo{sep}Focus distance 50 mm 3{sep}X 0',
        fr'..{sep}Calibration{sep}Check calibration photo{sep}Focus distance 50 mm 3{sep}X 15',
        fr'..{sep}Calibration{sep}Check calibration photo{sep}Focus distance 50 mm 3{sep}X 30',
        fr'..{sep}Calibration{sep}Check calibration photo{sep}Focus distance 50 mm 3{sep}X 45',
        fr'..{sep}Calibration{sep}Check calibration photo{sep}Focus distance 50 mm 3{sep}X 60',
        fr'..{sep}Calibration{sep}Check calibration photo{sep}Focus distance 50 mm 3{sep}Y 0',
        fr'..{sep}Calibration{sep}Check calibration photo{sep}Focus distance 50 mm 3{sep}Y 15',
        fr'..{sep}Calibration{sep}Check calibration photo{sep}Focus distance 50 mm 3{sep}Y 30',
        fr'..{sep}Calibration{sep}Check calibration photo{sep}Focus distance 50 mm 3{sep}Y 45',
        fr'..{sep}Calibration{sep}Check calibration photo{sep}Focus distance 50 mm 3{sep}Y 60'
    ]

    print(f"Calibrate with {i} file. Started.")
    _researcher.calibrate(images_paths=[calib_images[i]])
    print(f"Calibrate with {i} file. Finished.")

    get_errors = _researcher.get_errors_finder(
        frames_per_step=FRAMES_PER_STEP,
        step_mm=STEP_MM,
        text_for_log=f'Find errors for {calib_images[i]}.')

    return {
        calib_images[i]: {
            folder: get_errors(_researcher.photo_files(folder))
            for folder in folders_to_check
        }
    }
예제 #4
0
from trem_researcher import TremResearcher, sep
import time

from multiprocessing import Pool, cpu_count
from functools import partial

calib_settings_path = fr'D:\Projects\Tremor\BIN FILES\Calibration for Accurate attempt 5 (all) (corrected).pkl'
researcher = TremResearcher(marks_num=5, marks_size_mm=10)

test_folders = [
    r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\X 0',
    r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\X 15',
    r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\X 30',
    r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\X 45',
    r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\X 60',
    r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\X 75',
    r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\Y 0',
    r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\Y 15',
    r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\Y 30',
    r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\Y 45',
    r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\Y 60',
    r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 3\Y 75'
]


def f(calib_settings_path, test_folder):
    from trem_researcher import TremResearcher
    import numpy as np
    import cv2
    _researcher = TremResearcher(marks_num=5, marks_size_mm=10)
    _researcher.load_calib_settings(calib_settings_path)
예제 #5
0
from trem_researcher import TremResearcher, sep

#researcher = TremResearcher()
#researcher.calibrate(r'D:\Projects\Tremor\Calibration\Calibration photo\Accurate attempt 5')
#researcher.save_calib_settings(r'D:\Projects\Tremor\BIN FILES\Calibration for Accurate attempt 5 (all) (corrected).pkl')
#print(researcher.mtx, researcher.dist)

researcher1 = TremResearcher()
researcher2 = TremResearcher()
researcher1.load_calib_settings(r'D:\Projects\Tremor\BIN FILES\Calibration for Accurate attempt 4.pkl')
researcher2.load_calib_settings(r'D:\Projects\Tremor\BIN FILES\Calibration for Accurate attempt 5 (all) (corrected).pkl')

print("MTX:", researcher1.mtx - researcher2.mtx)
print("DIST:", researcher1.dist - researcher2.dist)
print(researcher2.mtx.dtype)
예제 #6
0
from trem_researcher import TremResearcher, sep
import time

from multiprocessing import Pool, cpu_count
from functools import partial

calib_images_path = fr'..{sep}Calibration{sep}Calibration photo{sep}Accurate attempt 5'
researcher = TremResearcher(marks_num=5, marks_size_mm=10)
calib_images = researcher.photo_files(calib_images_path)
files_to_check = len(calib_images)


def f(calib_images_path, i):
    from trem_researcher import TremResearcher
    import numpy as np
    import cv2
    _researcher = TremResearcher(marks_num=5, marks_size_mm=10)
    calib_images = _researcher.photo_files(calib_images_path)

    FRAMES_PER_STEP = 5
    STEP_MM = 5

    # folders_to_check = [r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 2\X',
    #                     r'D:\Projects\Tremor\Calibration\Check calibration photo\Focus distance 50 mm 2\Y']
    folders_to_check = [
        fr'..{sep}Calibration{sep}Check calibration photo{sep}Focus distance 50 mm 3{sep}X 0',
        fr'..{sep}Calibration{sep}Check calibration photo{sep}Focus distance 50 mm 3{sep}X 15',
        fr'..{sep}Calibration{sep}Check calibration photo{sep}Focus distance 50 mm 3{sep}X 30',
        fr'..{sep}Calibration{sep}Check calibration photo{sep}Focus distance 50 mm 3{sep}X 45',
        fr'..{sep}Calibration{sep}Check calibration photo{sep}Focus distance 50 mm 3{sep}X 60',
        fr'..{sep}Calibration{sep}Check calibration photo{sep}Focus distance 50 mm 3{sep}Y 0',
예제 #7
0
from trem_researcher import TremResearcher

researcher = TremResearcher(marks_num=5, marks_size_mm=10)
researcher.save_board(file_name='new_board',
                      path_to_save=r'D:\Projects\Tremor\Маркеры')