Python3 + opencv exampels work with stream buffer

Hello, first of all thank you for aravis. So far everything is running and I would now like to continue working with python and opencv. Unfortunately I just don’t understand it. How can I convert an image or stream buffer for opencv? The pixel format is bayerRG8.

...

stream.push_buffer (Aravis.Buffer.new_allocate (payload))

print ("Start acquisition")

camera.start_acquisition()

while True:
	try:		
		print ("Acquisition")
		raw_image = stream.pop_buffer()
		print (raw_image)
		if raw_image:
			stream.push_buffer (raw_image) 
            
		#raw_image = raw_image.get_data()
		#rgb_image = raw_image.convert("RGB")
		#numpy_image = rgb_image.get_numpy_array()
		#pimg = cv2.cvtColor(numpy.asarray(numpy_image),cv2.COLOR_BGR2RGB)

        except Exception as e:
		print(e)
		break
	except KeyboardInterrupt:
		break

print ("Stop acquisition")
camera.stop_acquisition ()

I would be very grateful for an example ! Iam using Opencv 4.8.1 and Python 3.8
Best regards Martin

okay found a workaround with gstreamer. Both pipelines work, is there a more efficient way for bayerRG8 pixels?

import cv2
import time 
  
cameraIP = "10.40.1.247"
  
gst_source = "aravissrc camera-name="+cameraIP+" ! video/x-bayer ! bayer2rgb ! videoconvert ! appsink"
#gst_source = "aravissrc camera-name="+cameraIP+" ! capsfilter caps='video/x-bayer,format=rggb' ! bayer2rgb ! videoconvert ! appsink"
  
cap = cv2.VideoCapture(gst_source)
print("Frame Width: "+str(cap.get(3))+" x Frame Height: "+ str(cap.get(4)))
  
while True:
  try:
      start = time.time()
  
      ret, frame = cap.read()
      
      if ret == False:
          print("no frame")
          break
  
      print("fps: " + str(1 / (time.time() - start)))        
  
  except KeyboardInterrupt:
      break
  except Exception as e:
      print(e)
      break
  
cap.release()

Best regards Martin