def scaling_bmps():
    '''
    this function process bmps
    '''

    down_scale_list = [2, 4, 8]
    frame_type_list = ['camera', 'screen']

    src_bmp_path = config.BMP_PATH

    for frame_type in frame_type_list:
        src_sequence_path = src_bmp_path + frame_type + os.sep
        for src_sequence in glob.glob(src_sequence_path + '*'):
            for src_bmp in glob.glob(src_sequence + os.sep + '*.bmp'):
                print('processing %s' %src_bmp)
                for down_scale in down_scale_list:
                    win, hin, frame_rate = tools_common.get_resolution_from_file_name(src_bmp)
                    wout = win / down_scale
                    hout = hin / down_scale
                    tools_downsampler.scalerSX80(src_bmp, wout, hout, frame_type)
예제 #2
0
def scaling_bmps():
    '''
    this function process all bmps saved in specific path
    '''

    down_scale_list = [2, 4, 8]

    src_bmps_path = config.BMP_PATH

    for src_sequence in glob.glob(src_bmps_path + 'camera_2015' + os.sep +
                                  '*'):
        for src_bmp in glob.glob(src_sequence + os.sep + '*.bmp'):
            print('processing %s' % src_bmp)

            for down_scale in down_scale_list:
                win, hin, frame_rate = tools_common.get_resolution_from_file_name(
                    src_bmp)
                wout = (int)(win / down_scale)
                hout = (int)(hin / down_scale)

                tools_downsampler.scalerSX80(src_bmp, wout, hout)
예제 #3
0
def scaling_one_bmp(in_bmp, wout, hout, frame_type='camera'):
    '''
    this function use to scale one .bmp file using scalerSX80

    usage:
        scaler_one_bmp(infile.bmp, wout, hout, frame_type)

    parameters:
        infile.bmp      the input file name(.bmp format)
        wout            the width of output file
        hout            the height of output file
        frame_type      optional parameter,
                        help to save output files by type of frame content,
                        default equals 'camera'
    return:
        no parameters returned, but save two scaled files in specific path
            - out_old.bmp(will be renamed and saved in specific path)
            - out_new.bmp(will be renamed and saved in specific path)
    '''

    resolution_out = '%dx%d' % (wout, hout)
    file_name_prefix = os.path.basename(in_bmp)[0:-9]
    file_name_suffix = os.path.basename(in_bmp)[-9:]

    out_path = config.OUT_DATA_PATH + 'results' + os.sep + 'bmp' + os.sep + frame_type + os.sep \
             + file_name_prefix + os.sep
    if os.path.isdir(out_path):
        pass
    else:
        os.makedirs(out_path)

    out_file_old = out_path + file_name_prefix + '_to_' + resolution_out + '_old' + file_name_suffix
    out_file_new = out_path + file_name_prefix + '_to_' + resolution_out + '_new' + file_name_suffix

    tools_downsampler.scalerSX80(in_bmp, wout, hout, frame_type)

    os.rename('out_old.bmp', out_file_old)
    os.rename('out_new.bmp', out_file_new)
def scaling_one_bmp(in_bmp, wout, hout, frame_type='camera'):
    '''
    this function use to scale one .bmp file using scalerSX80

    usage:
        scaler_one_bmp(infile.bmp, wout, hout, frame_type)

    parameters:
        infile.bmp      the input file name(.bmp format)
        wout            the width of output file
        hout            the height of output file
        frame_type      optional parameter,
                        help to save output files by type of frame content,
                        default equals 'camera'
    return:
        no parameters returned, but save two scaled files in specific path
    '''

    resolution_out = '%dx%d' %(wout, hout)
    file_name_prefix = os.path.basename(in_bmp)[0:-9]
    file_name_suffix = os.path.basename(in_bmp)[-9:]

    out_path = config.OUT_DATA_PATH + 'results' + os.sep + 'bmp' + os.sep + frame_type + os.sep \
             + file_name_prefix + os.sep
    if os.path.isdir(out_path):
        pass
    else:
        os.makedirs(out_path)

    out_file_old = out_path + file_name_prefix + '_to_' + resolution_out + '_old' + file_name_suffix
    out_file_new = out_path + file_name_prefix + '_to_' + resolution_out + '_new' + file_name_suffix

    tools_downsampler.scalerSX80(in_bmp, wout, hout, frame_type)

    os.rename('out_old.bmp', out_file_old)
    os.rename('out_new.bmp', out_file_new)