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
2f4d3965
Commit
2f4d3965
authored
Jun 29, 2010
by
Yannick Verdie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New functions with QT GUI:
- save/load window parameters implemented !
parent
6f10d9ce
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
106 additions
and
86 deletions
+106
-86
highgui.hpp
modules/highgui/include/opencv2/highgui/highgui.hpp
+2
-0
highgui_c.h
modules/highgui/include/opencv2/highgui/highgui_c.h
+2
-0
window.cpp
modules/highgui/src/window.cpp
+10
-0
window_QT.cpp
modules/highgui/src/window_QT.cpp
+0
-0
window_QT.h
modules/highgui/src/window_QT.h
+92
-86
No files found.
modules/highgui/include/opencv2/highgui/highgui.hpp
View file @
2f4d3965
...
@@ -67,6 +67,8 @@ CV_EXPORTS double getWindowProperty(const string& winname, int prop_id);//YV
...
@@ -67,6 +67,8 @@ CV_EXPORTS double getWindowProperty(const string& winname, int prop_id);//YV
//Only for QT
//Only for QT
CV_EXPORTS
void
displayOverlay
(
const
string
&
winname
,
const
string
&
text
,
int
delayms
);
CV_EXPORTS
void
displayOverlay
(
const
string
&
winname
,
const
string
&
text
,
int
delayms
);
CV_EXPORTS
void
displayStatusBar
(
const
string
&
winname
,
const
string
&
text
,
int
delayms
);
CV_EXPORTS
void
displayStatusBar
(
const
string
&
winname
,
const
string
&
text
,
int
delayms
);
CV_EXPORTS
void
saveWindowParameters
(
const
string
&
windowName
);
CV_EXPORTS
void
loadWindowParameters
(
const
string
&
windowName
);
CV_EXPORTS
int
startLoop
(
int
(
*
pt2Func
)(
int
argc
,
char
*
argv
[]),
int
argc
,
char
*
argv
[]);
CV_EXPORTS
int
startLoop
(
int
(
*
pt2Func
)(
int
argc
,
char
*
argv
[]),
int
argc
,
char
*
argv
[]);
CV_EXPORTS
void
stopLoop
();
CV_EXPORTS
void
stopLoop
();
...
...
modules/highgui/include/opencv2/highgui/highgui_c.h
View file @
2f4d3965
...
@@ -60,6 +60,8 @@ extern "C" {
...
@@ -60,6 +60,8 @@ extern "C" {
//-----------New for QT
//-----------New for QT
CVAPI
(
void
)
cvDisplayOverlay
(
const
char
*
name
,
const
char
*
text
,
int
delayms
);
CVAPI
(
void
)
cvDisplayOverlay
(
const
char
*
name
,
const
char
*
text
,
int
delayms
);
CVAPI
(
void
)
cvDisplayStatusBar
(
const
char
*
name
,
const
char
*
text
,
int
delayms
);
CVAPI
(
void
)
cvDisplayStatusBar
(
const
char
*
name
,
const
char
*
text
,
int
delayms
);
CVAPI
(
void
)
cvSaveWindowParameters
(
const
char
*
name
);
CVAPI
(
void
)
cvLoadWindowParameters
(
const
char
*
name
);
CVAPI
(
int
)
cvStartLoop
(
int
(
*
pt2Func
)(
int
argc
,
char
*
argv
[]),
int
argc
,
char
*
argv
[]);
CVAPI
(
int
)
cvStartLoop
(
int
(
*
pt2Func
)(
int
argc
,
char
*
argv
[]),
int
argc
,
char
*
argv
[]);
CVAPI
(
void
)
cvStopLoop
();
CVAPI
(
void
)
cvStopLoop
();
//----------------------
//----------------------
...
...
modules/highgui/src/window.cpp
View file @
2f4d3965
...
@@ -160,6 +160,16 @@ int waitKey(int delay)
...
@@ -160,6 +160,16 @@ int waitKey(int delay)
return
cvWaitKey
(
delay
);
return
cvWaitKey
(
delay
);
}
}
void
saveWindowParameters
(
const
string
&
windowName
)
{
cvSaveWindowParameters
(
windowName
.
c_str
());
}
void
loadWindowParameters
(
const
string
&
windowName
)
{
cvLoadWindowParameters
(
windowName
.
c_str
());
}
int
createTrackbar
(
const
string
&
trackbarName
,
const
string
&
winName
,
int
createTrackbar
(
const
string
&
trackbarName
,
const
string
&
winName
,
int
*
value
,
int
count
,
TrackbarCallback
callback
,
int
*
value
,
int
count
,
TrackbarCallback
callback
,
void
*
userdata
)
void
*
userdata
)
...
...
modules/highgui/src/window_QT.cpp
View file @
2f4d3965
This diff is collapsed.
Click to expand it.
modules/highgui/src/window_QT.h
View file @
2f4d3965
...
@@ -69,6 +69,7 @@
...
@@ -69,6 +69,7 @@
#include <QIODevice>
#include <QIODevice>
#include <QShortcut>
#include <QShortcut>
#include <QStatusBar>
#include <QStatusBar>
#include <QVarLengthArray>
//Macro here
//Macro here
#define CV_MODE_NORMAL 0
#define CV_MODE_NORMAL 0
...
@@ -108,7 +109,9 @@ public slots:
...
@@ -108,7 +109,9 @@ public slots:
double
getPropWindow
(
QString
name
);
double
getPropWindow
(
QString
name
);
void
setPropWindow
(
QString
name
,
double
flags
);
void
setPropWindow
(
QString
name
,
double
flags
);
double
getRatioWindow
(
QString
name
);
double
getRatioWindow
(
QString
name
);
void
setRatioWindow
(
QString
name
,
double
arg2
);
void
setRatioWindow
(
QString
name
,
double
arg2
);
void
saveWindowParameters
(
QString
name
);
void
loadWindowParameters
(
QString
name
);
};
};
class
CvTrackbar
:
public
QHBoxLayout
class
CvTrackbar
:
public
QHBoxLayout
...
@@ -133,6 +136,7 @@ private:
...
@@ -133,6 +136,7 @@ private:
CvTrackbarCallback
callback
;
CvTrackbarCallback
callback
;
QPointer
<
CvWindow
>
parent
;
QPointer
<
CvWindow
>
parent
;
int
*
dataSlider
;
int
*
dataSlider
;
};
};
class
CvWindow
:
public
QWidget
class
CvWindow
:
public
QWidget
...
@@ -146,37 +150,39 @@ public:
...
@@ -146,37 +150,39 @@ public:
void
updateImage
(
void
*
arr
);
void
updateImage
(
void
*
arr
);
void
displayInfo
(
QString
text
,
int
delayms
);
void
displayInfo
(
QString
text
,
int
delayms
);
void
displayStatusBar
(
QString
text
,
int
delayms
);
void
displayStatusBar
(
QString
text
,
int
delayms
);
void
readSettings
();
void
writeSettings
();
ViewPort
*
getView
();
ViewPort
*
getView
();
QString
name
;
int
flags
;
QPointer
<
QBoxLayout
>
layout
;
QPointer
<
QBoxLayout
>
layout
;
QPointer
<
QStatusBar
>
myBar
;
QPointer
<
QStatusBar
>
myBar
;
QPointer
<
QLabel
>
myBar_msg
;
QPointer
<
QLabel
>
myBar_msg
;
//QPointer<CustomLayout> layout;
protected
:
//parameters (will be save/load)
void
readSettings
();
QString
param_name
;
void
writeSettings
();
int
param_flags
;
protected
:
virtual
void
keyPressEvent
(
QKeyEvent
*
event
);
virtual
void
keyPressEvent
(
QKeyEvent
*
event
);
private
:
private
:
QPointer
<
ViewPort
>
myview
;
QPointer
<
ViewPort
>
myview
;
QPointer
<
QShortcut
>
shortcutZ
;
int
status
;
//0 normal, 1 fullscreen (YV)
QPointer
<
QShortcut
>
shortcutPlus
;
QPointer
<
QShortcut
>
shortcut
_r_Zoom
;
QPointer
<
QShortcut
>
shortcut
Minus
;
QPointer
<
QShortcut
>
shortcut
_imgRegion
;
QPointer
<
QShortcut
>
shortcut
Left
;
QPointer
<
QShortcut
>
shortcut
_Plus
;
QPointer
<
QShortcut
>
shortcut
Right
;
QPointer
<
QShortcut
>
shortcut
_Minus
;
QPointer
<
QShortcut
>
shortcut
Up
;
QPointer
<
QShortcut
>
shortcut
_Left
;
QPointer
<
QShortcut
>
shortcut
Down
;
QPointer
<
QShortcut
>
shortcut_Right
;
QPointer
<
QShortcut
>
shortcut_Up
;
void
icvLoadTrackbars
(
QSettings
*
settings
)
;
QPointer
<
QShortcut
>
shortcut_Down
;
void
icvSaveTrackbars
(
QSettings
*
settings
)
;
};
};
enum
type_mouse_event
{
mouse_up
=
0
,
mouse_down
=
1
,
mouse_dbclick
=
2
,
mouse_move
=
3
};
enum
type_mouse_event
{
mouse_up
=
0
,
mouse_down
=
1
,
mouse_dbclick
=
2
,
mouse_move
=
3
};
static
const
int
tableMouseButtons
[][
3
]
=
{
static
const
int
tableMouseButtons
[][
3
]
=
{
...
@@ -186,6 +192,7 @@ static const int tableMouseButtons[][3]={
...
@@ -186,6 +192,7 @@ static const int tableMouseButtons[][3]={
{
CV_EVENT_MOUSEMOVE
,
CV_EVENT_MOUSEMOVE
,
CV_EVENT_MOUSEMOVE
}
//mouse_move
{
CV_EVENT_MOUSEMOVE
,
CV_EVENT_MOUSEMOVE
,
CV_EVENT_MOUSEMOVE
}
//mouse_move
};
};
class
ViewPort
:
public
QGraphicsView
class
ViewPort
:
public
QGraphicsView
{
{
Q_OBJECT
Q_OBJECT
...
@@ -195,20 +202,24 @@ public:
...
@@ -195,20 +202,24 @@ public:
void
updateImage
(
void
*
arr
);
void
updateImage
(
void
*
arr
);
void
startDisplayInfo
(
QString
text
,
int
delayms
);
void
startDisplayInfo
(
QString
text
,
int
delayms
);
void
setMouseCallBack
(
CvMouseCallback
m
,
void
*
param
);
void
setMouseCallBack
(
CvMouseCallback
m
,
void
*
param
);
int
getRatio
();
void
setRatio
(
int
arg
);
//parameters (will be save/load)
QTransform
param_matrixWorld
;
int
param_keepRatio
;
IplImage
*
image2Draw_ipl
;
IplImage
*
image2Draw_ipl
;
QImage
image2Draw_qt
;
QImage
image2Draw_qt
;
int
mode_display
;
//opengl or native
int
nbChannelOriginImage
;
int
nbChannelOriginImage
;
void
setRatio
(
int
flags
);
int
getRatio
();
public
slots
:
public
slots
:
//reference:
//reference:
//http://www.qtcentre.org/wiki/index.php?title=QGraphicsView:_Smooth_Panning_and_Zooming
//http://www.qtcentre.org/wiki/index.php?title=QGraphicsView:_Smooth_Panning_and_Zooming
//http://doc.qt.nokia.com/4.6/gestures-imagegestures-imagewidget-cpp.html
//http://doc.qt.nokia.com/4.6/gestures-imagegestures-imagewidget-cpp.html
void
scaleView
(
qreal
scaleFactor
,
QPointF
center
,
bool
process1stParam
);
void
scaleView
(
qreal
scaleFactor
,
QPointF
center
);
void
imgRegion
(
);
void
moveView
(
QPointF
delta
);
void
moveView
(
QPointF
delta
);
void
resetZoom
();
void
resetZoom
();
void
ZoomIn
();
void
ZoomIn
();
...
@@ -220,21 +231,14 @@ public slots:
...
@@ -220,21 +231,14 @@ public slots:
void
resizeEvent
(
QResizeEvent
*
);
void
resizeEvent
(
QResizeEvent
*
);
private
:
private
:
QPoint
deltaOffset
;
QPoint
computeOffset
();
QPoint
mouseCoordinate
;
QPoint
mouseCoordinate
;
QPointF
positionGrabbing
;
QPointF
positionGrabbing
;
QRect
positionCorners
;
QRect
positionCorners
;
QTransform
matrixWorld
;
QTransform
matrixWorld_inv
;
QTransform
matrixWorld_inv
;
float
ratioX
,
ratioY
;
float
ratioX
,
ratioY
;
CvMouseCallback
on_mouse
;
CvMouseCallback
on_mouse
;
void
*
on_mouse_param
;
void
*
on_mouse_param
;
int
mode
;
int
keepRatio
;
bool
isSameSize
(
IplImage
*
img1
,
IplImage
*
img2
);
bool
isSameSize
(
IplImage
*
img1
,
IplImage
*
img2
);
QSize
sizeHint
()
const
;
QSize
sizeHint
()
const
;
QPointer
<
CvWindow
>
centralWidget
;
QPointer
<
CvWindow
>
centralWidget
;
...
@@ -270,64 +274,66 @@ private slots:
...
@@ -270,64 +274,66 @@ private slots:
void
stopDisplayInfo
();
void
stopDisplayInfo
();
};
};
//here css for trackbar
//here css for trackbar
/* from http://thesmithfam.org/blog/2010/03/10/fancy-qslider-stylesheet */
/* from http://thesmithfam.org/blog/2010/03/10/fancy-qslider-stylesheet */
static
const
QString
str_Trackbar_css
=
QString
(
""
)
static
const
QString
str_Trackbar_css
=
QString
(
""
)
+
"QSlider::groove:horizontal {"
+
"QSlider::groove:horizontal {"
+
"border: 1px solid #bbb;"
+
"border: 1px solid #bbb;"
+
"background: white;"
+
"background: white;"
+
"height: 10px;"
+
"height: 10px;"
+
"border-radius: 4px;"
+
"border-radius: 4px;"
+
"}"
+
"}"
+
"QSlider::sub-page:horizontal {"
+
"QSlider::sub-page:horizontal {"
+
"background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
+
"background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
+
"stop: 0 #66e, stop: 1 #bbf);"
+
"stop: 0 #66e, stop: 1 #bbf);"
+
"background: qlineargradient(x1: 0, y1: 0.2, x2: 1, y2: 1,"
+
"background: qlineargradient(x1: 0, y1: 0.2, x2: 1, y2: 1,"
+
"stop: 0 #bbf, stop: 1 #55f);"
+
"stop: 0 #bbf, stop: 1 #55f);"
+
"border: 1px solid #777;"
+
"border: 1px solid #777;"
+
"height: 10px;"
+
"height: 10px;"
+
"border-radius: 4px;"
+
"border-radius: 4px;"
+
"}"
+
"}"
+
"QSlider::add-page:horizontal {"
+
"QSlider::add-page:horizontal {"
+
"background: #fff;"
+
"background: #fff;"
+
"border: 1px solid #777;"
+
"border: 1px solid #777;"
+
"height: 10px;"
+
"height: 10px;"
+
"border-radius: 4px;"
+
"border-radius: 4px;"
+
"}"
+
"}"
+
"QSlider::handle:horizontal {"
+
"QSlider::handle:horizontal {"
+
"background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
+
"background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
+
"stop:0 #eee, stop:1 #ccc);"
+
"stop:0 #eee, stop:1 #ccc);"
+
"border: 1px solid #777;"
+
"border: 1px solid #777;"
+
"width: 13px;"
+
"width: 13px;"
+
"margin-top: -2px;"
+
"margin-top: -2px;"
+
"margin-bottom: -2px;"
+
"margin-bottom: -2px;"
+
"border-radius: 4px;"
+
"border-radius: 4px;"
+
"}"
+
"}"
+
"QSlider::handle:horizontal:hover {"
+
"QSlider::handle:horizontal:hover {"
+
"background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
+
"background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
+
"stop:0 #fff, stop:1 #ddd);"
+
"stop:0 #fff, stop:1 #ddd);"
+
"border: 1px solid #444;"
+
"border: 1px solid #444;"
+
"border-radius: 4px;"
+
"border-radius: 4px;"
+
"}"
+
"}"
+
"QSlider::sub-page:horizontal:disabled {"
+
"QSlider::sub-page:horizontal:disabled {"
+
"background: #bbb;"
+
"background: #bbb;"
+
"border-color: #999;"
+
"border-color: #999;"
+
"}"
+
"}"
+
"QSlider::add-page:horizontal:disabled {"
+
"QSlider::add-page:horizontal:disabled {"
+
"background: #eee;"
+
"background: #eee;"
+
"border-color: #999;"
+
"border-color: #999;"
+
"}"
+
"}"
+
"QSlider::handle:horizontal:disabled {"
+
"QSlider::handle:horizontal:disabled {"
+
"background: #eee;"
+
"background: #eee;"
+
"border: 1px solid #aaa;"
+
"border: 1px solid #aaa;"
+
"border-radius: 4px;"
+
"border-radius: 4px;"
+
"}"
;
+
"}"
;
#endif
#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