Ejemplo n.º 1
0
    os.chdir(os.path.dirname(
        os.path.realpath(__file__)))  # change cwd to file location
    THEORY_DF = plot.import_theory(
    )  # import the theory steady state dataframe

    DATA_LOC = ['190405_2']
    # DATA_LOC = ['190405']# ,'190329','190405','190405_2', '190405_3']
    for data in DATA_LOC:
        rel_imgs_dir = './Data/' + data + '/'  # File path relative to the script
        file_ext = '.ARW'

        # load in camera matrix
        with open(f'{rel_imgs_dir[:7]}cam_mtx.pickle', 'rb') as pickle_in:
            camera_params = pickle.load(pickle_in)
        # Get list of file names
        file_ids = raw_img.get_image_fid(rel_imgs_dir, file_ext)
        filenames = file_ids[file_ext[1:]]
        # Get background images
        BG_ids = raw_img.get_image_fid(rel_imgs_dir + 'BG/', file_ext)
        BG_filenames = BG_ids[file_ext[1:]]
        #crop background imgs and get crop_pos
        (BG, crop_pos, box_dims) = raw_img.prep_background_imgs([
            raw_img.raw_img(rel_imgs_dir + 'BG/', f, file_ext)
            for f in BG_filenames
        ], camera_params)
        #----------------------------------------------------------------
        plume_absorbance_thres = (0.0, 0.15)
        for COUNT, f in enumerate(filenames):
            # Image preprocessing ========================
            # import image
            IMG = raw_img.raw_img(rel_imgs_dir, f, file_ext)
Ejemplo n.º 2
0
    os.chdir(os.path.dirname(os.path.realpath(__file__))) # change cwd to file location

    video_loc = './Data/190619_3/'
    file_ext = '.jpg'
    fps = 50
    time_between_img = 0.5 # seconds
    plume_absorbance_thres = (0.0, 0.15)
    # Not needed but saves changing the prep_background imgs func
    with open(f'{video_loc[:7]}cam_mtx.pickle', 'rb') as pickle_in:
        camera_params = pickle.load(pickle_in)
    if CAPTURE_FRAMES == 1:
        # create jpgs frames
        video_to_frames(video_loc, '00000.MTS', image_ext=file_ext,
                        video_fps=fps, spacing=time_between_img, start_time=10)
    # Get list of file names
    file_ids = raw_img.get_image_fid(video_loc, file_ext)
    FNAMES = file_ids[file_ext[1:]]
    # Get background images
    BG_IDS = raw_img.get_image_fid(video_loc + 'BG/', file_ext)
    BG_FNAMES = BG_IDS[file_ext[1:]]

    (BG, CROP_POS, box_dims) = raw_img.prep_background_imgs(
            [raw_img.raw_img(video_loc + 'BG/',
                             f, file_ext) for f in BG_FNAMES], camera_params)
    for count, f in enumerate(FNAMES):
        # Preprocess the image
        #########################################
        img = raw_img.raw_img(video_loc, f, file_ext)
        img.get_experiment_conditions(get_g_ss = True)
        if count == 0:
            plume_q = (img.plume_q*1e-06) / 60 # m^3s^-1
Ejemplo n.º 3
0
            conc_data = conc_data[['image', 'dye conc (ppm)']]
            channels = ['red', 'green', 'blue']
            stats = [
                'max', 'h max', 'v max', 'min', 'h min', 'v min', 'mean',
                'h mean', 'v mean', 'std', 'h std', 'v std'
            ]
            multi_col = pd.MultiIndex.from_product([channels, stats], )
            conc = pd.DataFrame(columns=multi_col)
            conc[conc_data.columns] = conc_data

            # load in camera matrix
            with open(f'{rel_imgs_dir[:7]}cam_mtx.pickle', 'rb') as pickle_in:
                camera_params = pickle.load(pickle_in)

            # Get list of file names
            file_ids = raw_img.get_image_fid(rel_imgs_dir, FILE_EXT)
            filenames = file_ids[FILE_EXT[1:]]
            # Get background images
            BG_ids = raw_img.get_image_fid(rel_imgs_dir + 'BG/', FILE_EXT)
            BG_filenames = BG_ids[FILE_EXT[1:]]

            #crop background imgs and get crop_pos
            (BG, crop_pos, box_dims) = raw_img.prep_background_imgs([
                raw_img.raw_img(rel_imgs_dir + 'BG/', f, FILE_EXT)
                for f in BG_filenames
            ], camera_params)
            #----------------------------------------------------------------

            # Analyse in reverse so that the crop images are of the steady state
            for count, f in enumerate(filenames):
                try:
Ejemplo n.º 4
0
    FILE_EXT = '.ARW'
    GET_CAM_MTX = 1

    if GET_CAM_MTX == 1:
        # termination CRITERIA
        CRITERIA = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)

        # prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(12,5,0)
        OBJP = np.zeros((10*15, 3), np.float32)
        OBJP[:, :2] = np.mgrid[0:15, 0:10].T.reshape(-1, 2)

        # Arrays to store object points and image points from all the images.
        OBJPOINTS = [] # 3d point in real world space
        IMGPOINTS = [] # 2d points in image plane.
        # Get list of file names
        FILE_IDS = raw_img.get_image_fid(REL_IMGS_DIR, FILE_EXT)
        FILENAMES = FILE_IDS[FILE_EXT]


        for fname in FILENAMES:
            print(f'Processing {fname}')
            obj = raw_img.raw_img(REL_IMGS_DIR, fname, FILE_EXT)
            IMG = obj.raw_image

            gray = cv2.cvtColor(IMG, cv2.COLOR_RGB2GRAY)

            # gray = img
            # Find the chess board corners
            RET, corners = cv2.findChessboardCorners(gray, (15, 10), None)
            print(RET)
            # If found, add object points, image points (after refining them)