added OpenGL support to Gtk realization of highgui

This commit is contained in:
Vladislav Vinogradov 2011-11-28 08:23:26 +00:00
parent fb2fad52a2
commit 2a4fb155e1
6 changed files with 1027 additions and 466 deletions

View File

@ -37,9 +37,9 @@ endif(NOT CMAKE_TOOLCHAIN_FILE)
# Top level OpenCV project # Top level OpenCV project
# -------------------------------------------------------------- # --------------------------------------------------------------
if(NOT IOS) if(NOT IOS)
cmake_minimum_required(VERSION 2.6.3) cmake_minimum_required(VERSION 2.6.3)
else() else()
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
endif() endif()
project(OpenCV) project(OpenCV)
@ -77,9 +77,9 @@ endif()
# Default: dynamic libraries # Default: dynamic libraries
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
if(NOT IOS) if(NOT IOS)
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)") set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)")
else() else()
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)") set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)")
endif() endif()
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Include debug info into debug libs? # Include debug info into debug libs?
@ -335,9 +335,9 @@ endif()
# Build tests: # Build tests:
# =================================================== # ===================================================
if(NOT IOS) if(NOT IOS)
set(BUILD_TESTS ON CACHE BOOL "Build tests") set(BUILD_TESTS ON CACHE BOOL "Build tests")
else() else()
set(BUILD_TESTS OFF CACHE BOOL "Build tests") set(BUILD_TESTS OFF CACHE BOOL "Build tests")
endif() endif()
set(BUILD_PERF_TESTS ON CACHE BOOL "Build performance tests") set(BUILD_PERF_TESTS ON CACHE BOOL "Build performance tests")
@ -442,7 +442,7 @@ if(APPLE)
endif() endif()
if(IOS) if(IOS)
set(WITH_AVFOUNDATION ON CACHE BOOL "Use AVFoundation for Video I/O") set(WITH_AVFOUNDATION ON CACHE BOOL "Use AVFoundation for Video I/O")
endif() endif()
set(WITH_TBB OFF CACHE BOOL "Include Intel TBB support") set(WITH_TBB OFF CACHE BOOL "Include Intel TBB support")
@ -507,6 +507,17 @@ if(UNIX)
if(WITH_GTK) if(WITH_GTK)
CHECK_MODULE(gtk+-2.0 HAVE_GTK) CHECK_MODULE(gtk+-2.0 HAVE_GTK)
CHECK_MODULE(gthread-2.0 HAVE_GTHREAD) CHECK_MODULE(gthread-2.0 HAVE_GTHREAD)
if(WITH_OPENGL)
CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT)
if(HAVE_GTKGLEXT)
find_package(OpenGL QUIET)
if(OPENGL_FOUND)
set(HAVE_OPENGL 1)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
include_directories(${OPENGL_INCLUDE_DIR})
endif()
endif()
endif()
else() else()
set(HAVE_GTK FALSE) set(HAVE_GTK FALSE)
set(HAVE_GTHREAD FALSE) set(HAVE_GTHREAD FALSE)
@ -575,7 +586,7 @@ if(UNIX)
set(HAVE_DC1394 FALSE) set(HAVE_DC1394 FALSE)
endif() endif()
if(NOT APPLE) if(NOT APPLE)
CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H) CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
CHECK_FUNCTION_EXISTS(alloca HAVE_ALLOCA) CHECK_FUNCTION_EXISTS(alloca HAVE_ALLOCA)
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
@ -608,8 +619,8 @@ if(UNIX)
endif() endif()
endif() endif()
if (UNIX OR WIN32) if (UNIX OR WIN32)
if(NOT OPENCV_BUILD_3RDPARTY_LIBS) if(NOT OPENCV_BUILD_3RDPARTY_LIBS)
message(STATUS "NOT OPENCV_BUILD_3RDPARTY_LIBS **************************************************") message(STATUS "NOT OPENCV_BUILD_3RDPARTY_LIBS **************************************************")
include(FindZLIB) include(FindZLIB)
if(WITH_PNG) if(WITH_PNG)
include(FindPNG) include(FindPNG)
@ -631,9 +642,9 @@ if (UNIX OR WIN32)
set(JASPER_FOUND FALSE) set(JASPER_FOUND FALSE)
endif() endif()
if(WITH_JPEG) if(WITH_JPEG)
include(FindJPEG) include(FindJPEG)
else() else()
set(JPEG_FOUND FALSE) set(JPEG_FOUND FALSE)
endif() endif()
endif() endif()
endif() endif()
@ -1125,10 +1136,10 @@ if(WIN32)
endif() endif()
endif() endif()
if (WITH_OPENGL AND NOT HAVE_QT_OPENGL) if(WITH_OPENGL AND NOT HAVE_QT_OPENGL)
find_package(OpenGL QUIET) find_package(OpenGL QUIET)
if (OPENGL_FOUND) if(OPENGL_FOUND)
set(HAVE_OPENGL 1) set(HAVE_OPENGL 1)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES}) set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
include_directories(${OPENGL_INCLUDE_DIR}) include_directories(${OPENGL_INCLUDE_DIR})
@ -1725,7 +1736,8 @@ else()
endif() endif()
else() else()
status(" GTK+ 2.x:" HAVE_GTK THEN YES ELSE NO) status(" GTK+ 2.x:" HAVE_GTK THEN YES ELSE NO)
status(" GThread:" HAVE_GTHREAD THEN YES ELSE NO) status(" GThread :" HAVE_GTHREAD THEN YES ELSE NO)
status(" GtkGlExt:" HAVE_GTKGLEXT THEN YES ELSE NO)
endif() endif()
endif() endif()
endif() endif()
@ -1773,11 +1785,11 @@ if(UNIX AND NOT APPLE)
endif() endif()
endif() endif()
elseif(APPLE) elseif(APPLE)
if(NOT IOS) if(NOT IOS)
status(" Video I/O:" WITH_QUICKTIME THEN QuickTime ELSE QTKit) status(" Video I/O:" WITH_QUICKTIME THEN QuickTime ELSE QTKit)
else() else()
status(" Video I/O: AVFoundation") status(" Video I/O: AVFoundation")
endif() endif()
elseif(WIN32) elseif(WIN32)
status(" Video I/O:" HAVE_VIDEOINPUT THEN DirectShow ELSE NO) status(" Video I/O:" HAVE_VIDEOINPUT THEN DirectShow ELSE NO)
endif() endif()

