Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5452

Camera board • Re: raw .dng video and Pyqt5 ThreadPoolExecutor/QThreadPool?

$
0
0
Hi, so the gist of it will go like this.

You need to turn your for loop into a simple state machine that runs through the regular event loop. You'll want some kind of (global) counter to count the requests you processed. Let's call this "REQUEST_COUNTER".

When you click the button you need to launch the first capture, but you can't wait for it to return immediately:

Code:

def on_button_clicked():    global REQUEST_COUNTER    button.setEnabled(False)    REQUEST_COUNTER = 0    picam2.capture_request(signal_function=qpicamera2.signal_done)
Then your "capture_done" will get the request and process it. Then, if it's not finished, it must launch the next capture request. Otherwise, it must finish all your processing. So probably like this:

Code:

def capture_done(job):    global REQUEST_COUNTER    request = picam2.wait(job)    task = SaveDNGTask(picam2, i, request.get_metadata(), request.make_buffer('raw'))    thread_pool.start(task)    request.release()        REQUEST_COUNTER += 1    if REQUEST_COUNTER < 10:        picam2.capture_request(signal_function=qpicamera2.signal_done)    else:        thread_pool.waitForDone()        button.setEnabled(True)
I haven't tried it but hopefully it's clear enough - maybe put a few print statements in there so that you can see what's happening. Good luck!

Statistics: Posted by therealdavidp — Thu Apr 18, 2024 11:35 am



Viewing all articles
Browse latest Browse all 5452

Trending Articles