88import cv2
99import numpy as np
1010import zivid
11+ from sample_utils .display import display_bgr
1112
1213
1314def _options () -> argparse .Namespace :
@@ -46,10 +47,9 @@ def _capture_bgr_image(camera: zivid.Camera, gamma: float) -> np.ndarray:
4647
4748 print ("Capturing 2D frame" )
4849 with camera .capture (settings_2d ) as frame_2d :
49- image = frame_2d .image_rgba ()
50- rgba = image .copy_data ()
51- bgr = cv2 .cvtColor (rgba , cv2 .COLOR_RGBA2BGR )
52- return bgr
50+ image = frame_2d .image_bgra ()
51+ bgra = image .copy_data ()
52+ return bgra [:, :, :3 ]
5353
5454
5555def _combine_images (image_one : np .ndarray , image_two : np .ndarray ) -> np .ndarray :
@@ -69,19 +69,6 @@ def _combine_images(image_one: np.ndarray, image_two: np.ndarray) -> np.ndarray:
6969 return combined_image
7070
7171
72- def _display_bgr (image : np .ndarray , bgr_name : str ) -> None :
73- """Display BGR image using OpenCV.
74-
75- Args:
76- image: BGR image to be displayed
77- bgr_name: Name of the OpenCV window
78-
79- """
80- cv2 .imshow (bgr_name , image )
81- print ("Press any key to continue" )
82- cv2 .waitKey (0 )
83-
84-
8572def _main () -> None :
8673 app = zivid .Application ()
8774
@@ -100,7 +87,8 @@ def _main() -> None:
10087
10188 print (f"Displaying color image before and after gamma correction: { user_options .gamma } " )
10289 combined_image = _combine_images (bgr_original , bgr_adjusted )
103- _display_bgr (combined_image , "Original on left, adjusted on right" )
90+ cv2 .imwrite ("combined_image.jpg" , combined_image )
91+ display_bgr (combined_image [:, :, 0 :3 ], title = "Original on left, adjusted on right" )
10492
10593
10694if __name__ == "__main__" :
0 commit comments