View File

@ -98,7 +98,7 @@ struct CvCapture
virtual bool setProperty(int, double) { return 0; } virtual bool setProperty(int, double) { return 0; }
virtual bool grabFrame() { return true; } virtual bool grabFrame() { return true; }
virtual IplImage* retrieveFrame(int) { return 0; } virtual IplImage* retrieveFrame(int) { return 0; }
virtual int getCaptureDomain() { return CV_CAP_ANY; } // Return the type of the capture object: CV_CAP_VFW, etc... virtual int getCaptureDomain() { return CV_CAP_ANY; } // Return the type of the capture object: CV_CAP_VFW, etc...
}; };
/*************************** CvVideoWriter structure ****************************/ /*************************** CvVideoWriter structure ****************************/
@ -186,8 +186,13 @@ double cvGetModeWindow_GTK(const char* name);
double cvGetModeWindow_CARBON(const char* name); double cvGetModeWindow_CARBON(const char* name);
double cvGetPropWindowAutoSize_W32(const char* name); double cvGetPropWindowAutoSize_W32(const char* name);
double cvGetPropWindowAutoSize_GTK(const char* name);
double cvGetRatioWindow_W32(const char* name); double cvGetRatioWindow_W32(const char* name);
double cvGetRatioWindow_GTK(const char* name);
double cvGetOpenGlProp_W32(const char* name); double cvGetOpenGlProp_W32(const char* name);
double cvGetOpenGlProp_GTK(const char* name);
//for QT //for QT
#if defined (HAVE_QT) #if defined (HAVE_QT)

View File

@ -109,6 +109,8 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
return cvGetPropWindow_QT(name); return cvGetPropWindow_QT(name);
#elif defined WIN32 || defined _WIN32 #elif defined WIN32 || defined _WIN32
return cvGetPropWindowAutoSize_W32(name); return cvGetPropWindowAutoSize_W32(name);
#elif defined (HAVE_GTK)
return cvGetPropWindowAutoSize_GTK(name);
#else #else
return -1; return -1;
#endif #endif
@ -120,6 +122,8 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
return cvGetRatioWindow_QT(name); return cvGetRatioWindow_QT(name);
#elif defined WIN32 || defined _WIN32 #elif defined WIN32 || defined _WIN32
return cvGetRatioWindow_W32(name); return cvGetRatioWindow_W32(name);
#elif defined (HAVE_GTK)
return cvGetRatioWindow_GTK(name);
#else #else
return -1; return -1;
#endif #endif
@ -130,6 +134,8 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
#if defined (HAVE_QT) #if defined (HAVE_QT)
#elif defined WIN32 || defined _WIN32 #elif defined WIN32 || defined _WIN32
return cvGetOpenGlProp_W32(name); return cvGetOpenGlProp_W32(name);
#elif defined (HAVE_GTK)
return cvGetOpenGlProp_GTK(name);
#else #else
return -1; return -1;
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -214,6 +214,8 @@ int main(int argc, const char* argv[])
while (true) while (true)
{ {
int key = waitKey(1); int key = waitKey(1);
if (key >= 0)
key = key & 0xff;
if (key == 27) if (key == 27)
break; break;
@ -221,7 +223,13 @@ int main(int argc, const char* argv[])
double aspect = getWindowProperty("OpenGL Sample", WND_PROP_ASPECT_RATIO); double aspect = getWindowProperty("OpenGL Sample", WND_PROP_ASPECT_RATIO);
const double posStep = 0.1; const double posStep = 0.1;
#ifdef _WIN32
const double mouseStep = 0.001; const double mouseStep = 0.001;
#else
const double mouseStep = 0.000001;
#endif
const int mouseClamp = 300; const int mouseClamp = 300;
camera.setPerspectiveProjection(30.0 + fov / 100.0 * 40.0, aspect, 0.1, 1000.0); camera.setPerspectiveProjection(30.0 + fov / 100.0 * 40.0, aspect, 0.1, 1000.0);