Giter Club home page Giter Club logo

Comments (12)

anfederman avatar anfederman commented on June 1, 2024

[WARN] [1671735223.499671649] [camera]: no pixel format selected, using default:
"BGR888"

is in the camera_node log file.

it gets this from my default set in config.txt

Autoload overlays for any recognized cameras or displays that are attached

to the CSI/DSI ports. Please note this is for libcamera support, not for

the legacy camera stack

camera_auto_detect=0
display_auto_detect=1
dtoverlay=vc4-kms-v3d,cma-512
dtoverlay=imx219
dtoverlay=imx219,cam0

Config settings specific to arm64

arm_64bit=1

from camera_ros.

christianrauch avatar christianrauch commented on June 1, 2024

There is no configuration file in this repo. By default, the node will select the first available pixel format. You can change that.

What is the encoding of the published mage? What happens when you change the format? How can I reproduce this?

from camera_ros.

christianrauch avatar christianrauch commented on June 1, 2024

I can reproduce this issue with the vivid driver on my desktop. After loading the kernel module via sudo modprobe vivid the new V4L2 device will show a test pattern with coloured vertical bars (note the red, blue, black bar order). You can check this also with VLC which lets you open a capture device:
Bildschirmfoto vom 2022-12-29 15-44-52

To use this with libcamera, you have to use the vivid branch from the vivid fork https://git.libcamera.org/libcamera/vivid.git. When everything is set up correctly, you can use the device with the BGRA8888 format:

qcam -c vivid --stream pixelformat=BGRA8888

and it will show the test pattern correctly (red, blue, black):
Bildschirmfoto vom 2022-12-29 16-12-37

When I then use this device with the ROS node and the BGR888 format:

ros2 run camera_ros camera_node --ros-args -p camera:=vivid -p format:=BGR888

the image will be published with the correct bgr8 encoding:

$ ros2 topic echo --once /camera/image_raw --field encoding
bgr8
---

but rqt will show the test pattern with switched red and blue colour bars:
Bildschirmfoto vom 2022-12-29 15-57-14

from camera_ros.

anfederman avatar anfederman commented on June 1, 2024

from camera_ros.

christianrauch avatar christianrauch commented on June 1, 2024

This problem is not specific to the Raspberry Pi camera as I showed above with the vivid test driver.

When you mention the "config yaml file" do you mean the "Camera calibration file"? If you did not calibrate your camera yet, then this warning is normal. I just says that the camera calibration file cannot be found at the expected location because the camera was never calibrated.

from camera_ros.

anfederman avatar anfederman commented on June 1, 2024

from camera_ros.

christianrauch avatar christianrauch commented on June 1, 2024

Thanks for your reply. Is there a parameter to pass to camera_ros to flip the channels?

No, and there should be no such parameter because the colour format mapping between libcamera and the ROS image encodings should work correctly. I am going to look into this. In the meantime, you can simply change the encoding from bgr8 to rgb8 in order to have the channels switched.

from camera_ros.

anfederman avatar anfederman commented on June 1, 2024

from camera_ros.

christianrauch avatar christianrauch commented on June 1, 2024

I wrote a simple python script to visualise the channels of an image:

#!/usr/bin/env python3
import rclpy
from rclpy.node import Node
from sensor_msgs.msg import Image
import numpy as np
import cv2

class FormatVisualiser(Node):
    def __init__(self):
        super().__init__('format_visualiser')
        self.sub_img = self.create_subscription(Image, "/camera/image_raw", self.on_image, 1)

    def on_image(self, msg_img):
        dtype = np.dtype(msg_img.data.typecode)
        dtype = dtype.newbyteorder('>' if msg_img.is_bigendian else '<')
        img_raw = np.asarray(msg_img.data.tolist(), dtype=dtype)\
            .reshape(msg_img.height, msg_img.width, int(msg_img.step/msg_img.width))

        for i in range(img_raw.shape[2]):
            cv2.imshow(f"raw channel {i}", img_raw[...,i])

        if msg_img.encoding == "bgra8":
            img_rgb = cv2.cvtColor(img_raw, cv2.COLOR_BGRA2RGB)
            cv2.imshow("rgb", img_rgb)
            for i in range(img_rgb.shape[2]):
                cv2.imshow(f"rgb channel {i}", img_rgb[...,i])

            img_bgr = cv2.cvtColor(img_raw, cv2.COLOR_BGRA2BGR)
            cv2.imshow("bgr", img_bgr)
            for i in range(img_bgr.shape[2]):
                cv2.imshow(f"bgr channel {i}", img_bgr[...,i])

        cv2.waitKey(1)

if __name__ == "__main__":
    rclpy.init()
    exporter_node = FormatVisualiser()
    rclpy.spin(exporter_node)
    exporter_node.destroy_node()
    rclpy.shutdown()

When I use this with the BGRA8888 format (or BA24 in fourcc):

ros2 run camera_ros camera_node --ros-args -p camera:=vivid -p format:=BGRA8888

I can clearly see that the channels in memory are A, R, G, B , i.e. in inverse order (the alpha channel is supposed to be empty). This inverse order comes from the endianness (see https://en.wikipedia.org/wiki/RGBA_color_model#Representation).

Since the ROS message contains the endianness, I thought that the client is supposed to deal with the memory representation.

from camera_ros.

christianrauch avatar christianrauch commented on June 1, 2024

I (force) pushed an update to slect the target ROS encoding via the machine endianness. This should resolve your issue. Can you check?

from camera_ros.

anfederman avatar anfederman commented on June 1, 2024

Thank you, it works! Issue is resolved.

from camera_ros.

christianrauch avatar christianrauch commented on June 1, 2024

Nice. Then I will go ahead and close this issue.

from camera_ros.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.