Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Kio |
I have UDP communication working from Godot where Godot launches an external python script that processes incoming video with OPENCV from a ESP-32CAM module. The python UDP server script successfully sends and receives data to/from Godot UDP server.
(Have tried different protocols each with major issues - UDP I can get working, though not the most reliable.)
(I have been able to use image data sent from the ESP32-CAM over WebSocket’s in Godot. Processing the image with an OpenCV Module or using Godot Python is not a real thing yet. Also attempted a C# Mono variant with no success.)
The problem:
Formatting/sending image in Python that Godot can process from the UDP packet received.
My skull is bloody from hitting it against the wall on this.
Where I am at… looking for suggestions…
relevant UDP/OPENCV python script reference:
if not video_capture.isOpened():
sys.exit('Video source not found...')
ret, frame = video_capture.read()
frame = imutils.resize(frame, width=400)
#Send frame to Godot
#this is based on a python to python UDP video stream tutorial I found at
#https://pyshine.com/Send-video-over-UDP-socket-in-Python/
encode, buffer = cv2.imencode('.jpg', frame, [cv2.IMWRITE_JPEG_QUALITY,80])
message = base64.b64encode(buffer)
s_sender.sendto(bytes(message), (HOST_IP, PORT_SEND))
relevent godot UDP/image script reference:
peerpacket = peers.get_packet()
var cam1texture = create_texture_from_pool_byte_array(peerpacket)
func create_texture_from_pool_byte_array(byte_array):
var im = Image.new()
im.load_jpg_from_buffer(byte_array) #<- Point of issue
var im_tx = ImageTexture.new()
im_tx.create_from_image(im)
return im_tx