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
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
84 deletions
+104
-84
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
+90
-84
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
//Only for QT
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
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
void
stopLoop
();
...
...
modules/highgui/include/opencv2/highgui/highgui_c.h
View file @
2f4d3965
...
...
@@ -60,6 +60,8 @@ extern "C" {
//-----------New for QT
CVAPI
(
void
)
cvDisplayOverlay
(
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
(
void
)
cvStopLoop
();
//----------------------
...
...
modules/highgui/src/window.cpp
View file @
2f4d3965
...
...
@@ -160,6 +160,16 @@ int waitKey(int 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
*
value
,
int
count
,
TrackbarCallback
callback
,
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 @@
#include <QIODevice>
#include <QShortcut>
#include <QStatusBar>
#include <QVarLengthArray>
//Macro here
#define CV_MODE_NORMAL 0
...
...
@@ -109,6 +110,8 @@ public slots:
void
setPropWindow
(
QString
name
,
double
flags
);
double
getRatioWindow
(
QString
name
);
void
setRatioWindow
(
QString
name
,
double
arg2
);
void
saveWindowParameters
(
QString
name
);
void
loadWindowParameters
(
QString
name
);
};
class
CvTrackbar
:
public
QHBoxLayout
...
...
@@ -133,6 +136,7 @@ private:
CvTrackbarCallback
callback
;
QPointer
<
CvWindow
>
parent
;
int
*
dataSlider
;
};
class
CvWindow
:
public
QWidget
...
...
@@ -146,37 +150,39 @@ public:
void
updateImage
(
void
*
arr
);
void
displayInfo
(
QString
text
,
int
delayms
);
void
displayStatusBar
(
QString
text
,
int
delayms
);
void
readSettings
();
void
writeSettings
();
ViewPort
*
getView
();
QString
name
;
int
flags
;
QPointer
<
QBoxLayout
>
layout
;
QPointer
<
QStatusBar
>
myBar
;
QPointer
<
QLabel
>
myBar_msg
;
//QPointer<CustomLayout> layout;
protected
:
void
readSettings
();
void
writeSettings
();
//parameters (will be save/load)
QString
param_name
;
int
param_flags
;
protected
:
virtual
void
keyPressEvent
(
QKeyEvent
*
event
);
private
:
QPointer
<
ViewPort
>
myview
;
int
status
;
//0 normal, 1 fullscreen (YV)
QPointer
<
QShortcut
>
shortcut
_r_Zoom
;
QPointer
<
QShortcut
>
shortcut
_imgRegion
;
QPointer
<
QShortcut
>
shortcut
_Plus
;
QPointer
<
QShortcut
>
shortcut
_Minus
;
QPointer
<
QShortcut
>
shortcut
_Left
;
QPointer
<
QShortcut
>
shortcut_Right
;
QPointer
<
QShortcut
>
shortcut_Up
;
QPointer
<
QShortcut
>
shortcut_Down
;
QPointer
<
QShortcut
>
shortcutZ
;
QPointer
<
QShortcut
>
shortcutPlus
;
QPointer
<
QShortcut
>
shortcut
Minus
;
QPointer
<
QShortcut
>
shortcut
Left
;
QPointer
<
QShortcut
>
shortcut
Right
;
QPointer
<
QShortcut
>
shortcut
Up
;
QPointer
<
QShortcut
>
shortcut
Down
;
void
icvLoadTrackbars
(
QSettings
*
settings
)
;
void
icvSaveTrackbars
(
QSettings
*
settings
)
;
};
enum
type_mouse_event
{
mouse_up
=
0
,
mouse_down
=
1
,
mouse_dbclick
=
2
,
mouse_move
=
3
};
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
};
class
ViewPort
:
public
QGraphicsView
{
Q_OBJECT
...
...
@@ -195,20 +202,24 @@ public:
void
updateImage
(
void
*
arr
);
void
startDisplayInfo
(
QString
text
,
int
delayms
);
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
;
QImage
image2Draw_qt
;
int
mode_display
;
//opengl or native
int
nbChannelOriginImage
;
void
setRatio
(
int
flags
);
int
getRatio
();
public
slots
:
//reference:
//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
void
scaleView
(
qreal
scaleFactor
,
QPointF
center
,
bool
process1stParam
);
void
imgRegion
(
);
void
scaleView
(
qreal
scaleFactor
,
QPointF
center
);
void
moveView
(
QPointF
delta
);
void
resetZoom
();
void
ZoomIn
();
...
...
@@ -220,21 +231,14 @@ public slots:
void
resizeEvent
(
QResizeEvent
*
);
private
:
QPoint
deltaOffset
;
QPoint
computeOffset
();
QPoint
mouseCoordinate
;
QPointF
positionGrabbing
;
QRect
positionCorners
;
QTransform
matrixWorld
;
QTransform
matrixWorld_inv
;
float
ratioX
,
ratioY
;
CvMouseCallback
on_mouse
;
void
*
on_mouse_param
;
int
mode
;
int
keepRatio
;
bool
isSameSize
(
IplImage
*
img1
,
IplImage
*
img2
);
QSize
sizeHint
()
const
;
QPointer
<
CvWindow
>
centralWidget
;
...
...
@@ -270,64 +274,66 @@ private slots:
void
stopDisplayInfo
();
};
//here css for trackbar
/* from http://thesmithfam.org/blog/2010/03/10/fancy-qslider-stylesheet */
static
const
QString
str_Trackbar_css
=
QString
(
""
)
+
"QSlider::groove:horizontal {"
+
"border: 1px solid #bbb;"
+
"background: white;"
+
"height: 10px;"
+
"border-radius: 4px;"
+
"}"
+
"QSlider::sub-page:horizontal {"
+
"background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
+
"stop: 0 #66e, stop: 1 #bbf);"
+
"background: qlineargradient(x1: 0, y1: 0.2, x2: 1, y2: 1,"
+
"stop: 0 #bbf, stop: 1 #55f);"
+
"border: 1px solid #777;"
+
"height: 10px;"
+
"border-radius: 4px;"
+
"}"
+
"QSlider::add-page:horizontal {"
+
"background: #fff;"
+
"border: 1px solid #777;"
+
"height: 10px;"
+
"border-radius: 4px;"
+
"}"
+
"QSlider::handle:horizontal {"
+
"background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
+
"stop:0 #eee, stop:1 #ccc);"
+
"border: 1px solid #777;"
+
"width: 13px;"
+
"margin-top: -2px;"
+
"margin-bottom: -2px;"
+
"border-radius: 4px;"
+
"}"
+
"QSlider::handle:horizontal:hover {"
+
"background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
+
"stop:0 #fff, stop:1 #ddd);"
+
"border: 1px solid #444;"
+
"border-radius: 4px;"
+
"}"
+
"QSlider::sub-page:horizontal:disabled {"
+
"background: #bbb;"
+
"border-color: #999;"
+
"}"
+
"QSlider::add-page:horizontal:disabled {"
+
"background: #eee;"
+
"border-color: #999;"
+
"}"
+
"QSlider::handle:horizontal:disabled {"
+
"background: #eee;"
+
"border: 1px solid #aaa;"
+
"border-radius: 4px;"
+
"}"
;
+
"QSlider::groove:horizontal {"
+
"border: 1px solid #bbb;"
+
"background: white;"
+
"height: 10px;"
+
"border-radius: 4px;"
+
"}"
+
"QSlider::sub-page:horizontal {"
+
"background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
+
"stop: 0 #66e, stop: 1 #bbf);"
+
"background: qlineargradient(x1: 0, y1: 0.2, x2: 1, y2: 1,"
+
"stop: 0 #bbf, stop: 1 #55f);"
+
"border: 1px solid #777;"
+
"height: 10px;"
+
"border-radius: 4px;"
+
"}"
+
"QSlider::add-page:horizontal {"
+
"background: #fff;"
+
"border: 1px solid #777;"
+
"height: 10px;"
+
"border-radius: 4px;"
+
"}"
+
"QSlider::handle:horizontal {"
+
"background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
+
"stop:0 #eee, stop:1 #ccc);"
+
"border: 1px solid #777;"
+
"width: 13px;"
+
"margin-top: -2px;"
+
"margin-bottom: -2px;"
+
"border-radius: 4px;"
+
"}"
+
"QSlider::handle:horizontal:hover {"
+
"background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
+
"stop:0 #fff, stop:1 #ddd);"
+
"border: 1px solid #444;"
+
"border-radius: 4px;"
+
"}"
+
"QSlider::sub-page:horizontal:disabled {"
+
"background: #bbb;"
+
"border-color: #999;"
+
"}"
+
"QSlider::add-page:horizontal:disabled {"
+
"background: #eee;"
+
"border-color: #999;"
+
"}"
+
"QSlider::handle:horizontal:disabled {"
+
"background: #eee;"
+
"border: 1px solid #aaa;"
+
"border-radius: 4px;"
+
"}"
;
#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