From 56679f4335ffc3f14e3b8910cb75a1525b384935 Mon Sep 17 00:00:00 2001 From: Jeff Moe Date: Wed, 24 Aug 2022 20:01:23 -0600 Subject: [PATCH] Merge: Add software binning to cv2 acquisition --- acquire.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/acquire.py b/acquire.py index fc1a284..64297e8 100755 --- a/acquire.py +++ b/acquire.py @@ -123,7 +123,7 @@ def capture_pi(image_queue, z1, t1, z2, t2, nx, ny, nz, tend, device_id, live, c # Capture images from cv2 -def capture_cv2(image_queue, z1, t1, z2, t2, nx, ny, nz, tend, device_id, live): +def capture_cv2(image_queue, z1, t1, z2, t2, nx, ny, nz, tend, device_id, live, cfg): # Intialization first = True slow_CPU = False @@ -131,9 +131,15 @@ def capture_cv2(image_queue, z1, t1, z2, t2, nx, ny, nz, tend, device_id, live): # Initialize cv2 device device = cv2.VideoCapture(device_id) + # Test for software binning + try: + software_bin = cfg.getint(camera_type, 'software_bin') + except configparser.Error: + software_bin = 1 + # Set properties - device.set(3, nx) - device.set(4, ny) + device.set(3, nx * software_bin) + device.set(4, ny * software_bin) try: # Loop until reaching end time @@ -166,6 +172,11 @@ def capture_cv2(image_queue, z1, t1, z2, t2, nx, ny, nz, tend, device_id, live): z = np.asarray(cv2.cvtColor( frame, cv2.COLOR_BGR2GRAY)).astype(np.uint8) + # Apply software binning + if software_bin > 1: + my, mx = z.shape + z = cv2.resize(z, (mx // software_bin, my // software_bin)) + # Display Frame if live is True: cv2.imshow("Capture", z) @@ -677,7 +688,7 @@ if __name__ == '__main__': elif camera_type == "CV2": pcapture = multiprocessing.Process(target=capture_cv2, args=(image_queue, z1, t1, z2, t2, - nx, ny, nz, tend.unix, device_id, live)) + nx, ny, nz, tend.unix, device_id, live, cfg)) elif camera_type == "ASI": pcapture = multiprocessing.Process(target=capture_asi, args=(image_queue, z1, t1, z2, t2,