2011-12-14 3 views
1

Ok. 나는이 사이트에서 "CMake를 사용하여 빌드"지침을 따랐습니다. http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Portcmake를 통해 설치된 OpenCV-2.3.1을 사용하여 XCode에서 샘플 MacOSX FaceTracker 프로그램을 실행하려고 시도했습니다.

"build"폴더를 만들었습니다. cmake를 사용하여 "Unix Makefiles"를 생성했습니다. make -j8을 실행하고 sudo를 설치합니다. 모든 것이 있어야 할 곳이어야합니다. 잘못된. 나는 FaceTracker.xcodeproj 파일을 열어 "실행"을 클릭하고, 여기에 내가 가진 무엇 :

런 대상 나의 Mac으로 64 비트 계획 'FaceTracker을'실행 유효하지 않습니다.

'FaceTracker'구성표는 실행 대상 My Mac 64 비트에서 지원되는 SDK 용 빌드 가능 빌드 파일을 포함하고 있지 않습니다. 타겟이 모두 Xcode의이 버전에서 지원되는 인 SDK를 지정해야합니다.

이 기능을 사용하려면 어떻게해야합니까? 라이온이 미리 작성한 OpenCV 패키지를 사용하는 것이 얼마나 힘들다고 생각 하느냐고 두려워합니다. 나는 Xcode가 처음이다.

편집 : 12 월 14 일 7:05 PM :

가 나는 helloworld를 프로그램

//////////////////////////////////////////////////////////////////////// 
// 
// hello-world.cpp 
// 
// This is a simple, introductory OpenCV program. The program reads an 
// image from a file, inverts it, and displays the result. 
// 
//////////////////////////////////////////////////////////////////////// 
#include <stdlib.h> 
#include <stdio.h> 
#include <math.h> 
#include <cv.h> 
#include <highgui.h> 


int main(int argc, char *argv[]) 
{ 
    IplImage* img = 0; 
    int height,width,step,channels; 
    uchar *data; 
    int i,j,k; 

    if(argc<2){ 
    printf("Usage: main <image-file-name>\n\7"); 
    exit(0); 
    } 

    // load an image 
    img=cvLoadImage(argv[1]); 
    if(!img){ 
    printf("Could not load image file: %s\n",argv[1]); 
    exit(0); 
    } 

    // get the image data 
    height = img->height; 
    width  = img->width; 
    step  = img->widthStep; 
    channels = img->nChannels; 
    data  = (uchar *)img->imageData; 
    printf("Processing a %dx%d image with %d channels\n",height,width,channels); 

    // create a window 
    cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE); 
    cvMoveWindow("mainWin", 100, 100); 

    // invert the image 
    for(i=0;i<height;i++) for(j=0;j<width;j++) for(k=0;k<channels;k++) 
    data[i*step+j*channels+k]=255-data[i*step+j*channels+k]; 

    // show the image 
    cvShowImage("mainWin", img); 

    // wait for a key 
    cvWaitKey(0); 

    // release the image 
    cvReleaseImage(&img); 
    return 0; 
} 

내가 GCC로 컴파일 시도했다 : 내 문제처럼

