Send object over RPC

Hey everyone,
I would send image over RPC to master, it done. how i can send image with other object, such as object rectangle same time?
My code on below

# This is called repeatedly by interface.stream_writer().
def stream_generator_cb():
    # Capture snapshot
    img = sensor.snapshot()

    img.draw_string(10,10,"Aplikasi Pengenalan Wajah\nVersi 0.1",(255,0,0),1.5,x_spacing=2,mono_space=False)
    
    # Find objects.
    # Note: Lower scale factor scales-down the image more and detects smaller objects.
    # Higher threshold results in a higher detection rate, with more false positives.
    objects = img.find_features(face_cascade, threshold=0.75, scale_factor=1.25)
    for r in objects:
        print(r)
        img.draw_rectangle(r,color=(255,0,0),thickness=2)
    return img.compress(quality=90).bytearray()

Thanks for help :grinning:

Return just returns a byte array. So, it’s whatever structure you’d like. You could for example do str() on an object to get the printable string of it and then return that. If you add the two objects using + then you have a larger byte string.

That said, you have to parse the string being sent on the other side.

return objects .__str__() + img.compress(quality=90).bytearray()

And etc.

ok thanks
solved with your suggestion

return str(sensor.get_fb().compress(quality=50).bytearray())+str(faces) if len(faces) > 0 else str(sensor.get_fb().compress(quality=50).bytearray())