我在Android上使用opencv,并已成功从手机的SD卡加载和处理jpg图像。现在我想操纵存储在SD卡上的视频中的帧。我已经用C ++编写并测试了opencv代码,但在尝试将其放入我的android-opencv项目时遇到链接错误。具体来说,当我添加代码行
时CvCapture* capture = cvCreateFileCapture( "/sdcard/testVideo.MOV" );
然后尝试重建项目我得到以下输出/错误:
OPENCV_CONFIG = ../../build/android-opencv.mk
PROJECT_PATH defaulting to this directory
/Users/me/Documents/Android/android-ndk-r4-crystax/ndk-build OPENCV_CONFIG=../../build/android-opencv.mk PROJECT_PATH=. V=0
Compile++ thumb: Assay <= /Users/me/Documents/Android/opencv/android/apps/MyApp/jni/Processor.cpp
SharedLibrary : libAssay.so
/Users/me/Documents/Android/opencv/android/build/obj/local/armeabi-v7a/libhighgui.a(cap.o): In function `cvCreateVideoWriter':
cap.cpp:(.text.cvCreateVideoWriter+0x16): undefined reference to `cvCreateVideoWriter_Images(char const*)'
cap.cpp:(.text.cvCreateVideoWriter+0x20): undefined reference to `cvCreateVideoWriter_Images(char const*)'
/Users/me/Documents/Android/opencv/android/build/obj/local/armeabi-v7a/libhighgui.a(cap.o): In function `cvCreateFileCapture':
cap.cpp:(.text.cvCreateFileCapture+0x2): undefined reference to `cvCreateFileCapture_Images(char const*)'
collect2: ld returned 1 exit status
make[1]: *** [/Users/me/Documents/Android/opencv/android/apps/MyApp/obj/local/armeabi/libAssay.so] Error 1
make: *** [libs/armeabi-v7a/libAssay.so] Error 2
似乎链接到cvCreateFileCapture
时出现问题。我已经读过opencv库被指定的顺序很重要,但我不确定我应该使用什么顺序(或者这是我的问题)。我的opencv库按以下顺序指定:
OPENCV_LIBS := $(OPENCV_LIB_DIRS) -lfeatures2d -lcalib3d -limgproc -lobjdetect \
-lvideo -lhighgui -lml -llegacy -lcore -lopencv_lapack -lflann \
-lzlib -lpng -ljpeg -ljasper
任何人都知道如何让cvCreateFileCapture
工作?
谢谢!
答案 0 :(得分:1)
要解决此问题,假设您正在使用trunk,您可能会尝试获取链接器问题的修复程序: https://code.ros.org/trac/opencv/changeset/4756
然而现在这仅支持从一系列图像中捕获:
// capture video from a sequence of images
// the filename when opening can either be a printf pattern such as
// video%04d.png or the first frame of the sequence i.e. video0001.png
要真正支持视频读/写,我们需要添加ffmpeg或其他视频库支持。我已经看到ffmpeg端口浮动,但没有时间或需要将它们添加到opencv for android。如果这有价值,或者您已经完成并提交补丁,请告诉我。请务必通过opencv trac站点执行此操作。