-
Notifications
You must be signed in to change notification settings - Fork 165
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
Support CompressedImage and Stamped types #5
base: master
Are you sure you want to change the base?
Support CompressedImage and Stamped types #5
Conversation
@@ -80,6 +80,9 @@ def image_to_numpy(msg): | |||
data = data[...,0] | |||
return data | |||
|
|||
@converts_to_numpy(CompressedImage) | |||
def compressed_image_to_numpy(msg): | |||
return np.fromstring(msg.data, np.uint8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be np.frombuffer
- np.fromstring
is deprecated in this use (I know this because I deprecated it it!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this just feels like the wrong thing to do in general. If conversion from CompressedImage
is going to exist at all, it should do the full png/jpeg/etc decoding using the python imageio
module.
That might be a nasty dependency to pull in, so I'd rather not open that can of worms in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About frombuffer, done, commited.
About the CompressedImage, the reality of compressed images is not very nice. That transformation works for all jpg. For png one can do exactly the same but must skip the first 12 bits of a header. For CompressedImages that contain a depth image (there is no way to know) there is one step more even... So that would be a bit of a mess to figure out all the cases.
I think this implementation helps, better than none.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For png one can do exactly the same but must skip the first 12 bits of a header
Huh? What do you mean by this?
So that would be a bit of a mess to figure out all the cases.
Then throw an error in the cases that aren't supported.
I think this implementation helps, better than none.
I disagree - the point of this library was to do the "one obvious thing". The obviously thing for a comrpessed image is to return a 3D RGB array. Returning a 1d sequence of bytes is not what I would expect at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small complaint
I don't like At the very least, I would consider |
Following up #3 but only adding CompressedImage and the XXXXStamped types.