puku0x / cvdrone

CV Drone (= OpenCV + AR.Drone)
https://github.com/puku0x/cvdrone/wiki/How-to-build
Other
202 stars 94 forks source link

av_free_frame not declared when using with ubuntu 12.04 #33

Closed yteo006 closed 8 years ago

yteo006 commented 8 years ago

hi, apparently i have installed ubuntu 12.04, then also had done with apt-get update, apt-get upgrade, install ffmpeg, install libopencv-dev, install build-essential and install libav-tools. then i proceed making file with make command under the build/linux directory. i had the error message saying that av_free_frame not declared from video.cpp. i need help with this.

puku0x commented 8 years ago

This may happen only on Ubuntu 12.04.

To solve this,

1.Update dependencies

$ sudo apt-get update
$ sudo apt-get upgrade

2.Comment out the following lines in ardrone.h

//#include <opencv/cv.h>
//#include <opencv/highgui.h>

3.Replace avcodec_free_frame to av_free

    // AR.Drone 2.0
    if (version.major == ARDRONE_VERSION_2) {
        // Deallocate the frame
        if (pFrame) {
            #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
            av_frame_free(&pFrame);
            #else
            av_free(&pFrame);
            //avcodec_free_frame(&pFrame);
            #endif
            pFrame = NULL;
        }

        // Deallocate the frame
        if (pFrameBGR) {
            #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
            av_frame_free(&pFrameBGR);
            #else
            av_free(&pFrameBGR);
            //avcodec_free_frame(&pFrameBGR);
            #endif
            pFrameBGR = NULL;
        }

4.Build it by the following makefile

CXX           = g++
CXXFLAGS      = -O2 -Wall -D__STDC_CONSTANT_MACROS 
LIBS          = -lm                     \
                -lpthread               \
                -lavutil                \
                -lavformat              \
                -lavcodec               \
                -lswscale               \
                -lopencv_calib3d        \
                -lopencv_core           \
                -lopencv_features2d     \
                -lopencv_flann          \
                -lopencv_highgui        \
                -lopencv_imgproc        \
                -lopencv_ml             \
                -lopencv_objdetect      \
                -lopencv_video
OBJS          = ../../src/ardrone/ardrone.o \
                ../../src/ardrone/command.o \
                ../../src/ardrone/config.o  \
                ../../src/ardrone/udp.o     \
                ../../src/ardrone/tcp.o     \
                ../../src/ardrone/navdata.o \
                ../../src/ardrone/version.o \
                ../../src/ardrone/video.o   \
                ../../src/main.o
PROGRAM       = test.a

$(PROGRAM):     $(OBJS)
        $(CXX) $(OBJS) -o $(PROGRAM) $(CXXFLAGS) $(LDFLAGS) $(LIBS) 

clean:;         rm -f *.o *~ $(PROGRAM) $(OBJS)

install:        $(PROGRAM)
        install -s $(PROGRAM) $(DEST)