UnicodeError when os.listdir()

import sensor
import time,os

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time=2000)

filedirlist=os.listdir()
print(filedirlist)
if not "Failed" in filedirlist:
    os.mkdir("Failed")
if not "Error" in filedirlist:
    os.mkdir("OK")
if not "Error" in filedirlist:
    os.mkdir("OK")

clock = time.clock()

while True:
    clock.tick()
    img = sensor.snapshot()
    print(clock.fps())

Traceback (most recent call last):
File “”, line 11, in
UnicodeError:
OpenMV v4.5.2-dirty; MicroPython v1.20-omv-r22-dirty; OPENMV4P-STM32H743
Type “help()” for more information.

how to correct ?

Hi, that would be an issue with the fat file system driver in reading the file names on the disk. You may wish to change the file names to ascii only.

1 Like

that code works if files has no chinese name .zzzz…

Unicode is not enabled by default to save space. If this is important to you, you could try rebuilding the firmware and change FF_LFN_UNICODE=1 in lib/micropython/lib/oofatfs/ffconf.h. You may also need to change FF_CODE_PAGE to the correct code.

1 Like

thank you, :saluting_face: