Программы на C++. Форум разработчиков
Anonymous
В cpp извлеките блок кода в meth, вызывающий sigsegv
Сообщение
Anonymous » 16 май 2024, 07:08
Ниже приведен код ошибки, он вызывает ошибку в ort_session.Run
Код: Выделить всё
#include "gtest/gtest.h"
#include "onnx_helper.h"
#include "ndarray.h"
#include "opencv_helper.h"
#include "vector_helper.h"
#include
#include
#include
class OnnxHelper2Test : public testing::Test {
protected:
// static void SetUpTestCase() {
// }
};
std::pair handle_input_img(const std::string &input_img_path) {
// Load the image using OpenCV
cv::Mat input_mat = cv::imread(input_img_path);
// Convert to float
cv::cvtColor(input_mat, input_mat, cv::COLOR_BGR2RGB);
input_mat.convertTo(input_mat, CV_32F);
// Normalize
input_mat /= 255.0;
// Convert the preprocessed image to a vector of floats
Ndarray input_img = mat_to_ndarray(input_mat);
// std::string r = xarr_to_str(xa);
input_img.transpose({2, 0, 1});
// const std::string &xa_str1 = xarr_to_str(xa);
// std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/78487258/in-cpp-extract-code-block-to-meth-cause-sigsegv[/url]
1715832494
Anonymous
Ниже приведен код ошибки, он вызывает ошибку в ort_session.Run [code]#include "gtest/gtest.h" #include "onnx_helper.h" #include "ndarray.h" #include "opencv_helper.h" #include "vector_helper.h" #include #include #include class OnnxHelper2Test : public testing::Test { protected: // static void SetUpTestCase() { // } }; std::pair handle_input_img(const std::string &input_img_path) { // Load the image using OpenCV cv::Mat input_mat = cv::imread(input_img_path); // Convert to float cv::cvtColor(input_mat, input_mat, cv::COLOR_BGR2RGB); input_mat.convertTo(input_mat, CV_32F); // Normalize input_mat /= 255.0; // Convert the preprocessed image to a vector of floats Ndarray input_img = mat_to_ndarray(input_mat); // std::string r = xarr_to_str(xa); input_img.transpose({2, 0, 1}); // const std::string &xa_str1 = xarr_to_str(xa); // std::cout Подробнее здесь: [url]https://stackoverflow.com/questions/78487258/in-cpp-extract-code-block-to-meth-cause-sigsegv[/url]