!9065 fix opencv bug

From: @pandoublefeng
Reviewed-by: 
Signed-off-by:
pull/9065/MERGE
mindspore-ci-bot 5 years ago committed by Gitee
commit 81ff2d556a

@ -134,6 +134,20 @@ void ExecutionTree::PrintNode(std::ostream &out, const std::shared_ptr<DatasetOp
// Start the execution of the tree
Status ExecutionTree::Launch() {
// opencv limit too many threads
#ifndef ENABLE_ANDROID
#if !defined(_WIN32) && !defined(_WIN64)
int32_t thread_num = get_nprocs();
if (thread_num == 0) {
std::string err_msg = "Invalid thread number.";
RETURN_STATUS_UNEXPECTED(err_msg);
}
if (thread_num > 8)
cv::setNumThreads(8);
else
cv::setNumThreads(thread_num);
#endif
#endif
// Tree must be built and prepared before it can be launched!
if (tree_state_ != kDeTStateReady) {
std::string err_msg =

@ -21,6 +21,12 @@
#include <stack>
#include <string>
#include <vector>
#ifndef ENABLE_ANDROID
#if !defined(_WIN32) && !defined(_WIN64)
#include <sys/sysinfo.h>
#include <opencv2/imgproc/imgproc.hpp>
#endif
#endif
#include "minddata/dataset/engine/datasetops/dataset_op.h"
#include "minddata/dataset/util/status.h"
#include "mindspore/ccsrc/minddata/dataset/engine/perf/profiling.h"

@ -97,8 +97,6 @@ Status Resize(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *out
if (input_cv->Rank() != 3 && input_cv->Rank() != 2) {
RETURN_STATUS_UNEXPECTED("Input Tensor is not in shape of <H,W,C> or <H,W>");
}
// OpenCv lanuch too many threads.
cv::setNumThreads(8);
cv::Mat in_image = input_cv->mat();
// resize image too large or too small
if (output_height == 0 || output_height > in_image.rows * 1000 || output_width == 0 ||

Loading…
Cancel
Save