2026-01-28 06:16:04 +00:00

1.5 KiB

Kneron preprocessing floating/ 520/ 720 / IE

Installation

with input the account and password

pip install git+http://gitlab.kneron.tw/SYS/prepostprocess.git

with ssh keys

pip install git+ssh://git@gitlab.kneron.tw/SYS/prepostprocess

Example

API

import kneron_preprocessing as kp
def main():
    ## 1. Init, set preprocessing as floating / 520 / 720 / IE
    # set floating
    kp.set_default_as_floating()
    # 520
    kp.set_default_as_520()
    # 720
    kp.set_default_as_720()
    # IE
    kp.set_default_as_IE()

    ## 2. load Image
    # load jpg, png, ..etc
    image = './RGB565_Image.png'
    image_data = kp.load_image(image)
    # or load Bin
    raw_w = 640
    raw_h = 480
    image = './RGB565_Image.bin'
    image_data = kp.load_bin(image,'rgb565',(raw_w,raw_h))

    ## 3. do pre-processing
    # crop
    image_data = kp.crop(image_data,box=(272,145,461,341))
    # resize
    image_data = kp.resize(image_data,size=(56,56))
    # norm
    image_data = kp.norm(image_data)
    # pad
    image_data = kp.pad_corner(image_data,size=(56,56),pad_val=-0.5)

    ## 4. dump image & bit match function
    #dump image, input as np.array
    out_path = "./test.bin"
    kp.dump_image(img_data,output=out_path,file_fmt='bin',image_fmt='RGB565')
    #dump image, input as image path
    kp.dump_image('./test.jpg',output=out_path,file_fmt='txt',image_fmt='YUV422')

    # bit match image
    result, index = kp.bit_match(out_path,image_data)