I have a python list that contains the RGBA data of a PNG image represented as int32, which was sent over from a Java socket server.
A sample output of this data as a numpy array without any conversions:
[[-12763847 -12763847 -12763847 ... -5590160 -12039396 -12434915]
[-12763847 -12763847 -12763847 ... -6643102 -12828909 -12830184]
[-12763847 -12763847 -12763847 ... -8419763 -13487094 -12435167]]
CV2, of course, accepts uint8 as the data type (displaying as int32 shows a black screen), so I convert my list to a numpy array with dtype = np.uint8 with the following:
image_data = np.array(data_list, dtype = np.uint8)
A sample output of this:
[[ 57 57 57 ... 112 28 29]
[ 57 57 57 ... 98 19 24]
[ 57 57 57 ... 77 10 33]]
However, when I display the image using
cv2.imshow("Image", image_data)
I get a window showing the image, but in grayscale; it lacks colors.
How do I prevent the colors from being ignored?