jetson-utils
jetson-utils copied to clipboard
Need to read the stream in only 3 channels i.e. RGB not 4 channels i.e. RGBA. How to do it?
I'm doing object detection using the TensorFlow object detection API. For that, the detection model accepts the input tensor in the shape [<tf.Tensor 'image_tensor:0' shape=(None, None, None, 3) dtype=uint8>]; but after using CudaToNumpy the shape is (None, None, None, 4). I tried to convert 4 channel feed to 3 channel feed but there is a loss of information in that.
Captured by gStreamer, original image with 4 channels:

After conversion to 3 channels:

Please tell me if there is any way to convert the 4 channels to 3 channels without losing the information.
For this conversion, I have used : img = cv2.cvtColor(img, cv2.COLOR_BGRA2BGR)
and passed the numpy array as img.
Use img = cv2.cvtColor(img, cv2.COLOR_RGBA2RGB)