ROSBag: RealSense bags have a 4-byte depth-units trailer that is guessed, not parsed
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- python
- Domaine
- backend, computer-vision
Piste de recherche
Start with ROSBag._autodetect_typestore and the __iter__ trim logic in src/machinevisiontoolbox/Sources.py, then inspect tests/create_ros_fixture.py and the existing ROS bag tests. First reproduce the suspected data loss with Intel’s single_depth_color_640x480.bag, which should be checked before changing parsing. Done means image trailers are parsed without trimming valid bytes, depth units are preserved and handled as specified, and fixtures cover bags with and without trailers; the open pull request #155 indicates work is already underway.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
ROSBag can mis-read bag files recorded with the Intel RealSense SDK (librealsense). RealSense appends 4 extra bytes to every sensor_msgs/Image message, which the current code handles by guessing a fixed number of trailing bytes to strip.
What we found
Investigated by parsing real bags directly, outside rosbags:
- In a 1280x720 bag recorded with librealsense, every
sensor_msgs/Imagemessage has exactly 4 bytes after the valid message. For color frames the trailer is00000000. For depth frames it is the float320.001(bytes6f 12 83 3a), the RealSense depth unit in metres per count. It matches the bag's own.../option/Depth_Units/valuetopic, and librealsense's writer (ros_writer.cpp,write_video_frame) deliberately appends adepth_unitsfloat to a modifiedsensor_msgs::Image. So the trailer is real metadata, not junk, and we currently throw it away. - For both image types,
step == width * bytes_per_pixel, the data array length isheight * step, and the message length isend_of_array + 4. The extra bytes sit entirely after the array, so row padding does not explain them. - Intel's own sample bag
single_depth_color_640x480.bag(which also containsrealsense_msgs/StreamInfo) has 0 extra bytes. But_is_realsenseis true for it, so the fixedtrim_order=(4,)inROSBag._autodetect_typestorewould chop 4 real bytes from each message. We have not verified this (rosbagswas not installed in the environment used); it should be the first regression test.
Where
ROSBag._autodetect_typestore and the __iter__ code that applies self._trim_bytes, in src/machinevisiontoolbox/Sources.py.
Proposed fix
- Add RealSense-style fixtures (with and without the trailer) to
tests/create_ros_fixture.py, plus a regression test for the 0-extra-bytes sample bag. - For
Image/CompressedImage, parse the fixed message layout by hand up to the data array (header, height, width, encoding, is_bigendian, step, array length prefixn), setend = position + 4 + n, treatraw[end:]as the footer, checkn == height * step, and hand onlyraw[:end]to the type store. No probing, no global_trim_bytes, and it works whether a bag has 0 or 4 trailing bytes. Keep the existing 0/4/8 probe only as a fallback for other message types. - Keep a 4-byte footer as a float32
depth_unitson the sample (depth only; color is0.0) instead of discarding it. - Also check non-image connections (
StreamInfo,CameraInfo) for trailers; not yet checked.
Depth units API (design agreed in principle, open to discussion)
New arguments ROSBag(..., depth_units=None | "auto" | float, invalid_is_nan=True), where depth_units is metres per unit (the librealsense convention; note this is the reciprocal of Open3D's and TUM RGB-D's units-per-metre depth_scale, so document the 1000 / 5000 mapping).
Sources of the scale, in order of precedence: a user-supplied float, then the per-message footer, then the bag's .../option/Depth_Units/value topic if recorded, then the scale implied by the encoding under REP 118 (16UC1 = millimetres = 0.001; 32FC1 = already metres), then unknown.
- Default (
None): native dtype (uint16) returned unchanged, with the best-known scale attached to the sample asdepth_unitsmetadata. "auto"or a float: convert to float32 metres; where the result is float andinvalid_is_nanis true (the default), raw 0 becomes NaN.32FC1input is already metres, so a user scale acts as a gain.- The dtype never silently depends on which SDK recorded the bag.
Also use logging rather than print in this code path. Part of the wider clean-up in the Sources.py tracking issue linked in the checklist at the end.
Tracking issue for the rest of the file: #150.
- Langage dominant
- Python
- Étoiles
- 224
- Forks
- 31
- Merge moyen
- 1 j 20 h
- PR mergées (30 j)
- 28
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de petercorke/machinevision-toolbox-python
-
Difficulté 2/5 1-3 heures Accessibilité débutants 42/100
petercorke/machinevision-toolbox-python#157 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
petercorke/machinevision-toolbox-python#152 ·
Les mainteneurs répondent en général sous 1 jour
-
Sources.py: quick wins, split into a package, and API unificationPeut-être pris @zw1915 l’a pris il y a 2 jours. Ouvertehelp wanted tech-debt
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
petercorke/machinevision-toolbox-python#150 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 3-5 jours Accessibilité débutants 43/100
petercorke/machinevision-toolbox-python#148 ·
Les mainteneurs répondent en général sous 1 jour
-
tech-debt
Difficulté 2/5 1-3 heures Accessibilité débutants 30/100
petercorke/machinevision-toolbox-python#147 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de petercorke/machinevision-toolbox-python
Issues similaires
-
Pull-through from gcr.io returns 500 when pulling using podman/buildahPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. OuverteIssue Triage-Needed
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
pulp/pulp_container#2581 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
521xueweihan/HelloGitHub#4040 ·
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
ClanGenOfficial/clangen#6313 ·
Les mainteneurs répondent en général sous 2 jours
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
Les mainteneurs répondent en général sous 1 jour
-
bug(trainer): CustomTrainer func_args with non literal values fail inside the TrainJobPeut-être pris @avanishkasar l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
kubeflow/sdk#879 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour