From c6872100db7e29a92057aeff4e84ac48b5c137f2 Mon Sep 17 00:00:00 2001 From: Yannick Verdie Date: Mon, 7 Jun 2010 08:29:10 +0000 Subject: [PATCH] Start integrating QT GUI (GoC 2010) --- CMakeLists.txt | 66 +++++++++++++++---- modules/highgui/CMakeLists.txt | 61 ++++++++++++++--- .../include/opencv2/highgui/highgui_c.h | 11 ++++ modules/highgui/src/window.cpp | 2 +- 4 files changed, 119 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 19aea96f93..0ac6c55970 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -491,6 +491,36 @@ if(BUILD_NEW_PYTHON_SUPPORT) endif() + +#YV +############################### QT ################################ +set(HAVE_QT 0) +set(HAVE_QT_OPENGL 0) +set(AUTOSWITCH_QT 0)#uses to disable QT + +find_package(Qt4)# QUIET) +if (QT4_FOUND AND AUTOSWITCH_QT) + set(WITH_QT ON CACHE BOOL "Build with QT Backend support") + set(HAVE_QT 1) + add_definitions(-DHAVE_QT=1) + + if(UNIX) + if (APPLE) + set(WITH_CARBON 0) + message(STATUS "QT detected, so Carbon and Cocoa disabled") + else() + set(HAVE_GTK 0) + set(HAVE_GTHREAD 0) + message(STATUS "QT detected, so GTK and GThread disabled") + endif() + endif() + + #if (QT_QTOPENGL_FOUND) + # set(WITH_QT_OPENGL ON CACHE BOOL "add OpenGL extention to QT") + # set(HAVE_QT_OPENGL 1) + # add_definitions(-DOPENCV_GL=1) + #endif() +endif() ############################### TBB ################################ @@ -1105,22 +1135,34 @@ message(STATUS " Linker flags (Release): ${CMAKE_SHARED_LINKER_FLAGS} ${CM message(STATUS " Linker flags (Debug): ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}") endif() +#YV if(UNIX AND NOT APPLE) -message(STATUS "") -message(STATUS " GUI: ") -message(STATUS " GTK+ 2.x: ${HAVE_GTK}") -message(STATUS " GThread: ${HAVE_GTHREAD}") -message(STATUS "") + message(STATUS "") + message(STATUS " GUI: ") + if (HAVE_QT) + message(STATUS " QT 4.x: ${HAVE_QT}") + message(STATUS " QT OpenGL support: ${HAVE_QT_OPENGL}") + else() + message(STATUS " GTK+ 2.x: ${HAVE_GTK}") + message(STATUS " GThread: ${HAVE_GTHREAD}") + endif() + message(STATUS "") endif() if(APPLE) -message(STATUS "") -if(WITH_CARBON) -message(STATUS " GUI Back-end: Carbon") -else() -message(STATUS " GUI Back-end: Cocoa") -endif() -message(STATUS "") + message(STATUS "") + if (HAVE_QT) + message(STATUS " GUI: ") + message(STATUS " QT 4.x: ${HAVE_QT}") + message(STATUS " QT OpenGL support: ${HAVE_QT_OPENGL}") + else() + if(WITH_CARBON) + message(STATUS " GUI Back-end: Carbon") + else() + message(STATUS " GUI Back-end: Cocoa") + endif() + message(STATUS "") + endif() endif() message(STATUS " Image I/O: ") diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index 67c305dd7c..4b6de71e55 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -65,16 +65,46 @@ foreach(h ${lib_hdr_names}) list(APPEND highgui_ext_hdrs "${CMAKE_CURRENT_SOURCE_DIR}/include/opencv2/highgui/${h}") endforeach() +#YV if(WIN32) - set(highgui_srcs ${highgui_srcs} src/window_w32.cpp src/cap_vfw.cpp src/cap_cmu.cpp src/cap_w32.cpp src/cap_dshow.cpp) + + if (HAVE_QT) + + #SET(QT_USE_QTXML 1) + INCLUDE(${QT_USE_FILE}) + SET(_MOC_HEADERS src/window_QT.h) + QT4_WRAP_CPP(_MOC_OUTFILES ${_MOC_HEADERS}) + + set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} ${QT_LIBRARIES}) + set(highgui_srcs ${highgui_srcs} src/window_QT.cpp ${_MOC_OUTFILES}) + + else() + set(highgui_srcs ${highgui_srcs} src/window_w32.cpp) + endif() + + set(highgui_srcs ${highgui_srcs} src/cap_vfw.cpp src/cap_cmu.cpp src/cap_w32.cpp src/cap_dshow.cpp) if(HAVE_MIL) set(highgui_srcs ${highgui_srcs} src/cap_mil.cpp) endif() endif() if(UNIX) - if(HAVE_GTK) - set(highgui_srcs ${highgui_srcs} src/window_gtk.cpp) + + if (HAVE_QT) + + #SET(QT_USE_QTXML 1) + INCLUDE(${QT_USE_FILE}) + SET(_MOC_HEADERS src/window_QT.h) + QT4_WRAP_CPP(_MOC_OUTFILES ${_MOC_HEADERS}) + + set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} ${QT_LIBRARIES}) + set(highgui_srcs ${highgui_srcs} src/window_QT.cpp ${_MOC_OUTFILES}) + + else() + if(HAVE_GTK) + set(highgui_srcs ${highgui_srcs} src/window_gtk.cpp) + endif() + endif() if(HAVE_XINE) @@ -145,18 +175,33 @@ if(UNIX) endforeach() endif() +#YV if(APPLE) add_definitions(-DHAVE_QUICKTIME=1) if(NOT OPENCV_BUILD_3RDPARTY_LIBS) add_definitions(-DHAVE_IMAGEIO=1) endif() - if(WITH_CARBON) - add_definitions(-DHAVE_CARBON=1) - set(highgui_srcs ${highgui_srcs} src/window_carbon.cpp) + + if (HAVE_QT) + + #SET(QT_USE_QTXML 1) + INCLUDE(${QT_USE_FILE}) + SET(_MOC_HEADERS src/window_QT.h) + QT4_WRAP_CPP(_MOC_OUTFILES ${_MOC_HEADERS}) + + set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} ${QT_LIBRARIES}) + set(highgui_srcs ${highgui_srcs} src/window_QT.cpp ${_MOC_OUTFILES}) + else() - add_definitions(-DHAVE_COCOA=1) - set(highgui_srcs ${highgui_srcs} src/window_cocoa.mm) + if(WITH_CARBON) + add_definitions(-DHAVE_CARBON=1) + set(highgui_srcs ${highgui_srcs} src/window_carbon.cpp) + else() + add_definitions(-DHAVE_COCOA=1) + set(highgui_srcs ${highgui_srcs} src/window_cocoa.mm) + endif() endif() + if(WITH_QUICKTIME) set(highgui_srcs ${highgui_srcs} src/cap_qt.cpp) else() diff --git a/modules/highgui/include/opencv2/highgui/highgui_c.h b/modules/highgui/include/opencv2/highgui/highgui_c.h index c1445ab83a..0ca594b536 100644 --- a/modules/highgui/include/opencv2/highgui/highgui_c.h +++ b/modules/highgui/include/opencv2/highgui/highgui_c.h @@ -200,6 +200,17 @@ CVAPI(void) cvConvertImage( const CvArr* src, CvArr* dst, int flags CV_DEFAULT(0 /* wait for key event infinitely (delay<=0) or for "delay" milliseconds */ CVAPI(int) cvWaitKey(int delay CV_DEFAULT(0)); +//YV +#if defined (HAVE_QT) + //class CvWindow; + //class ViewPort; + struct CvTrackbar; + + CVAPI(int) cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char *argv[]); + CVAPI(void) cvStopLoop(); + CVAPI(void) cvInformation(const char* name, const char* text, int delay); + CvTrackbar* icvFindTrackbarByName( const char* name_trackbar, const char* name_window ); +#endif /****************************************************************************************\ * Working with Video Files and Cameras * diff --git a/modules/highgui/src/window.cpp b/modules/highgui/src/window.cpp index 8e78fe92ca..3e24aba363 100644 --- a/modules/highgui/src/window.cpp +++ b/modules/highgui/src/window.cpp @@ -171,7 +171,7 @@ int startWindowThread() #elif defined (HAVE_GTK) // see window_gtk.cpp #elif defined (HAVE_COCOA) // see window_carbon.cpp #elif defined (HAVE_CARBON) - +#elif defined (HAVE_QT) //YV see window_QT.cpp #else