Ask Your Question

manu.web's profile - activity

2013-01-05 11:48:08 -0600 asked a question Build Error with CalcOpticalFlowFarneback Function -> OpenCV -> C Language - Eclipse -> MacOSX

hi, i have to do a program using C Language and OpenCV Libreries for a project, I followed the guide for the installation for MACOSX on this site: OpenCV Installation

I used Mac Port for the Istallation.

I use Eclipse to program, Now when i try to compile this program, i get a Build Error and i think that it depends to CalcOpticalFlowFarneback() Function.

This is the code:

 #include <stdio.h>
  #include <cv.h>
  #include <highgui.h>
  #include <math.h>
  #include <time.h>


int main(){



    CvCapture* webcam = cvCreateCameraCapture(0);
    IplImage*prev=NULL;
    IplImage*next=NULL;
    char scelta;

    /*INIZIALIZZAZIONE FUNZIONE RAND*/

    srand(time(NULL));


    double pyr_scale=0.5; 
    int levels=1;
    int winsize=3; 
    int iterations=10;
    int poly_n=5; 
    double poly_sigma=1.1;
    int flags=0;

    sleep(2);

    if (!webcam){
    /* Exit with an error */
        puts("Attenzione! si รจ verificato un Errore in Fase di Attivazione della WebCam. Preghiamo di Riprovare!");
        return -1;
    }


    while (1) {

        prev = cvQueryFrame(webcam);//primi 8-bit single-channel immagine in ingresso
        next = cvQueryFrame(webcam);// immagine secondo ingresso della stessa dimensione e lo stesso tipo prev.

        CvSize isize = cvSize(80,80);
        IplImage *flow = cvCreateImage(isize, IPL_DEPTH_32F, 1); //immagine computerizzata che ha le stesse dimensioni e tipo CV_32FC2 prev
        if ((prev) && (next)) {



            cvCalcOpticalFlowFarneback(prev,next,flow,pyr_scale,levels,winsize,iterations,poly_n,poly_sigma,flags);

            scelta=cvWaitKey(20);
            if((char)scelta == 27){

                break;
            }


        }


    }

    cvDestroyWindow("VIDEO SORVEGLIANZA");
    cvReleaseCapture(&webcam);

    return 0;
}

and this is the error Log:

>     Undefined symbols for architecture x86_64: "_cvCalcOpticalFlowFarneback",
> referenced from:_main in main.o
>     ld: symbol(s) not found for architecture x86_64
>     collect2: ld returned 1 exit status
>     make: *** [cattura_foto] Error 1

And I want to specify that if i remove the cvCalcOpticalFlowFarneback Function i do not have any problems.

Thank you,

manu.web