Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
d6bbaea2
Commit
d6bbaea2
authored
Aug 02, 2010
by
Yannick Verdie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt imgRegion bug fixed
Qt compilation pb with OpenGL flags fixed
parent
5b7b6d91
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
486 additions
and
444 deletions
+486
-444
CMakeLists.txt
CMakeLists.txt
+2
-0
window_QT.cpp
modules/highgui/src/window_QT.cpp
+29
-8
window_QT.h
modules/highgui/src/window_QT.h
+455
-436
No files found.
CMakeLists.txt
View file @
d6bbaea2
...
@@ -525,6 +525,8 @@ if (WITH_QT)
...
@@ -525,6 +525,8 @@ if (WITH_QT)
if
(
QT_QTOPENGL_FOUND AND OPENGL_FOUND
)
if
(
QT_QTOPENGL_FOUND AND OPENGL_FOUND
)
set
(
HAVE_QT_OPENGL 1
)
set
(
HAVE_QT_OPENGL 1
)
add_definitions
(
-DHAVE_QT_OPENGL
)
add_definitions
(
-DHAVE_QT_OPENGL
)
link_directories
(
"
${
OPENGL_LIBRARIES
}
"
)
set
(
OPENCV_LINKER_LIBS
${
OPENCV_LINKER_LIBS
}
${
OPENGL_LIBRARIES
}
)
endif
()
endif
()
endif
()
endif
()
...
...
modules/highgui/src/window_QT.cpp
View file @
d6bbaea2
...
@@ -2241,7 +2241,7 @@ void ViewPort::controlImagePosition()
...
@@ -2241,7 +2241,7 @@ void ViewPort::controlImagePosition()
//save also the inv matrix
//save also the inv matrix
matrixWorld_inv
=
param_matrixWorld
.
inverted
();
matrixWorld_inv
=
param_matrixWorld
.
inverted
();
viewport
()
->
update
();
//
viewport()->update();
}
}
void
ViewPort
::
moveView
(
QPointF
delta
)
void
ViewPort
::
moveView
(
QPointF
delta
)
...
@@ -2409,9 +2409,12 @@ void ViewPort::icvmouseProcessing(QPointF pt, int cv_event, int flags)
...
@@ -2409,9 +2409,12 @@ void ViewPort::icvmouseProcessing(QPointF pt, int cv_event, int flags)
{
{
//to convert mouse coordinate
//to convert mouse coordinate
qreal
pfx
,
pfy
;
qreal
pfx
,
pfy
;
//qreal ratioX = float(image2Draw_qt.width())/image2Draw_qt_resized.width();
//qreal ratioY = float(image2Draw_qt.height())/image2Draw_qt_resized.height();
matrixWorld_inv
.
map
(
pt
.
x
(),
pt
.
y
(),
&
pfx
,
&
pfy
);
matrixWorld_inv
.
map
(
pt
.
x
(),
pt
.
y
(),
&
pfx
,
&
pfy
);
mouseCoordinate
.
rx
()
=
floor
(
pfx
);
mouseCoordinate
.
ry
()
=
floor
(
pfy
);
mouseCoordinate
.
rx
()
=
floor
(
pfx
/
ratioX
);
mouseCoordinate
.
ry
()
=
floor
(
pfy
/
ratioY
);
if
(
on_mouse
)
if
(
on_mouse
)
on_mouse
(
cv_event
,
mouseCoordinate
.
x
(),
mouseCoordinate
.
y
(),
flags
,
on_mouse_param
);
on_mouse
(
cv_event
,
mouseCoordinate
.
x
(),
mouseCoordinate
.
y
(),
flags
,
on_mouse_param
);
...
@@ -2430,7 +2433,6 @@ QSize ViewPort::sizeHint() const
...
@@ -2430,7 +2433,6 @@ QSize ViewPort::sizeHint() const
void
ViewPort
::
resizeEvent
(
QResizeEvent
*
event
)
void
ViewPort
::
resizeEvent
(
QResizeEvent
*
event
)
{
{
image2Draw_qt_resized
=
image2Draw_qt
.
scaled
(
this
->
width
(),
this
->
height
(),
Qt
::
IgnoreAspectRatio
,
Qt
::
SmoothTransformation
);
controlImagePosition
();
controlImagePosition
();
ratioX
=
width
()
/
float
(
image2Draw_ipl
->
width
);
ratioX
=
width
()
/
float
(
image2Draw_ipl
->
width
);
...
@@ -2493,8 +2495,14 @@ void ViewPort::paintEvent(QPaintEvent* event)
...
@@ -2493,8 +2495,14 @@ void ViewPort::paintEvent(QPaintEvent* event)
//in mode zoom/panning
//in mode zoom/panning
if
(
param_matrixWorld
.
m11
()
>
1
)
if
(
param_matrixWorld
.
m11
()
>
1
)
{
{
if
(
param_matrixWorld
.
m11
()
>=
threshold_zoom_img_region
)
if
(
param_matrixWorld
.
m11
()
>=
threshold_zoom_img_region
)
{
if
(
centralWidget
->
param_flags
==
CV_WINDOW_NORMAL
)
startDisplayInfo
(
"WARNING: The values displayed are the values of the resized image. If you want the values of the original image, use CV_WINDOW_AUTORESIZE"
,
1000
);
drawImgRegion
(
&
myPainter
);
drawImgRegion
(
&
myPainter
);
}
drawViewOverview
(
&
myPainter
);
drawViewOverview
(
&
myPainter
);
}
}
...
@@ -2512,7 +2520,8 @@ void ViewPort::paintEvent(QPaintEvent* event)
...
@@ -2512,7 +2520,8 @@ void ViewPort::paintEvent(QPaintEvent* event)
void
ViewPort
::
draw2D
(
QPainter
*
painter
)
void
ViewPort
::
draw2D
(
QPainter
*
painter
)
{
{
painter
->
drawImage
(
0
,
0
,
image2Draw_qt
.
scaled
(
this
->
width
(),
this
->
height
(),
Qt
::
IgnoreAspectRatio
,
Qt
::
SmoothTransformation
));
image2Draw_qt_resized
=
image2Draw_qt
.
scaled
(
this
->
width
(),
this
->
height
(),
Qt
::
IgnoreAspectRatio
,
Qt
::
SmoothTransformation
);
painter
->
drawImage
(
0
,
0
,
image2Draw_qt_resized
);
}
}
void
ViewPort
::
drawStatusBar
()
void
ViewPort
::
drawStatusBar
()
...
@@ -2544,6 +2553,7 @@ void ViewPort::drawStatusBar()
...
@@ -2544,6 +2553,7 @@ void ViewPort::drawStatusBar()
}
}
}
}
void
ViewPort
::
drawImgRegion
(
QPainter
*
painter
)
void
ViewPort
::
drawImgRegion
(
QPainter
*
painter
)
{
{
qreal
offsetX
=
param_matrixWorld
.
dx
()
/
param_matrixWorld
.
m11
();
qreal
offsetX
=
param_matrixWorld
.
dx
()
/
param_matrixWorld
.
m11
();
...
@@ -2573,22 +2583,33 @@ void ViewPort::drawImgRegion(QPainter *painter)
...
@@ -2573,22 +2583,33 @@ void ViewPort::drawImgRegion(QPainter *painter)
QPointF
point1
;
//sorry, I do not know how to name it
QPointF
point1
;
//sorry, I do not know how to name it
QPointF
point2
;
//idem
QPointF
point2
;
//idem
//qreal ratioX = float(image2Draw_qt.width())/image2Draw_qt_resized.width();
//qreal ratioY = float(image2Draw_qt.height())/image2Draw_qt_resized.height();
for
(
int
j
=-
1
;
j
<
view
.
height
()
/
param_matrixWorld
.
m11
();
j
++
)
for
(
int
j
=-
1
;
j
<
height
()
/
param_matrixWorld
.
m11
();
j
++
)
//-1 because display the pixels top rows left colums
for
(
int
i
=-
1
;
i
<
view
.
width
()
/
param_matrixWorld
.
m11
();
i
++
)
for
(
int
i
=-
1
;
i
<
width
()
/
param_matrixWorld
.
m11
();
i
++
)
//-1
{
{
point1
.
setX
((
i
+
offsetX
)
*
param_matrixWorld
.
m11
());
point1
.
setX
((
i
+
offsetX
)
*
param_matrixWorld
.
m11
());
point1
.
setY
((
j
+
offsetY
)
*
param_matrixWorld
.
m11
());
point1
.
setY
((
j
+
offsetY
)
*
param_matrixWorld
.
m11
());
matrixWorld_inv
.
map
(
point1
.
x
(),
point1
.
y
(),
&
point2
.
rx
(),
&
point2
.
ry
());
matrixWorld_inv
.
map
(
point1
.
x
(),
point1
.
y
(),
&
point2
.
rx
(),
&
point2
.
ry
());
point2
.
rx
()
=
(
long
)
(
point2
.
x
()
+
0.5
);
point2
.
ry
()
=
(
long
)
(
point2
.
y
()
+
0.5
);
if
(
point2
.
x
()
>=
0
&&
point2
.
y
()
>=
0
)
if
(
point2
.
x
()
>=
0
&&
point2
.
y
()
>=
0
)
rgbValue
=
image2Draw_qt
.
pixel
(
QPoint
(
point2
.
x
(),
point2
.
y
()));
rgbValue
=
image2Draw_qt
_resized
.
pixel
(
QPoint
(
point2
.
x
(),
point2
.
y
()));
else
else
rgbValue
=
qRgb
(
0
,
0
,
0
);
rgbValue
=
qRgb
(
0
,
0
,
0
);
if
(
nbChannelOriginImage
==
3
)
if
(
nbChannelOriginImage
==
3
)
{
{
//for debug
val
=
tr
(
"%1 %2"
).
arg
(
point2
.
x
()).
arg
(
point2
.
y
());
painter
->
setPen
(
QPen
(
Qt
::
black
,
1
));
painter
->
drawText
(
QRect
(
point1
.
x
(),
point1
.
y
(),
param_matrixWorld
.
m11
(),
param_matrixWorld
.
m11
()
/
2
),
Qt
::
AlignCenter
,
val
);
val
=
tr
(
"%1"
).
arg
(
qRed
(
rgbValue
));
val
=
tr
(
"%1"
).
arg
(
qRed
(
rgbValue
));
painter
->
setPen
(
QPen
(
Qt
::
red
,
1
));
painter
->
setPen
(
QPen
(
Qt
::
red
,
1
));
painter
->
drawText
(
QRect
(
point1
.
x
(),
point1
.
y
(),
param_matrixWorld
.
m11
(),
param_matrixWorld
.
m11
()
/
3
),
painter
->
drawText
(
QRect
(
point1
.
x
(),
point1
.
y
(),
param_matrixWorld
.
m11
(),
param_matrixWorld
.
m11
()
/
3
),
...
...
modules/highgui/src/window_QT.h
View file @
d6bbaea2
//IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
// By downloading, copying, installing or using the software you agree to this license.
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// If you do not agree to this license, do not download, install,
// copy or use the software.
// copy or use the software.
// License Agreement
// License Agreement
// For Open Source Computer Vision Library
// For Open Source Computer Vision Library
//Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
//Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
//Copyright (C) 2008-2010, Willow Garage Inc., all rights reserved.
//Copyright (C) 2008-2010, Willow Garage Inc., all rights reserved.
//Third party copyrights are property of their respective owners.
//Third party copyrights are property of their respective owners.
//Redistribution and use in source and binary forms, with or without modification,
//Redistribution and use in source and binary forms, with or without modification,
//are permitted provided that the following conditions are met:
//are permitted provided that the following conditions are met:
// * Redistribution's of source code must retain the above copyright notice,
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// this list of conditions and the following disclaimer.
// * Redistribution's in binary form must reproduce the above copyright notice,
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// and/or other materials provided with the distribution.
// * The name of the copyright holders may not be used to endorse or promote products
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
// derived from this software without specific prior written permission.
//This software is provided by the copyright holders and contributors "as is" and
//This software is provided by the copyright holders and contributors "as is" and
//any express or implied warranties, including, but not limited to, the implied
//any express or implied warranties, including, but not limited to, the implied
//warranties of merchantability and fitness for a particular purpose are disclaimed.
//warranties of merchantability and fitness for a particular purpose are disclaimed.
//In no event shall the Intel Corporation or contributors be liable for any direct,
//In no event shall the Intel Corporation or contributors be liable for any direct,
//indirect, incidental, special, exemplary, or consequential damages
//indirect, incidental, special, exemplary, or consequential damages
//(including, but not limited to, procurement of substitute goods or services;
//(including, but not limited to, procurement of substitute goods or services;
//loss of use, data, or profits; or business interruption) however caused
//loss of use, data, or profits; or business interruption) however caused
//and on any theory of liability, whether in contract, strict liability,
//and on any theory of liability, whether in contract, strict liability,
//or tort (including negligence or otherwise) arising in any way out of
//or tort (including negligence or otherwise) arising in any way out of
//the use of this software, even if advised of the possibility of such damage.
//the use of this software, even if advised of the possibility of such damage.
//--------------------Google Code 2010 -- Yannick Verdie--------------------//
//--------------------Google Code 2010 -- Yannick Verdie--------------------//
#ifndef __OPENCV_HIGHGUI_QT_H__
#ifndef __OPENCV_HIGHGUI_QT_H__
#define __OPENCV_HIGHGUI_QT_H__
#define __OPENCV_HIGHGUI_QT_H__
#include "precomp.hpp"
#include "precomp.hpp"
#if defined( HAVE_QT_OPENGL )
#if defined( HAVE_QT_OPENGL )
#include <QtOpenGL>
#include <QtOpenGL>
#include <QGLWidget>
#include <QGLWidget>
#endif
#endif
#include <QAbstractEventDispatcher>
#include <QAbstractEventDispatcher>
#include <QtGui/QApplication>
#include <QtGui/QApplication>
#include <QFile>
#include <QFile>
#include <QPushButton>
#include <QPushButton>
#include <QtGui/QGraphicsView>
#include <QtGui/QGraphicsView>
#include <QSizePolicy>
#include <QSizePolicy>
#include <QInputDialog>
#include <QInputDialog>
#include <QtGui/QBoxLayout>
#include <QtGui/QBoxLayout>
#include <QSettings>
#include <QSettings>
#include <qtimer.h>
#include <qtimer.h>
#include <QtConcurrentRun>
#include <QtConcurrentRun>
#include <QWaitCondition>
#include <QWaitCondition>
#include <QKeyEvent>
#include <QKeyEvent>
#include <QMetaObject>
#include <QMetaObject>
#include <QPointer>
#include <QPointer>
#include <QSlider>
#include <QSlider>
#include <QLabel>
#include <QLabel>
#include <QIODevice>
#include <QIODevice>
#include <QShortcut>
#include <QShortcut>
#include <QStatusBar>
#include <QStatusBar>
#include <QVarLengthArray>
#include <QVarLengthArray>
#include <QFileInfo>
#include <QFileInfo>
#include <QDate>
#include <QDate>
#include <QFileDialog>
#include <QFileDialog>
#include <QToolBar>
#include <QToolBar>
#include <QAction>
#include <QAction>
#include <QPushButton>
#include <QPushButton>
#include <QCheckBox>
#include <QCheckBox>
#include <QRadioButton>
#include <QRadioButton>
#include <QButtonGroup>
#include <QButtonGroup>
#include <QMenu>
#include <QMenu>
//start private enum
//start private enum
enum
{
CV_MODE_NORMAL
=
0
,
CV_MODE_OPENGL
=
1
};
enum
{
CV_MODE_NORMAL
=
0
,
CV_MODE_OPENGL
=
1
};
//we can change the keyboard shortcuts from here !
//we can change the keyboard shortcuts from here !
enum
{
shortcut_zoom_normal
=
Qt
::
CTRL
+
Qt
::
Key_Z
,
enum
{
shortcut_zoom_normal
=
Qt
::
CTRL
+
Qt
::
Key_Z
,
shortcut_zoom_imgRegion
=
Qt
::
CTRL
+
Qt
::
Key_X
,
shortcut_zoom_imgRegion
=
Qt
::
CTRL
+
Qt
::
Key_X
,
shortcut_save_img
=
Qt
::
CTRL
+
Qt
::
Key_S
,
shortcut_save_img
=
Qt
::
CTRL
+
Qt
::
Key_S
,
shortcut_properties_win
=
Qt
::
CTRL
+
Qt
::
Key_P
,
shortcut_properties_win
=
Qt
::
CTRL
+
Qt
::
Key_P
,
shortcut_zoom_in
=
Qt
::
CTRL
+
Qt
::
Key_Plus
,
//QKeySequence(QKeySequence::ZoomIn),
shortcut_zoom_in
=
Qt
::
CTRL
+
Qt
::
Key_Plus
,
//QKeySequence(QKeySequence::ZoomIn),
shortcut_zoom_out
=
Qt
::
CTRL
+
Qt
::
Key_Minus
,
//QKeySequence(QKeySequence::ZoomOut),
shortcut_zoom_out
=
Qt
::
CTRL
+
Qt
::
Key_Minus
,
//QKeySequence(QKeySequence::ZoomOut),
shortcut_panning_left
=
Qt
::
CTRL
+
Qt
::
Key_Left
,
shortcut_panning_left
=
Qt
::
CTRL
+
Qt
::
Key_Left
,
shortcut_panning_right
=
Qt
::
CTRL
+
Qt
::
Key_Right
,
shortcut_panning_right
=
Qt
::
CTRL
+
Qt
::
Key_Right
,
shortcut_panning_up
=
Qt
::
CTRL
+
Qt
::
Key_Up
,
shortcut_panning_up
=
Qt
::
CTRL
+
Qt
::
Key_Up
,
shortcut_panning_down
=
Qt
::
CTRL
+
Qt
::
Key_Down
shortcut_panning_down
=
Qt
::
CTRL
+
Qt
::
Key_Down
};
};
//end enum
//end enum
class
CvWindow
;
class
CvWindow
;
class
ViewPort
;
class
ViewPort
;
#if defined( HAVE_QT_OPENGL )
class
OpenGLWidget
;
class
GuiReceiver
:
public
QObject
#endif
{
Q_OBJECT
class
GuiReceiver
:
public
QObject
public
:
{
GuiReceiver
();
Q_OBJECT
~
GuiReceiver
();
int
start
();
public
:
void
isLastWindow
();
GuiReceiver
();
~
GuiReceiver
();
bool
_bTimeOut
;
int
start
();
QTimer
*
timer
;
void
isLastWindow
();
private
:
bool
_bTimeOut
;
int
nb_windows
;
QTimer
*
timer
;
public
slots
:
private
:
void
createWindow
(
QString
name
,
int
flags
=
0
);
int
nb_windows
;
void
destroyWindow
(
QString
name
);
void
destroyAllWindow
();
public
slots
:
void
addSlider
(
QString
trackbar_name
,
QString
window_name
,
void
*
value
,
int
count
,
void
*
on_change
);
void
createWindow
(
QString
name
,
int
flags
=
0
);
void
moveWindow
(
QString
name
,
int
x
,
int
y
);
void
destroyWindow
(
QString
name
);
void
resizeWindow
(
QString
name
,
int
width
,
int
height
);
void
destroyAllWindow
();
void
showImage
(
QString
name
,
void
*
arr
);
void
addSlider
(
QString
trackbar_name
,
QString
window_name
,
void
*
value
,
int
count
,
void
*
on_change
);
void
displayInfo
(
QString
name
,
QString
text
,
int
delayms
);
void
moveWindow
(
QString
name
,
int
x
,
int
y
);
void
displayStatusBar
(
QString
name
,
QString
text
,
int
delayms
);
void
resizeWindow
(
QString
name
,
int
width
,
int
height
);
void
timeOut
();
void
showImage
(
QString
name
,
void
*
arr
);
void
toggleFullScreen
(
QString
name
,
double
flags
);
void
displayInfo
(
QString
name
,
QString
text
,
int
delayms
);
double
isFullScreen
(
QString
name
);
void
displayStatusBar
(
QString
name
,
QString
text
,
int
delayms
);
double
getPropWindow
(
QString
name
);
void
timeOut
();
void
setPropWindow
(
QString
name
,
double
flags
);
void
toggleFullScreen
(
QString
name
,
double
flags
);
double
getRatioWindow
(
QString
name
);
double
isFullScreen
(
QString
name
);
void
setRatioWindow
(
QString
name
,
double
arg2
);
double
getPropWindow
(
QString
name
);
void
saveWindowParameters
(
QString
name
);
void
setPropWindow
(
QString
name
,
double
flags
);
void
loadWindowParameters
(
QString
name
);
double
getRatioWindow
(
QString
name
);
void
setOpenGLCallback
(
QString
window_name
,
void
*
callbackOpenGL
,
void
*
userdata
,
double
angle
,
double
zmin
,
double
zmax
);
void
setRatioWindow
(
QString
name
,
double
arg2
);
void
putText
(
void
*
arg1
,
QString
text
,
QPoint
org
,
void
*
font
);
void
saveWindowParameters
(
QString
name
);
void
addButton
(
QString
button_name
,
int
button_type
,
int
initial_button_state
,
void
*
on_change
,
void
*
userdata
);
void
loadWindowParameters
(
QString
name
);
};
void
setOpenGLCallback
(
QString
window_name
,
void
*
callbackOpenGL
,
void
*
userdata
,
double
angle
,
double
zmin
,
double
zmax
);
void
putText
(
void
*
arg1
,
QString
text
,
QPoint
org
,
void
*
font
);
enum
typeBar
{
type_CvTrackbar
=
0
,
type_CvButtonbar
=
1
};
void
addButton
(
QString
button_name
,
int
button_type
,
int
initial_button_state
,
void
*
on_change
,
void
*
userdata
);
class
CvBar
:
public
QHBoxLayout
};
{
public
:
enum
typeBar
{
type_CvTrackbar
=
0
,
type_CvButtonbar
=
1
};
typeBar
type
;
class
CvBar
:
public
QHBoxLayout
QString
name_bar
;
{
QPointer
<
QWidget
>
myparent
;
public
:
};
typeBar
type
;
QString
name_bar
;
QPointer
<
QWidget
>
myparent
;
class
CvButtonbar
:
public
CvBar
};
{
Q_OBJECT
public
:
class
CvButtonbar
:
public
CvBar
CvButtonbar
(
QWidget
*
arg
,
QString
bar_name
);
{
~
CvButtonbar
();
Q_OBJECT
void
addButton
(
QString
button_name
,
CvButtonCallback
call
,
void
*
userdata
,
int
button_type
,
int
initial_button_state
);
public
:
CvButtonbar
(
QWidget
*
arg
,
QString
bar_name
);
private
:
~
CvButtonbar
();
void
setLabel
();
void
addButton
(
QString
button_name
,
CvButtonCallback
call
,
void
*
userdata
,
int
button_type
,
int
initial_button_state
);
QPointer
<
QLabel
>
label
;
private
:
QPointer
<
QButtonGroup
>
group_button
;
void
setLabel
();
};
QPointer
<
QLabel
>
label
;
QPointer
<
QButtonGroup
>
group_button
;
class
CvPushButton
:
public
QPushButton
};
{
Q_OBJECT
public
:
class
CvPushButton
:
public
QPushButton
CvPushButton
(
CvButtonbar
*
par
,
QString
button_name
,
CvButtonCallback
call
,
void
*
userdata
);
{
Q_OBJECT
private
:
public
:
CvButtonbar
*
myparent
;
CvPushButton
(
CvButtonbar
*
par
,
QString
button_name
,
CvButtonCallback
call
,
void
*
userdata
);
QString
button_name
;
CvButtonCallback
callback
;
private
:
void
*
userdata
;
CvButtonbar
*
myparent
;
QString
button_name
;
private
slots
:
CvButtonCallback
callback
;
void
callCallBack
(
bool
);
void
*
userdata
;
};
private
slots
:
void
callCallBack
(
bool
);
};
class
CvCheckBox
:
public
QCheckBox
{
Q_OBJECT
public
:
class
CvCheckBox
:
public
QCheckBox
CvCheckBox
(
CvButtonbar
*
par
,
QString
button_name
,
CvButtonCallback
call
,
void
*
userdata
,
int
initial_button_state
);
{
Q_OBJECT
private
:
public
:
CvButtonbar
*
myparent
;
CvCheckBox
(
CvButtonbar
*
par
,
QString
button_name
,
CvButtonCallback
call
,
void
*
userdata
,
int
initial_button_state
);
QString
button_name
;
CvButtonCallback
callback
;
private
:
void
*
userdata
;
CvButtonbar
*
myparent
;
QString
button_name
;
private
slots
:
CvButtonCallback
callback
;
void
callCallBack
(
bool
);
void
*
userdata
;
};
private
slots
:
class
CvRadioButton
:
public
QRadioButton
void
callCallBack
(
bool
);
{
};
Q_OBJECT
public
:
class
CvRadioButton
:
public
QRadioButton
CvRadioButton
(
CvButtonbar
*
par
,
QString
button_name
,
CvButtonCallback
call
,
void
*
userdata
,
int
initial_button_state
);
{
Q_OBJECT
private
:
public
:
CvButtonbar
*
myparent
;
CvRadioButton
(
CvButtonbar
*
par
,
QString
button_name
,
CvButtonCallback
call
,
void
*
userdata
,
int
initial_button_state
);
QString
button_name
;
CvButtonCallback
callback
;
private
:
void
*
userdata
;
CvButtonbar
*
myparent
;
QString
button_name
;
private
slots
:
CvButtonCallback
callback
;
void
callCallBack
(
bool
);
void
*
userdata
;
};
private
slots
:
void
callCallBack
(
bool
);
};
class
CvTrackbar
:
public
CvBar
{
Q_OBJECT
public
:
class
CvTrackbar
:
public
CvBar
CvTrackbar
(
CvWindow
*
parent
,
QString
name
,
int
*
value
,
int
count
,
CvTrackbarCallback
on_change
=
NULL
);
{
~
CvTrackbar
();
Q_OBJECT
public
:
//QString trackbar_name;
CvTrackbar
(
CvWindow
*
parent
,
QString
name
,
int
*
value
,
int
count
,
CvTrackbarCallback
on_change
=
NULL
);
QPointer
<
QSlider
>
slider
;
~
CvTrackbar
();
private
slots
:
//QString trackbar_name;
void
createDialog
();
QPointer
<
QSlider
>
slider
;
void
update
(
int
myvalue
);
private
slots
:
private
:
void
createDialog
();
void
setLabel
(
int
myvalue
);
void
update
(
int
myvalue
);
QString
createLabel
();
QPointer
<
QPushButton
>
label
;
private
:
CvTrackbarCallback
callback
;
void
setLabel
(
int
myvalue
);
int
*
dataSlider
;
QString
createLabel
();
QPointer
<
QPushButton
>
label
;
};
CvTrackbarCallback
callback
;
int
*
dataSlider
;
class
CvWinProperties
:
public
QWidget
{
};
Q_OBJECT
public
:
class
CvWinProperties
:
public
QWidget
CvWinProperties
(
QString
name
,
QWidget
*
parent
);
{
~
CvWinProperties
();
Q_OBJECT
QPointer
<
QBoxLayout
>
myLayout
;
public
:
CvWinProperties
(
QString
name
,
QWidget
*
parent
);
private
:
~
CvWinProperties
();
void
closeEvent
(
QCloseEvent
*
e
);
QPointer
<
QBoxLayout
>
myLayout
;
void
showEvent
(
QShowEvent
*
event
)
;
void
hideEvent
(
QHideEvent
*
event
)
;
private
:
};
void
closeEvent
(
QCloseEvent
*
e
);
void
showEvent
(
QShowEvent
*
event
)
;
class
CvWindow
:
public
QWidget
void
hideEvent
(
QHideEvent
*
event
)
;
{
};
Q_OBJECT
public
:
CvWindow
(
QString
arg2
,
int
flag
=
CV_WINDOW_NORMAL
);
~
CvWindow
();
class
GlobalLayout
:
public
QBoxLayout
static
void
addSlider
(
CvWindow
*
w
,
QString
name
,
int
*
value
,
int
count
,
CvTrackbarCallback
on_change
CV_DEFAULT
(
NULL
));
{
void
setMouseCallBack
(
CvMouseCallback
m
,
void
*
param
);
Q_OBJECT
void
updateImage
(
void
*
arr
);
public
:
void
displayInfo
(
QString
text
,
int
delayms
);
GlobalLayout
(
QWidget
*
parent
)
:
QBoxLayout
(
QBoxLayout
::
TopToBottom
,
parent
){};
void
displayStatusBar
(
QString
text
,
int
delayms
);
bool
hasHeightForWidth
()
{
return
true
;};
void
readSettings
();
int
heightForWidth
(
int
w
)
{
qDebug
()
<<
"yopyopypp"
;
return
w
;};
void
writeSettings
();
};
void
setOpenGLCallback
(
CvOpenGLCallback
arg1
,
void
*
userdata
,
double
angle
,
double
zmin
,
double
zmax
);
void
hideTools
();
void
showTools
();
class
CvWindow
:
public
QWidget
static
CvButtonbar
*
createButtonbar
(
QString
bar_name
);
{
Q_OBJECT
public
:
CvWindow
(
QString
arg2
,
int
flag
=
CV_WINDOW_NORMAL
);
ViewPort
*
getView
();
~
CvWindow
();
static
void
addSlider
(
CvWindow
*
w
,
QString
name
,
int
*
value
,
int
count
,
CvTrackbarCallback
on_change
CV_DEFAULT
(
NULL
));
QPointer
<
QBoxLayout
>
myGlobalLayout
;
//All the widget (toolbar, view, LayoutBar, ...) are attached to it
void
setMouseCallBack
(
CvMouseCallback
m
,
void
*
param
);
QPointer
<
QBoxLayout
>
myBarLayout
;
void
updateImage
(
void
*
arr
);
QPointer
<
QStatusBar
>
myStatusBar
;
void
displayInfo
(
QString
text
,
int
delayms
);
QPointer
<
QToolBar
>
myToolBar
;
void
displayStatusBar
(
QString
text
,
int
delayms
);
QPointer
<
QLabel
>
myStatusBar_msg
;
void
readSettings
();
void
writeSettings
();
//parameters (will be save/load)
void
setOpenGLCallback
(
CvOpenGLCallback
arg1
,
void
*
userdata
,
double
angle
,
double
zmin
,
double
zmax
);
QString
param_name
;
void
hideTools
();
CvWinProperties
*
parameters_window
;
void
showTools
();
int
param_flags
;
static
CvButtonbar
*
createButtonbar
(
QString
bar_name
);
int
param_gui_mode
;
QSize
getAvailableSize
();
int
param_ratio_mode
;
QVector
<
QAction
*>
vect_QActions
;
ViewPort
*
getView
();
protected
:
QPointer
<
QBoxLayout
>
myGlobalLayout
;
//All the widget (toolbar, view, LayoutBar, ...) are attached to it
virtual
void
keyPressEvent
(
QKeyEvent
*
event
);
QPointer
<
QBoxLayout
>
myBarLayout
;
QPointer
<
QStatusBar
>
myStatusBar
;
private
:
QPointer
<
QToolBar
>
myToolBar
;
QPointer
<
ViewPort
>
myview
;
QPointer
<
QLabel
>
myStatusBar_msg
;
QVector
<
QShortcut
*>
vect_QShortcuts
;
//parameters (will be save/load)
void
icvLoadTrackbars
(
QSettings
*
settings
);
QString
param_name
;
void
icvSaveTrackbars
(
QSettings
*
settings
);
CvWinProperties
*
parameters_window
;
void
icvLoadControlPanel
();
int
param_flags
;
void
icvSaveControlPanel
();
int
param_gui_mode
;
void
icvLoadButtonbar
(
CvButtonbar
*
t
,
QSettings
*
settings
);
int
param_ratio_mode
;
void
icvSaveButtonbar
(
CvButtonbar
*
t
,
QSettings
*
settings
);
QVector
<
QAction
*>
vect_QActions
;
void
createShortcuts
();
void
createActions
();
protected
:
void
createToolBar
();
virtual
void
keyPressEvent
(
QKeyEvent
*
event
);
void
createView
(
int
display_mode
,
int
ratio_mode
);
void
createStatusBar
();
private
:
void
createGlobalLayout
();
QPointer
<
ViewPort
>
myview
;
void
createBarLayout
();
QVector
<
QShortcut
*>
vect_QShortcuts
;
CvWinProperties
*
createParameterWindow
();
void
icvLoadTrackbars
(
QSettings
*
settings
);
private
slots
:
void
icvSaveTrackbars
(
QSettings
*
settings
);
void
displayPropertiesWin
();
void
icvLoadControlPanel
();
};
void
icvSaveControlPanel
();
void
icvLoadButtonbar
(
CvButtonbar
*
t
,
QSettings
*
settings
);
void
icvSaveButtonbar
(
CvButtonbar
*
t
,
QSettings
*
settings
);
void
createShortcuts
();
enum
type_mouse_event
{
mouse_up
=
0
,
mouse_down
=
1
,
mouse_dbclick
=
2
,
mouse_move
=
3
};
void
createActions
();
void
createToolBar
();
static
const
int
tableMouseButtons
[][
3
]
=
{
void
createView
(
int
display_mode
,
int
ratio_mode
);
{
CV_EVENT_LBUTTONUP
,
CV_EVENT_RBUTTONUP
,
CV_EVENT_MBUTTONUP
},
//mouse_up
void
createStatusBar
();
{
CV_EVENT_LBUTTONDOWN
,
CV_EVENT_RBUTTONDOWN
,
CV_EVENT_MBUTTONDOWN
},
//mouse_down
void
createGlobalLayout
();
{
CV_EVENT_LBUTTONDBLCLK
,
CV_EVENT_RBUTTONDBLCLK
,
CV_EVENT_MBUTTONDBLCLK
},
//mouse_dbclick
void
createBarLayout
();
{
CV_EVENT_MOUSEMOVE
,
CV_EVENT_MOUSEMOVE
,
CV_EVENT_MOUSEMOVE
}
//mouse_move
CvWinProperties
*
createParameterWindow
();
};
private
slots
:
void
displayPropertiesWin
();
static
const
double
DEFAULT_ANGLE
=
45
.
0
;
};
static
const
double
DEFAULT_ZMIN
=
0
.
01
;
static
const
double
DEFAULT_ZMAX
=
1000
.
0
;
class
ViewPort
:
public
QGraphicsView
{
Q_OBJECT
enum
type_mouse_event
{
mouse_up
=
0
,
mouse_down
=
1
,
mouse_dbclick
=
2
,
mouse_move
=
3
};
public
:
ViewPort
(
CvWindow
*
centralWidget
,
int
mode
=
CV_MODE_NORMAL
,
int
keepRatio
=
CV_WINDOW_KEEPRATIO
);
static
const
int
tableMouseButtons
[][
3
]
=
{
~
ViewPort
();
{
CV_EVENT_LBUTTONUP
,
CV_EVENT_RBUTTONUP
,
CV_EVENT_MBUTTONUP
},
//mouse_up
void
updateImage
(
void
*
arr
);
{
CV_EVENT_LBUTTONDOWN
,
CV_EVENT_RBUTTONDOWN
,
CV_EVENT_MBUTTONDOWN
},
//mouse_down
void
startDisplayInfo
(
QString
text
,
int
delayms
);
{
CV_EVENT_LBUTTONDBLCLK
,
CV_EVENT_RBUTTONDBLCLK
,
CV_EVENT_MBUTTONDBLCLK
},
//mouse_dbclick
void
setMouseCallBack
(
CvMouseCallback
m
,
void
*
param
);
{
CV_EVENT_MOUSEMOVE
,
CV_EVENT_MOUSEMOVE
,
CV_EVENT_MOUSEMOVE
}
//mouse_move
void
setOpenGLCallback
(
CvOpenGLCallback
func
,
void
*
userdata
,
double
arg3
,
double
arg4
,
double
arg5
);
};
int
getRatio
();
void
setRatio
(
int
arg
);
static
const
double
DEFAULT_ANGLE
=
45
.
0
;
//parameters (will be save/load)
static
const
double
DEFAULT_ZMIN
=
0
.
01
;
QTransform
param_matrixWorld
;
static
const
double
DEFAULT_ZMAX
=
1000
.
0
;
class
ViewPort
:
public
QGraphicsView
int
param_keepRatio
;
{
Q_OBJECT
IplImage
*
image2Draw_ipl
;
public
:
QImage
image2Draw_qt
;
ViewPort
(
CvWindow
*
centralWidget
,
int
mode
=
CV_MODE_NORMAL
,
int
keepRatio
=
CV_WINDOW_KEEPRATIO
);
QImage
image2Draw_qt_resized
;
~
ViewPort
();
int
mode_display
;
//opengl or native
void
updateImage
(
void
*
arr
);
int
nbChannelOriginImage
;
void
startDisplayInfo
(
QString
text
,
int
delayms
);
void
setMouseCallBack
(
CvMouseCallback
m
,
void
*
param
);
public
slots
:
void
setOpenGLCallback
(
CvOpenGLCallback
func
,
void
*
userdata
,
double
arg3
,
double
arg4
,
double
arg5
);
//reference:
int
getRatio
();
//http://www.qtcentre.org/wiki/index.php?title=QGraphicsView:_Smooth_Panning_and_Zooming
void
setRatio
(
int
arg
);
//http://doc.qt.nokia.com/4.6/gestures-imagegestures-imagewidget-cpp.html
int
heightForWidth
(
int
w
);
// {qDebug()<<"yopyopypp";return w;};
void
scaleView
(
qreal
scaleFactor
,
QPointF
center
);
bool
hasHeightForWidth
(){
qDebug
()
<<
"ask"
;
return
true
;};
void
imgRegion
();
void
moveView
(
QPointF
delta
);
//parameters (will be save/load)
void
resetZoom
();
QTransform
param_matrixWorld
;
void
ZoomIn
();
void
ZoomOut
();
int
param_keepRatio
;
void
siftWindowOnLeft
();
void
siftWindowOnRight
();
IplImage
*
image2Draw_ipl
;
void
siftWindowOnUp
()
;
QImage
image2Draw_qt
;
void
siftWindowOnDown
();
QImage
image2Draw_qt_resized
;
void
resizeEvent
(
QResizeEvent
*
);
int
mode_display
;
//opengl or native
void
saveView
();
int
nbChannelOriginImage
;
void
contextMenuEvent
(
QContextMenuEvent
*
event
);
public
slots
:
//reference:
private
:
//http://www.qtcentre.org/wiki/index.php?title=QGraphicsView:_Smooth_Panning_and_Zooming
QPoint
mouseCoordinate
;
//http://doc.qt.nokia.com/4.6/gestures-imagegestures-imagewidget-cpp.html
QPointF
positionGrabbing
;
void
scaleView
(
qreal
scaleFactor
,
QPointF
center
);
QRect
positionCorners
;
void
imgRegion
();
QTransform
matrixWorld_inv
;
void
moveView
(
QPointF
delta
);
float
ratioX
,
ratioY
;
void
resetZoom
();
void
ZoomIn
();
//for mouse callback
void
ZoomOut
();
CvMouseCallback
on_mouse
;
void
siftWindowOnLeft
();
void
*
on_mouse_param
;
void
siftWindowOnRight
();
void
siftWindowOnUp
()
;
//for opengl callback
void
siftWindowOnDown
();
CvOpenGLCallback
on_openGL_draw3D
;
void
resizeEvent
(
QResizeEvent
*
);
void
*
on_openGL_param
;
void
saveView
();
void
contextMenuEvent
(
QContextMenuEvent
*
event
);
bool
isSameSize
(
IplImage
*
img1
,
IplImage
*
img2
);
QSize
sizeHint
()
const
;
QPointer
<
CvWindow
>
centralWidget
;
private
:
QPointer
<
QTimer
>
timerDisplay
;
QPoint
mouseCoordinate
;
bool
drawInfo
;
QPointF
positionGrabbing
;
QString
infoText
;
QRect
positionCorners
;
//QImage* image;
QTransform
matrixWorld_inv
;
float
ratioX
,
ratioY
;
void
paintEvent
(
QPaintEvent
*
paintEventInfo
);
void
wheelEvent
(
QWheelEvent
*
event
);
//for mouse callback
void
mouseMoveEvent
(
QMouseEvent
*
event
);
CvMouseCallback
on_mouse
;
void
mousePressEvent
(
QMouseEvent
*
event
);
void
*
on_mouse_param
;
void
mouseReleaseEvent
(
QMouseEvent
*
event
);
void
mouseDoubleClickEvent
(
QMouseEvent
*
event
);
//for opengl callback
void
drawInstructions
(
QPainter
*
painter
);
CvOpenGLCallback
on_openGL_draw3D
;
void
drawViewOverview
(
QPainter
*
painter
);
void
*
on_openGL_param
;
void
drawImgRegion
(
QPainter
*
painter
);
void
draw2D
(
QPainter
*
painter
);
bool
isSameSize
(
IplImage
*
img1
,
IplImage
*
img2
);
void
drawStatusBar
();
QSize
sizeHint
()
const
;
void
controlImagePosition
();
QPointer
<
CvWindow
>
centralWidget
;
void
icvmouseHandler
(
QMouseEvent
*
event
,
type_mouse_event
category
,
int
&
cv_event
,
int
&
flags
);
QPointer
<
QTimer
>
timerDisplay
;
void
icvmouseProcessing
(
QPointF
pt
,
int
cv_event
,
int
flags
);
bool
drawInfo
;
QString
infoText
;
#if defined( HAVE_QT_OPENGL )
QRectF
target
;
double
angle
;
//QImage* image;
double
zmin
;
double
zmax
;
void
paintEvent
(
QPaintEvent
*
paintEventInfo
);
void
unsetGL
();
void
wheelEvent
(
QWheelEvent
*
event
);
void
initGL
();
void
mouseMoveEvent
(
QMouseEvent
*
event
);
void
setGL
(
int
width
,
int
height
);
void
mousePressEvent
(
QMouseEvent
*
event
);
void
icvgluPerspective
(
GLdouble
fovy
,
GLdouble
aspect
,
GLdouble
zNear
,
GLdouble
zFar
);
void
mouseReleaseEvent
(
QMouseEvent
*
event
);
#endif
void
mouseDoubleClickEvent
(
QMouseEvent
*
event
);
void
drawInstructions
(
QPainter
*
painter
);
private
slots
:
void
drawViewOverview
(
QPainter
*
painter
);
void
stopDisplayInfo
();
void
drawImgRegion
(
QPainter
*
painter
);
};
void
draw2D
(
QPainter
*
painter
);
void
drawStatusBar
();
#endif
void
controlImagePosition
();
void
icvmouseHandler
(
QMouseEvent
*
event
,
type_mouse_event
category
,
int
&
cv_event
,
int
&
flags
);
void
icvmouseProcessing
(
QPointF
pt
,
int
cv_event
,
int
flags
);
#if defined( HAVE_QT_OPENGL )
QPointer
<
OpenGLWidget
>
myGL
;
double
angle
;
double
zmin
;
double
zmax
;
void
unsetGL
();
void
initGL
();
void
setGL
(
int
width
,
int
height
);
void
icvgluPerspective
(
GLdouble
fovy
,
GLdouble
aspect
,
GLdouble
zNear
,
GLdouble
zFar
);
#endif
private
slots
:
void
stopDisplayInfo
();
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment