I'am working on a video chat in python. I'am using CV2 to capture the current image(this gives me a numpy array), then I send the numpy over to my server. Now I have a string at the server and i need to decode it back to a numpy array.
I'am using Python 3.7 and i dindn't come up with somethink yet.
#client
#capture 500 frames
while i < 500:
i = i + 1
# Capture frame-by-frame
ret, frame = cap.read()
#send data
client_socket.send(bytes(str(ret) + "###" + str(frame), "utf-8"))
#server
#split ret and frame
ret, frame = str(conn.recv(16000)).split("###")
gray = cv2.cvtColor(frame.toNumpyArray #PseudoMethod <-- Here
,cv2.COLOR_BGR2GRAY)
I only need a method to convert the string back to a numpy array. If i print it out,the string looks like this:
b'[[[128 255 255]\n [125 255 255]\n [107 255 255]\n ...\n [102 130 167]\n [102 128 172]\n [102 128 172]]\n\n [[128 255 255]\n [127 255 255]\n [108 255 255]\n ...\n [102 130 167]\n [102 128 172]\n [102 128 172]]\n\n [[111 255 255]\n [111 255 255]\n [109 255 255]\n ...\n [ 99 131 169]\n [ 99 131 169]\n [ 99 131 169]]\n\n ...\n\n [[ 27 64 95]\n [ 29 67 97]\n [ 24 66 98]\n ...\n [ 73 117 160]\n [ 70 119 161]\n [ 70 119 161]]\n\n [[ 18 71 81]\n [ 20 74 83]\n [ 30 67 93]\n ...\n [ 77 117 159]\n [ 74 118 163]\n [ 74 118 163]]\n\n [[ 14 68 77]\n [ 19 73 82]\n [ 30 67 93]\n ...\n [ 77 117 159]\n [ 74 118 163]\n [ 74 118 163]]]'
Sorry for my bad english, I'am a german student.