gcc helloworld.cpp 
helloworld.cpp:12:16: error: cv.h: No such file or directory 
helloworld.cpp:13:21: error: highgui.h: No such file or directory 
helloworld.cpp: In function ‘int main(int, char**)’: 
helloworld.cpp:18: error: ‘IplImage’ was not declared in this scope 
helloworld.cpp:18: error: ‘img’ was not declared in this scope 
helloworld.cpp:20: error: ‘uchar’ was not declared in this scope 
helloworld.cpp:20: error: ‘data’ was not declared in this scope 
helloworld.cpp:29: error: ‘cvLoadImage’ was not declared in this scope 
helloworld.cpp:40: error: expected primary-expression before ‘)’ token 
helloworld.cpp:40: error: expected `;' before ‘img’ 
helloworld.cpp:44: error: ‘CV_WINDOW_AUTOSIZE’ was not declared in this scope 
helloworld.cpp:44: error: ‘cvNamedWindow’ was not declared in this scope 
helloworld.cpp:45: error: ‘cvMoveWindow’ was not declared in this scope 
helloworld.cpp:52: error: ‘cvShowImage’ was not declared in this scope 
helloworld.cpp:55: error: ‘cvWaitKey’ was not declared in this scope 
helloworld.cpp:58: error: ‘cvReleaseImage’ was not declared in this scope 
Jesse:testing jessebikman$ g++ helloworld.cpp 
helloworld.cpp:12:16: error: cv.h: No such file or directory 
helloworld.cpp:13:21: error: highgui.h: No such file or directory 
helloworld.cpp: In function ‘int main(int, char**)’: 
helloworld.cpp:18: error: ‘IplImage’ was not declared in this scope 
helloworld.cpp:18: error: ‘img’ was not declared in this scope 
helloworld.cpp:20: error: ‘uchar’ was not declared in this scope 
helloworld.cpp:20: error: ‘data’ was not declared in this scope 
helloworld.cpp:29: error: ‘cvLoadImage’ was not declared in this scope 
helloworld.cpp:40: error: expected primary-expression before ‘)’ token 
helloworld.cpp:40: error: expected `;' before ‘img’ 
helloworld.cpp:44: error: ‘CV_WINDOW_AUTOSIZE’ was not declared in this scope 
helloworld.cpp:44: error: ‘cvNamedWindow’ was not declared in this scope 
helloworld.cpp:45: error: ‘cvMoveWindow’ was not declared in this scope 
helloworld.cpp:52: error: ‘cvShowImage’ was not declared in this scope 
helloworld.cpp:55: error: ‘cvWaitKey’ was not declared in this scope 
helloworld.cpp:58: error: ‘cvReleaseImage’ was not declared in this scope 

보인다 설치된 libs와 함께,하지만 난 내 플랫폼이 리눅스가 아니라 OS X, 그리고 Macports 또는 Home Brew를 사용하지 않았다는 것을 고려하여 어디서 찾을 수 있을지 잘 모르겠다. 나는 installati의 권장 된 방법을 사용했다. 에, CMake. 내가 CMake에서 사용하는 위치를 사용하여 내 Mac에서 PKG_CONFIG_PATH를 설정하는 방법을 알고 있습니까? 설치 방법은 매우 혼란스럽고 OpenCV를 제거하기 위해 CMake를 사용할 수있는 것처럼 보이지 않습니다. 이는 또한 매우 혼란 스럽습니다.

+0

http://stackoverflow.com/a/8498273/176769 – karlphillip

+0

나는 당신이 만든 제안 사항을 반영하기 위해 내 질문에 업데이트되었습니다. 커맨드 라인에서 컴파일이 작동하지 않아서 그 라이브러리가 보이지 않는 것 같습니다. – JesseBikman

답변

2

기본적으로 모든 것을 cmd 라인에 추가하는 것을 잊었습니다! 충당 라이브러리와 헤더 디렉토리 libs와 디렉토리와 링크 :

g++ helloworld.cpp -o helloworld -I/usr/local/include/opencv -I/usr/local/include -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann 
+0

이제 알 겠어 : 아키텍처 x86_64에 대한 정의되지 않은 기호 : 참조 : std :: ios_base :: Init :: Init() 참조 : ccHgPC7D.o의 __static_initialization_and_destruction_0 (int, int) "std :: ios_base :: 초기화 : ~ Init() "참조 : ccHgPC7D.o의 ___tcf_1 ld : 아키텍처 x86_64에 대한 심볼을 찾지 못했습니다. collect2 : ld가 1을 반환했습니다. 종료 상태 – JesseBikman

+0

나는 실수로'gcc'를 사용했습니다. 'g ++ '을 사용해야합니다. 결국 CPP 파일입니다. 음,이 문제를 반영하여 답변이 업데이트되었습니다. – karlphillip

+0

또한 도움이되거나 질문에 대한 공식 답변으로 선택하면 미래에 다른 사람들에게 도움이 될 수 있도록 내 답변에 투표하는 것을 잊지 마십시오. 답변을 공무원으로 선택하려면 답변 옆에있는 확인란을 클릭하십시오. 이것이 효과적인지 아닌지 알려주세요. – karlphillip

관련 문제