2016-09-13 2 views
1

프로젝트 here은 기본적으로 gradle 프로젝트 here의 샘플을 복사하여 붙여 넣습니다.C++ 프로젝트에서 OpenCV를 gradle로 통합하는 방법

다음 단계는 hello world이지만 OpenCV 프레임 워크 용입니다. 메모리에있는 그림을 읽고 표시합니다. 정확히 말하면, 당신이 볼 수 있듯이 main.cpp 우리는 더 그

#include <stdio.h> 
#include <opencv2/opencv.hpp> 
using namespace cv; 
int main(int argc, char** argv) 
{ 
    if (argc != 2) 
    { 
     printf("usage: DisplayImage.out <Image_Path>\n"); 
     return -1; 
    } 
    Mat image; 
    image = imread(argv[1], 1); 
    if (!image.data) 
    { 
     printf("No image data \n"); 
     return -1; 
    } 
    namedWindow("Display Image", WINDOW_AUTOSIZE); 
    imshow("Display Image", image); 
    waitKey(0); 
    return 0; 
} 

처럼 나는 OpenCV의 헤더를 포함하지만 나는 Gradle을 통해 LIB 자체를 추가 사투를 벌인거야. 아마도 prebuilt 방법을 사용해야하지만 실패합니다.

답변

0

난 당신이 헤더와 미리 만들어진 라이브러리 linkings 구성 할 필요가 있다고 생각 : 나는 보통 안드로이드에서 할

을,하지만 난 당신의 Gradle을 플러그인이 무엇인지 모르기 때문에 그것이 작동하는 것을 보장 할 수 없다. 그러나 구문을 변경할 수있는 gradle 버전에 따라 단서로 사용할 수 있습니다. 에 추가하려고, 예를 들어 opencv_core 더 3rparty 종속성을해야합니다 위해,

repositories { 
    libs(PrebuiltLibraries) { 
    opencv_core { 
    headers.srcDir "your opencv.dir" 
     binaries.withType(StaticLibraryBinary) { binary -> 
     // This closure will be executed once for every buildType/platform combination 
     def variantDir = binary.targetPlatform.architecture.name == 'i386' ? 'Win32' : 'x64' 
     staticLibraryFile = "path/to/library/${variantDir}/opencv_core.so" 
     } 
    } 
    opencv_another_lib { 
    headers.srcDir "your opencv.dir" 
     binaries.withType(StaticLibraryBinary) { binary -> 
     // This closure will be executed once for every buildType/platform combination 
     def variantDir = binary.targetPlatform.architecture.name == 'i386' ? 'Win32' : 'x64' 
     staticLibraryFile = "path/to/library/${variantDir}/opencv_another_lib.so" 
     } 
    } 
    } 

아마 당신의 headers.srcDir 정의, 후

opencv.dir="the site where opencv headers are" 

당신의 OpenCV의 libs와 정의 :

첫째로 당신의 OpenCV의 디렉토리를 정의 같은 길.

이 정보가 도움이되기를 바랍니다.

건배.

우 나이.

관련 문제