jetson-utils icon indicating copy to clipboard operation
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?

Open gopalkalpande opened this issue 6 years ago • 1 comments

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: 134

After conversion to 3 channels: 139

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.

gopalkalpande avatar Nov 07 '19 12:11 gopalkalpande

Use img = cv2.cvtColor(img, cv2.COLOR_RGBA2RGB)

ZFTurbo avatar May 06 '20 14:05 ZFTurbo