import base64
def img_base64(img_path):
if os.path.exists(img_path):
with open(img_path, 'rb') as f_obj:
image_data = f_obj.read()
base64_d = base64.b64encode(image_data)
return base64_d
master.save_screenshot(".\\screenshots\\test.png")
full_screenshot_base64 = img_base64(".\\screenshots\\test.png")
partial_screenshot_base64 = img_base64(".\\resource\\images\\suit_head.png")
master.update_settings({"getMatchedImageResult": True})
master.update_settings({"fixImageTemplateScale": True})
master.find_image_occurrence(base64_full_image=full_screenshot_base64, base64_partial_image=partial_screenshot_base64, visuallze=True)
When I run above python code, error message is:
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type bytes is not JSON serializable
How should I solve this problem? Please help me, thank you!
According to the method description, the type of the parameter needs to be bytes, but the prompt is: Object of type bytes is not JSON serializable.