Skip to content

Support images in BGR and BGRA #2340

@abey79

Description

@abey79

Describe the annoyance

There is generally no consensus between RGB and BGR image formats. For example, Pillow's PIL.Image.open() yields RGB format (including when the image is converted to a Numpy array). OpenCV's cv2.imread() or VideoCapture instead yield BGR numpy arrays.

rr.log_image() expects RGB and yields false colours otherwise. At the very least, this should be documented. Ideally, some optional format argument should be added so alternative formats may be correctly ingested.

To Reproduce
This code yields false color (e.g. blue skins):

import cv2
import rerun as rr

rr.init("demo")
rr.spawn()
image = cv2.imread("image.jpg")
rr.log_image("image", image)

This is fixed by adding explicit format conversion:

# ... 
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
rr.log_image("image", image)

Ideally, something like that would be possible:

rr.log_image("image", image, format=rr.BGR)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestuser-requestThis is a pressing issue for one of our users🍏 primitivesRelating to Rerun primitives📺 re_vieweraffects re_viewer itself😤 annoyingSomething in the UI / SDK is annoying to use

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions