Inconsistent inference results for hello_classification sample between Windows and Linux (44369) (#3849)

* Fix image load issue

* remove extra line
This commit is contained in:
Sergey Lyubimtsev 2021-01-14 17:22:41 +03:00 committed by GitHub
parent 26d0d2c240
commit fa41a799b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
#include <string> #include <string>
#include <iterator>
#include <samples/common.hpp> #include <samples/common.hpp>
#include <inference_engine.hpp> #include <inference_engine.hpp>
@ -34,12 +35,13 @@ cv::Mat imreadW(std::wstring input_image_path) {
std::iostream::binary | std::ios_base::ate | std::ios_base::in); std::iostream::binary | std::ios_base::ate | std::ios_base::in);
if (input_image_stream.is_open()) { if (input_image_stream.is_open()) {
if (input_image_stream.good()) { if (input_image_stream.good()) {
input_image_stream.seekg(0, std::ios::end);
std::size_t file_size = input_image_stream.tellg(); std::size_t file_size = input_image_stream.tellg();
input_image_stream.seekg(0, std::ios::beg); input_image_stream.seekg(0, std::ios::beg);
std::vector<char> buffer(0); std::vector<char> buffer(0);
std::copy( std::copy(
std::istream_iterator<char>(input_image_stream), std::istreambuf_iterator<char>(input_image_stream),
std::istream_iterator<char>(), std::istreambuf_iterator<char>(),
std::back_inserter(buffer)); std::back_inserter(buffer));
image = cv::imdecode(cv::Mat(1, file_size, CV_8UC1, &buffer[0]), cv::IMREAD_COLOR); image = cv::imdecode(cv::Mat(1, file_size, CV_8UC1, &buffer[0]), cv::IMREAD_COLOR);
} else { } else {