-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix bad image check and improve it too
- Loading branch information
Showing
2 changed files
with
13 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -235,11 +235,14 @@ const std::vector<int> getConversionCode(std::string src_encoding, std::string d | |
cv::Mat matFromImage(const sensor_msgs::Image& source) | ||
{ | ||
int source_type = getCvType(source.encoding); | ||
int byte_depth = enc::bitDepth(source.encoding) / 8; | ||
int num_channels = enc::numChannels(source.encoding); | ||
|
||
if (source.height > source.step) | ||
if (source.step != source.width * byte_depth * num_channels) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
vrabaud
Author
Contributor
|
||
{ | ||
std::stringstream ss; | ||
ss << "Image is wrongly formed: height > step or " << source.height << " > " << source.step; | ||
ss << "Image is wrongly formed: step != width * byte_depth * num_channels or " << source.step << " != " << | ||
source.width << " * " << byte_depth << " * " << num_channels; | ||
throw Exception(ss.str()); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is offending invariant check that prevents aligned image as discussed in #27. I think this has to be:
if (source.step < source.width * byte_depth * num_channels)