-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Side effects of copying an empty/invalid yarp::sig::Image #2349
Comments
That
The whole We should schedule a big rewriting of this part... |
There is another one here: yarp/src/libYARP_sig/src/yarp/sig/Image.copyPixels.cpp Lines 1459 to 1462 in b65ceeb
This is why manually setting the pixel code in the target image does not help (in case anyone thinks of calling yarp::sig::FlexImage image1, image2;
image2.setPixelCode(VOCAB_PIXEL_RGB);
image2 = image1; // prints "*** Tried to copy type 0 to 6449010" and quits |
This #1932 deprecates |
We had an internal discussion, and, since the interface is supposed to return false when the image is not available, we will fix the client to return false if the image is not ready yet. Later, we will investigate how to properly handle this in
|
* Avoid crashing when no image was received yet (Fixes robotology#2349) * Associate the right timestamp with the image
* Avoid crashing when no image was received yet (Fixes robotology#2349) * Associate the right timestamp with the image
I have observed neither base
yarp::sig::Image
nor its derivedyarp::sig::FlexImage
can be safely copied prior to populating them with pixels. In short, all boils down to:yarp::sig::FlexImage image1, image2; image2 = image1; // prints "*** Trying to allocate an invalid pixel type image" and quits
This is caused by the following lines (note the somewhat draconian
std::exit
call) and the fact thatgetPixelCode
equalsVOCAB_PIXEL_INVALID
:yarp/src/libYARP_sig/src/yarp/sig/Image.cpp
Lines 349 to 353 in b65ceeb
In a more realistic scenario, this bug exploded in my face while attempting a remote connection to an RGBD sensor. Steps:
VOCAB_PIXEL_RGB
internally (ref).yarp::sig::FlexImage
, whereas depth frames useyarp::sig::ImageOf<yarp::sig::PixelFloat>
.yarp::dev::IRGBDSensor
'sgetRgbImage
andgetDepthImage
, respectively.Unless you place a small delay between steps 2. and 3.,
getRgbImage
will force the application to quit, showing that same invalid pixel type error. On the other hand,getDepthImage
is fine. This is caused byFlexImage
not having its internal pixel code initialized, as demonstrated earlier. Conversely,ImageOf<T>
always knows how to interpret itsT
pixel type (ref), no matter if it is storing a frame or not yet.In view of this, all RGBDSensorClient does is to periodically receive streamed RGB+D frames from the server device, store them locally in their respective class members, and make them available on request via
getRgbImage
andgetDepthImage
. In this last stage, the copy assignment operator is invoked (same as in my first snippet, see above). Before the first RGB frame arrives,last_rgb
does not know what pixel type to expect andgetPixelCode()
returnsVOCAB_PIXEL_UNKNOWN
, causing the early exit. Ref.: RGBDSensorClient_StreamingMsgParser.cppI propose to drop the draconian
std::exit
call and allow cloning empty/invalidFlexImage
instances. This is not a problem withImageOf<T>
just because of the pixel code being known beforehand. Perhaps a more thorough review is to be considered due to:yarp/src/libYARP_sig/src/yarp/sig/Image.cpp
Line 11 in b65ceeb
Config: Ubuntu 16.04/18.04, GCC 7.5.0, YARP 3.4 (3.4.0+8-20200715.210+gitb14899f).
The text was updated successfully, but these errors were encountered: