Draft
Conversation
Owner
Author
|
@likholat please take a look |
likholat
reviewed
Oct 10, 2024
| auto colorRead = (channels == 3) ? CV_32FC3 : CV_32FC1; | ||
| c.convertTo(c, colorRead, scale); | ||
|
|
||
| ov::Shape input_shape = { 1, size_t(c.rows), size_t(c.cols), size_t(channels) }; |
There was a problem hiding this comment.
please use C++ style casting: static_cast<size_t>(c.rows)
|
|
||
| ov::Tensor OpenVINOModel::convertToTensor(const cv::Mat& img, bool normalize, bool color) | ||
| { | ||
| cv::Mat c = img.clone(); |
|
|
||
| ov::Shape input_shape = { 1, size_t(c.rows), size_t(c.cols), size_t(channels) }; | ||
| ov::element::Type input_type = ov::element::f32; | ||
| ov::Tensor converted = ov::Tensor(input_type, input_shape, c.data); |
There was a problem hiding this comment.
We don't need to create 2 tensors to copy data
Suggested change
| ov::Tensor converted = ov::Tensor(input_type, input_shape, c.data); | |
| ov::Tensor res = ov::Tensor(input_type, input_shape); | |
| std::memcpy(res.data(), img.data, img.total() * img.elemSize()); |
| @@ -0,0 +1,85 @@ | |||
|
|
|||
| #include "OpenvinoModel.h" | |||
There was a problem hiding this comment.
Suggested change
| #include "OpenvinoModel.h" | |
| #include "OpenvinoModel.hpp" |
likholat
reviewed
Oct 10, 2024
| c.convertTo(c, colorRead, scale); | ||
|
|
||
| ov::Shape input_shape = { 1, size_t(c.rows), size_t(c.cols), size_t(channels) }; | ||
| ov::element::Type input_type = ov::element::f32; |
There was a problem hiding this comment.
We should add a check for input data type, something like:
Suggested change
| ov::element::Type input_type = ov::element::f32; | |
| ov::element::Type input_type; | |
| switch (img.type()) { | |
| case CV_32F: | |
| precision = ov::element::f32; | |
| break; | |
| case CV_8U: | |
| precision = ov::element::u8; | |
| break; | |
| default: | |
| OPENVINO_THROW("Unsupported data type for image'"); | |
| } |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add OpenVINO backend to the EasyOCR C++ library