Я установил Ubuntu 14.04 и OpenCV, используя действия, описанные здесь https://solarianprogrammer.com/2014/04/21/opencv-beaglebone-black-ubuntu/
Я пытаюсь скомпилировать следующий код (сохраненный в текстовом файле с именем, как test2.cpp. test2.cpp и lena.jpg были копируются в beaglebone домашнюю папку):OpenCV на Beaglebone
// Test to convert a color image to gray
// Build on Linux with:
// g++ test2.cpp -o test2 -lopencv_core -lopencv_imgproc -lopencv_highgui
#include <opencv2/opencv.hpp>
#include <iostream>
int main() {
// Load the image file and check for success
cv::Mat input = cv::imread("lena.jpg", 1);
if(!input.data) {
std::cout << "Unable to open the image file" << std::endl;
return -1;
}
// Convert the input file to gray
cv::Mat gray_image;
cvtColor(input, gray_image, cv::COLOR_BGR2GRAY);
// Save the result
cv::imwrite("lena_gray.jpg", gray_image);
return 0;
}
с помощью г ++ test2.cpp -o test2 -lopencv_core -lopencv_imgproc -lopencv_highgui Я также пытался говорить компилятор, где библиотеки с помощью -L/USR/местные/Библиотека. (там были найдены файлы libopencv). Но каждый раз возникала следующая ошибка:
[email protected]:~$ g++ test2.cpp -o test2 -lopencv_core -lopencv_imgproc -lopencv_highgui -L usr/local/lib
/tmp/cckXjOPd.o: In function `main':
test2.cpp:(.text+0x26): undefined reference to `cv::imread(cv::String const&, int)'
test2.cpp:(.text+0xf0): undefined reference to `cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int=""> > const&)'
collect2: error: ld returned 1 exit status
Может кто-нибудь помочь мне здесь? Любая помощь будет оценена по достоинству.
Typo: вам не хватает ведущего '/' для пути к библиотеке. Вам нужно '-L/usr/local/lib'. Может быть, проще написать «Makefile», где этот тип вещей установлен правильно. – juanchopanza
Я попытался добавить ведущую/но полученную ту же ошибку. – Clive