我已经编写了一个简单的代码,用于在 aruco 库中创建制造商,它是
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/aruco.hpp>
using namespace cv;
int main(int argc, char *argv[]) {
int dictionaryId = 100;
int markerId = 45;
int borderBits = 2;
int markerSize = 2450;
bool showImage = true;
cv::Ptr<aruco::Dictionary> dictionary = aruco::getPredefinedDictionary(aruco::PREDEFINED_DICTIONARY_NAME(dictionaryId));
Mat markerImg;
aruco::drawMarker(dictionary, markerId, markerSize, markerImg, borderBits);
if(showImage) {
imshow("marker", markerImg);
waitKey(0);
}
imwrite("out.png", markerImg);
return 0;
}
当我尝试使用命令编译和运行它时
g++ -I/usr/local/include/opencv -I/usr/include/opencv2 -L/usr/local/lib/ -g -o binary create_marker.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_stitching -lopencv_aruco
正如本网站的解决方案之一给出的那样,它给出了这个错误
g++ -I/usr/local/include/opencv -I/usr/include/opencv2 -L/usr/local/lib/ -g -o binary create_marker.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_stitching -lopencv_aruco /usr/bin/ld: 找不到 -lopencv_aruco collect2: 错误: ld 返回 1 退出状态
有人可以指出我做错了什么,因为我是opencv的新手谢谢!