Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pickling error on Python multiprocess queue #7

Open
jojje42 opened this issue Jun 20, 2023 · 3 comments
Open

Pickling error on Python multiprocess queue #7

jojje42 opened this issue Jun 20, 2023 · 3 comments

Comments

@jojje42
Copy link

jojje42 commented Jun 20, 2023

Hi,
Trying to change from Python multithreading to multiprocessing.
I can queue the frames using threads queue (queue.Queue) but I'll get pickling error during usage of multiprocessor.Queue.
I think the reason is that thread queues are skipping serialization in some cases while multiprocessor queues always serialize.

    # Example
    def __call__(self, cam: Camera, stream: Stream, frame: Frame):
        if frame.get_status() == FrameStatus.Complete:
            frame_cpy = copy.deepcopy(frame)
            rgb_frame = frame_cpy.convert_pixel_format(PixelFormat.Bgr8)
            cv_img = rgb_frame.as_opencv_image()
            my_queue.put_nowait(cv_img)
Error
_pickle.PicklingError: Can't pickle <class 'vmbpy.frame.c_ubyte_Array_9560448'>: attribute lookup c_ubyte_Array_9560448 on vmbpy.frame failed

I've tried to make a copy of nd array, e.g. cv_img2 = cv_img.copy(), with the same error.

@emasty
Copy link

emasty commented Aug 16, 2023

I can confirm this behaviour. Could you find a solution yet?

There is a multithreading example available, but it doesn't do much due to GIL. Multiprocessing would be the real example required.

@emasty
Copy link

emasty commented Aug 24, 2023

I did notice that the issue does not occur once the frame is resized using cv2.resize. I did not have a closer look why though.
But for a quick&dirty test, resizing the image with the original resolution does work.

@jojje42
Copy link
Author

jojje42 commented Aug 25, 2023

I didn't find a solution.
Very interesting with the "resize" solution, thanks! Haven't had time to try it but will comment here when tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants