我剛開始接觸OpenCV的,我有下面的示例.cpp文件(從opencv.org):凡/如何放置在OpenCV中
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char** argv)
{
Mat image;
image = imread(argv[1], 1);
if(argc != 2 || !image.data)
{
printf("No image data \n");
return -1;
}
namedWindow("Display Image", CV_WINDOW_AUTOSIZE);
imshow("Display Image", image);
waitKey(0);
return 0;
}
,我有以下CMakeList .cmake文件:
project(opencvTEST)
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
find_package(OpenCV REQUIRED)
# Project Executable
add_executable (test test.cpp)
target_link_libraries(test ${OpenCV_LIBS})
我有一個蘋果(OS 10.6.8),我已經安裝了OpenCV的2.4.3 CMake的,而且我已經搜查高和低,試過無數不同的東西來得到這個測試程序來編譯(我使用的命令行 - 沒有IDE),但我得到以下編譯錯誤(顯然,由於include
語句的工作不正常):
test.cpp:3:30: error: opencv2/opencv.hpp: No such file or directory
test.cpp:5: error: ‘cv’ is not a namespace-name
test.cpp:5: error: expected namespace-name before ‘;’ token
test.cpp: In function ‘int main(int, char**)’:
test.cpp:9: error: ‘Mat’ was not declared in this scope
test.cpp:9: error: expected `;' before ‘image’
test.cpp:10: error: ‘image’ was not declared in this scope
test.cpp:10: error: ‘imread’ was not declared in this scope
test.cpp:18: error: ‘CV_WINDOW_AUTOSIZE’ was not declared in this scope
test.cpp:18: error: ‘namedWindow’ was not declared in this scope
test.cpp:19: error: ‘imshow’ was not declared in this scope
test.cpp:21: error: ‘waitKey’ was not declared in this scope
我有一個在同一目錄下命名爲opencv2
夾test.cpp
和opencv.hpp
是opencv2
,所以我不明白爲什麼它沒有找到它。有任何想法嗎?
此外,一般來說,OpenCV希望您將源(.cpp等)文件放在哪裏?
挺有意思的......我不知道'之間的差異< ''和''''''#include'語句。你知道將'opencv'和'opencv2'(帶有頭文件的文件夾)複製到'/ usr/include'目錄是否有缺點? – MuffinTheMan