Ubuntu11.04でOpenCV2.2をコンパイル
5月12日追記:
この問題は,svn版(r5099)で修正されたので,チェックアウト後に下記3ファイル+cap_v4l.cpp をコピーしてコンパイルするのが最も良い方法でしょう.
https://code.ros.org/gf/project/opencv/scmsvn/?action=ScmCommitDetail&scm_commit_id=109758
V4Lを利用しない場合は,-D WITH_V4L=OFF のオプションをつけて cmake を実行するのも良いでしょう.
——————–
Ubuntu11.04でOpenCV2.2をコンパイルするためのパッチです.
https://code.ros.org/trac/opencv/ticket/937
を修正したものです.
内容は,以下の様に || を && に修正する2ヶ所,< linux/videodev.h>を<libv4l1-videodev.h>に修正する2ヶ所,の計4ヶ所の変更だけなので,手で修正しても良いかもしれません.
ちなみに,SVN版では r4962 で,|| -> && の箇所は修正されています.が,インクルードファイルの方は,なぜかそのままですね….V4Lを利用しない限りは,全く関係ありませんが.
diff -u modules/highgui/src/cap.cpp modules/highgui/src.mod/cap.cpp
--- modules/highgui/src/cap.cpp 2011-05-10 09:15:45.978453001 +0900
+++ modules/highgui/src.mod/cap.cpp 2011-05-10 09:25:04.406453002 +0900
@@ -171,7 +171,7 @@
if (capture)
return capture;
#endif
- #if defined (HAVE_CAMV4L) || defined (HAVE_CAMV4L2)
+ #if defined (HAVE_CAMV4L) && defined (HAVE_CAMV4L2)
capture = cvCreateCameraCapture_V4L (index);
if (capture)
return capture;
diff -u modules/highgui/src/cap_libv4l.cpp modules/highgui/src.mod/cap_libv4l.cpp
--- modules/highgui/src/cap_libv4l.cpp 2011-05-10 09:15:45.970453003 +0900
+++ modules/highgui/src.mod/cap_libv4l.cpp 2011-05-10 09:25:04.394453003 +0900
@@ -241,7 +241,12 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
+#include <libv4l1-videodev.h>
+#else
#include <linux/videodev.h>
+#endif
#include <linux/videodev2.h>
#include <libv4l1.h>
diff -u modules/highgui/src/cap_v4l.cpp modules/highgui/src.mod/cap_v4l.cpp
--- modules/highgui/src/cap_v4l.cpp 2011-05-10 09:15:45.978453001 +0900
+++ modules/highgui/src.mod/cap_v4l.cpp 2011-05-10 09:25:04.406453002 +0900
@@ -202,7 +202,7 @@
#include "precomp.hpp"
-#if !defined WIN32 && (defined HAVE_CAMV4L || defined HAVE_CAMV4L2)
+#if !defined WIN32 && defined HAVE_CAMV4L && defined HAVE_CAMV4L2
#define CLEAR(x) memset (&(x), 0, sizeof (x))
@@ -214,7 +214,12 @@
#include <sys/types.h>
#include <sys/mman.h>
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
+#include <libv4l1-videodev.h>
+#else
#include <linux/videodev.h>
+#endif
#include <string.h>
#include <stdlib.h>
Common subdirectories: modules/highgui/src/files_Qt and modules/highgui/src.mod/files_Qt
