Read raw Bayer matrix from ROS2 image message
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I’m using the ROS Toolbox with MATLAB 2023a.
I’m reading raw Bayer images from ROS2 Bag file (SQLite3). The messages in the Bag file are recorded with the encoding 'bayer_bggr16'.
I would like to read the raw Bayer matrix of size M x N x 1.
Reading the documentation in the link below:
The tip for bayer_X formats states:
"bayer_X images are returned as either Bayer matrices of size M-by-N-by-1, or as a converted image of size M-by-N-by-3 (Image Processing Toolbox™ is required)."
Using the command below, I get a color output image of size M x N x 3. – e.g. it seems that the function performs debayering.
Image = rosReadImage(Message2Read)
I see also in the documentation, under encodingParam:
“Using this input argument overwrites the Encoding field of the input msg”
Hence, I tried using the following syntax in order to force it to decode as mono16:
Image = rosReadImage(Message2Read, "Encoding", "mono16")
Though It seems that rosReadImage command ignores the Encoding Parameter.
The only thing that works is to manually change the encoding string scalar in the ROS message itself before using the command rosReadImage.
Any advice how can I read the raw Bayer matrix of size M x N x 1 using rosReadImage?
0 commentaires
Réponses (1)
Josh Chen
le 5 Jan 2024
Modifié(e) : Josh Chen
le 5 Jan 2024
Hi Avishay,
I am assuming you have the Image Processing Toolbox installed on your machine. By default, if you have Image Processing Toolbox, rosReadImage will do the debayer after retriving the image from ROS message. Changing encoding information of a given message is not recommened since it may not always give you the correct output. If all you want is a raw Bayer matrix (M-by-N-by-1), you can try a simpler workaround as follow:
>> edit ros.msg.sensor_msgs.internal.ImageReader.convertToBayer
then remove the "img = demosaic(img, alignment);" under this function.
This should be easier than modifying fields in messages one-by-one.
If you scroll all the way down to the rosReadImage documentation, you will see the "Encoding" is only used for code generation workflow to assist on memory preallocation, and it should be the same as what's in the message itself. Thanks for bringing this issue to us, we would update the documentation to make this more clear.
Hope that helps,
Josh
0 commentaires
Voir également
Catégories
En savoir plus sur Specialized Messages dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!