我用c++和OpenCV写了一段代码:
#include <iostream>
#include <time.h>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
using namespace std;
int main()
{
...
return 0;
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试在终端上运行我的代码并使用 g++ 进行构建:
g++ $(pkg-config --cflags --libs opencv) -std=c++11 yourFile.cpp -o yourFileProgram
Run Code Online (Sandbox Code Playgroud)
但我收到此错误:
...
ld: warning: ignoring file /opt/homebrew/Cellar/opencv/4.5.1_2/lib/libopencv_core.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file /opt/homebrew/Cellar/opencv/4.5.1_2/lib/libopencv_photo.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
"cv::Mat::Mat()", referenced from:
_main in cv_test-ff1014.o
"cv::Mat::~Mat()", referenced …
Run Code Online (Sandbox Code Playgroud) 我需要使用 matplotlib 中的 2 个特征绘制具有多个线性回归的 3D 图。我怎样才能做到这一点?
这是我的代码:
import pandas
from sklearn import linear_model
df = pandas.read_csv("cars.csv")
X = df[['Weight', 'Volume']]
y = df['CO2']
regr = linear_model.LinearRegression()
predictedCO2 = regr.predict([scaled[0]])
print(predictedCO2)
Run Code Online (Sandbox Code Playgroud) 我下载了 libtorch 并在 macbook pro ARM 上制作了这些文件:
example-app/
build/
libtorch/
CMakeLists.txt
example-app.cpp
Run Code Online (Sandbox Code Playgroud)
然后我使用这些命令来构建火炬:
cmake -DCMAKE_PREFIX_PATH=/path-to-example-app/example-app/libtorch
make
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
building for macOS-x86_64 but attempting to link with file built for unknown-arm64
Run Code Online (Sandbox Code Playgroud)
你能帮助我吗?
我使用 C++ 编写了一个简单的 OpenCV 代码并在 linux 中运行它:
\n#include <iostream>\n#include <opencv2/opencv.hpp>\n#include <opencv2/highgui.hpp>\nusing namespace std;\nint main()\n{\n cv::Mat image;\n\xc2\xa0 image = cv::imread("sajjad.jpg", 1);\n\xc2\xa0\n\xc2\xa0 cv::namedWindow("Display Image", cv::WINDOW_AUTOSIZE);\n\xc2\xa0 cv::imshow("Display Image", image);\n\xc2\xa0 cv::waitKey(0);\n\xc2\xa0 return 0;\n}\n
Run Code Online (Sandbox Code Playgroud)\n我收到此错误:
\nopencv_test.cpp:2:10: fatal error: opencv2/opencv.hpp: No such file or directory\n #include <opencv2/opencv.hpp>\n ^~~~~~~~~~~~~~~~~~~~\ncompilation terminated.\n
Run Code Online (Sandbox Code Playgroud)\n如何在linux中安装C++的OpenCV?
\n