@@ -639,8 +639,19 @@ def socket_to_socket_opt(socket: dai.CameraBoardSocket) -> str:
639
639
capture_list .remove (c )
640
640
print ()
641
641
if c .startswith ('raw_' ) or c .startswith ('tof_amplitude_' ) or c .startswith ('tof_intensity_' ):
642
+ # Custom handling for IMX462 that has extra metadata and offset in RAW frame
643
+ bits = 10
644
+ order = cv2 .COLOR_BayerGB2BGR
645
+ if pkt .getData ().size == 1920 * 2 * (1080 + 15 ):
646
+ full_raw = pkt .getData ()
647
+ extra_offset = 384 * 2
648
+ actual_frame = full_raw [(1920 * 2 * 15 + extra_offset ):]
649
+ missing_data = np .full (extra_offset , 0xAA , dtype = np .uint8 ) # FIXME
650
+ frame = np .append (actual_frame , missing_data ).view (np .uint16 ).reshape ((1080 , 1920 ))
651
+ bits = 12
652
+ order = cv2 .COLOR_BayerGR2BGR
642
653
if capture :
643
- filename = capture_file_info + '_10bit .bw'
654
+ filename = capture_file_info + f'_ { bits } bit .bw'
644
655
print ('Saving:' , filename )
645
656
frame .tofile (filename )
646
657
# Full range for display, use bits [15:6] of the 16-bit pixels
@@ -649,14 +660,14 @@ def socket_to_socket_opt(socket: dai.CameraBoardSocket) -> str:
649
660
if type == dai .ImgFrame .Type .RAW10 :
650
661
multiplier = (1 << (16 - 10 ))
651
662
if type == dai .ImgFrame .Type .RAW12 :
652
- multiplier = (1 << (16 - 4 ))
663
+ multiplier = (1 << (16 - 12 ))
653
664
frame = frame * multiplier
654
665
# Debayer as color for preview/png
655
666
if cam_type_color [cam_skt ]:
656
667
# See this for the ordering, at the end of page:
657
668
# https://docs.opencv.org/4.5.1/de/d25/imgproc_color_conversions.html
658
669
# TODO add bayer order to ImgFrame getType()
659
- frame = cv2 .cvtColor (frame , cv2 . COLOR_BayerGB2BGR )
670
+ frame = cv2 .cvtColor (frame , order )
660
671
else :
661
672
# Save YUV too, but only when RAW is also enabled (for tuning purposes)
662
673
if capture and args .enable_raw :
0 commit comments