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
# --------------------------------------------------------------
if(NOT IOS)
cmake_minimum_required(VERSION 2.6.3)
cmake_minimum_required(VERSION 2.6.3)
else()
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 2.8)
endif()
project(OpenCV)
@ -77,9 +77,9 @@ endif()
# Default: dynamic libraries
# ----------------------------------------------------------------------------
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()
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()
# ----------------------------------------------------------------------------
# Include debug info into debug libs?
@ -335,9 +335,9 @@ endif()
# Build tests:
# ===================================================
if(NOT IOS)
set(BUILD_TESTS ON CACHE BOOL "Build tests")
set(BUILD_TESTS ON CACHE BOOL "Build tests")
else()
set(BUILD_TESTS OFF CACHE BOOL "Build tests")
set(BUILD_TESTS OFF CACHE BOOL "Build tests")
endif()
set(BUILD_PERF_TESTS ON CACHE BOOL "Build performance tests")
@ -442,7 +442,7 @@ if(APPLE)
endif()
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()
set(WITH_TBB OFF CACHE BOOL "Include Intel TBB support")
@ -507,6 +507,17 @@ if(UNIX)
if(WITH_GTK)
CHECK_MODULE(gtk+-2.0 HAVE_GTK)
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()
set(HAVE_GTK FALSE)
set(HAVE_GTHREAD FALSE)
@ -575,7 +586,7 @@ if(UNIX)
set(HAVE_DC1394 FALSE)
endif()
if(NOT APPLE)
if(NOT APPLE)
CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
CHECK_FUNCTION_EXISTS(alloca HAVE_ALLOCA)
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
@ -608,8 +619,8 @@ if(UNIX)
endif()
endif()
if (UNIX OR WIN32)
if(NOT OPENCV_BUILD_3RDPARTY_LIBS)
message(STATUS "NOT OPENCV_BUILD_3RDPARTY_LIBS **************************************************")
if(NOT OPENCV_BUILD_3RDPARTY_LIBS)
message(STATUS "NOT OPENCV_BUILD_3RDPARTY_LIBS **************************************************")
include(FindZLIB)
if(WITH_PNG)
include(FindPNG)
@ -631,9 +642,9 @@ if (UNIX OR WIN32)
set(JASPER_FOUND FALSE)
endif()
if(WITH_JPEG)
include(FindJPEG)
include(FindJPEG)
else()
set(JPEG_FOUND FALSE)
set(JPEG_FOUND FALSE)
endif()
endif()
endif()
@ -1125,10 +1136,10 @@ if(WIN32)
endif()
endif()
if (WITH_OPENGL AND NOT HAVE_QT_OPENGL)
if(WITH_OPENGL AND NOT HAVE_QT_OPENGL)
find_package(OpenGL QUIET)
if (OPENGL_FOUND)
if(OPENGL_FOUND)
set(HAVE_OPENGL 1)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
include_directories(${OPENGL_INCLUDE_DIR})
@ -1725,7 +1736,8 @@ else()
endif()
else()
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()
@ -1773,11 +1785,11 @@ if(UNIX AND NOT APPLE)
endif()
endif()
elseif(APPLE)
if(NOT IOS)
status(" Video I/O:" WITH_QUICKTIME THEN QuickTime ELSE QTKit)
else()
status(" Video I/O: AVFoundation")
endif()
if(NOT IOS)
status(" Video I/O:" WITH_QUICKTIME THEN QuickTime ELSE QTKit)
else()
status(" Video I/O: AVFoundation")
endif()
elseif(WIN32)
status(" Video I/O:" HAVE_VIDEOINPUT THEN DirectShow ELSE NO)
endif()

View File

@ -98,7 +98,7 @@ struct CvCapture
virtual bool setProperty(int, double) { return 0; }
virtual bool grabFrame() { return true; }
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 ****************************/
@ -186,8 +186,13 @@ double cvGetModeWindow_GTK(const char* name);
double cvGetModeWindow_CARBON(const char* name);
double cvGetPropWindowAutoSize_W32(const char* name);
double cvGetPropWindowAutoSize_GTK(const char* name);
double cvGetRatioWindow_W32(const char* name);
double cvGetRatioWindow_GTK(const char* name);
double cvGetOpenGlProp_W32(const char* name);
double cvGetOpenGlProp_GTK(const char* name);
//for 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);
#elif defined WIN32 || defined _WIN32
return cvGetPropWindowAutoSize_W32(name);
#elif defined (HAVE_GTK)
return cvGetPropWindowAutoSize_GTK(name);
#else
return -1;
#endif
@ -120,6 +122,8 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
return cvGetRatioWindow_QT(name);
#elif defined WIN32 || defined _WIN32
return cvGetRatioWindow_W32(name);
#elif defined (HAVE_GTK)
return cvGetRatioWindow_GTK(name);
#else
return -1;
#endif
@ -130,6 +134,8 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
#if defined (HAVE_QT)
#elif defined WIN32 || defined _WIN32
return cvGetOpenGlProp_W32(name);
#elif defined (HAVE_GTK)
return cvGetOpenGlProp_GTK(name);
#else
return -1;
#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)
{
int key = waitKey(1);
if (key >= 0)
key = key & 0xff;
if (key == 27)
break;
@ -221,7 +223,13 @@ int main(int argc, const char* argv[])
double aspect = getWindowProperty("OpenGL Sample", WND_PROP_ASPECT_RATIO);
const double posStep = 0.1;
#ifdef _WIN32
const double mouseStep = 0.001;
#else
const double mouseStep = 0.000001;
#endif
const int mouseClamp = 300;
camera.setPerspectiveProjection(30.0 + fov / 100.0 * 40.0, aspect, 0.1, 1000.0);