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
e8aad754
Commit
e8aad754
authored
Jul 31, 2010
by
Yannick Verdie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bugs on Qt
parent
49f1a9c3
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
165 additions
and
18 deletions
+165
-18
highgui.hpp
modules/highgui/include/opencv2/highgui/highgui.hpp
+1
-0
highgui_c.h
modules/highgui/include/opencv2/highgui/highgui_c.h
+1
-1
window.cpp
modules/highgui/src/window.cpp
+6
-1
window_QT.cpp
modules/highgui/src/window_QT.cpp
+153
-16
window_QT.h
modules/highgui/src/window_QT.h
+4
-0
No files found.
modules/highgui/include/opencv2/highgui/highgui.hpp
View file @
e8aad754
...
@@ -66,6 +66,7 @@ CV_EXPORTS double getWindowProperty(const string& winname, int prop_id);//YV
...
@@ -66,6 +66,7 @@ CV_EXPORTS double getWindowProperty(const string& winname, int prop_id);//YV
//Only for Qt
//Only for Qt
//------------------------
//------------------------
CV_EXPORTS
CvFont
fontQt
(
const
string
&
nameFont
,
int
pointSize
CV_DEFAULT
(
-
1
),
Scalar
color
CV_DEFAULT
(
Scalar
::
all
(
0
)),
int
weight
CV_DEFAULT
(
CV_FONT_NORMAL
),
int
style
CV_DEFAULT
(
CV_STYLE_NORMAL
),
int
spacing
CV_DEFAULT
(
0
));
CV_EXPORTS
void
addText
(
const
Mat
&
img
,
const
char
*
text
,
Point
org
,
CvFont
font
);
CV_EXPORTS
void
addText
(
const
Mat
&
img
,
const
char
*
text
,
Point
org
,
CvFont
font
);
CV_EXPORTS
void
displayOverlay
(
const
string
&
winname
,
const
string
&
text
,
int
delayms
);
CV_EXPORTS
void
displayOverlay
(
const
string
&
winname
,
const
string
&
text
,
int
delayms
);
...
...
modules/highgui/include/opencv2/highgui/highgui_c.h
View file @
e8aad754
...
@@ -74,7 +74,7 @@ enum { CV_STYLE_NORMAL = 0,//QFont::StyleNormal,
...
@@ -74,7 +74,7 @@ enum { CV_STYLE_NORMAL = 0,//QFont::StyleNormal,
//for color cvScalar(blue_component, green_component, red\_component[, alpha_component])
//for color cvScalar(blue_component, green_component, red\_component[, alpha_component])
//and alpha= 0 <-> 0xFF (not transparent <-> transparent)
//and alpha= 0 <-> 0xFF (not transparent <-> transparent)
CVAPI
(
CvFont
)
cvFont
_
Qt
(
const
char
*
nameFont
,
int
pointSize
CV_DEFAULT
(
-
1
),
CvScalar
color
CV_DEFAULT
(
cvScalarAll
(
0
)),
int
weight
CV_DEFAULT
(
CV_FONT_NORMAL
),
int
style
CV_DEFAULT
(
CV_STYLE_NORMAL
),
int
spacing
CV_DEFAULT
(
0
));
CVAPI
(
CvFont
)
cvFontQt
(
const
char
*
nameFont
,
int
pointSize
CV_DEFAULT
(
-
1
),
CvScalar
color
CV_DEFAULT
(
cvScalarAll
(
0
)),
int
weight
CV_DEFAULT
(
CV_FONT_NORMAL
),
int
style
CV_DEFAULT
(
CV_STYLE_NORMAL
),
int
spacing
CV_DEFAULT
(
0
));
CVAPI
(
void
)
cvAddText
(
const
CvArr
*
img
,
const
char
*
text
,
CvPoint
org
,
CvFont
*
arg2
);
CVAPI
(
void
)
cvAddText
(
const
CvArr
*
img
,
const
char
*
text
,
CvPoint
org
,
CvFont
*
arg2
);
...
...
modules/highgui/src/window.cpp
View file @
e8aad754
...
@@ -190,10 +190,15 @@ int startWindowThread()
...
@@ -190,10 +190,15 @@ int startWindowThread()
#if defined (HAVE_QT)
#if defined (HAVE_QT)
CvFont
fontQt
(
const
string
&
nameFont
,
int
pointSize
,
Scalar
color
,
int
weight
,
int
style
,
int
spacing
)
{
return
cvFontQt
(
nameFont
.
c_str
(),
pointSize
,
color
,
weight
,
style
);
}
void
addText
(
const
Mat
&
img
,
const
string
&
text
,
Point
org
,
CvFont
font
)
void
addText
(
const
Mat
&
img
,
const
string
&
text
,
Point
org
,
CvFont
font
)
{
{
CvMat
_img
=
img
;
CvMat
_img
=
img
;
cvAddText
(
&
_img
,
text
.
c_str
(),
CvPoint
(
org
)
,
&
font
);
cvAddText
(
&
_img
,
text
.
c_str
(),
org
,
&
font
);
}
}
void
displayStatusBar
(
const
string
&
name
,
const
string
&
text
,
int
delayms
)
void
displayStatusBar
(
const
string
&
name
,
const
string
&
text
,
int
delayms
)
...
...
modules/highgui/src/window_QT.cpp
View file @
e8aad754
...
@@ -60,7 +60,7 @@ static CvWinProperties* global_control_panel = NULL;
...
@@ -60,7 +60,7 @@ static CvWinProperties* global_control_panel = NULL;
CV_IMPL
CvFont
cvFont
_
Qt
(
const
char
*
nameFont
,
int
pointSize
,
CvScalar
color
,
int
weight
,
int
style
,
int
spacing
)
CV_IMPL
CvFont
cvFontQt
(
const
char
*
nameFont
,
int
pointSize
,
CvScalar
color
,
int
weight
,
int
style
,
int
spacing
)
{
{
/*
/*
...
@@ -441,10 +441,10 @@ int icvInitSystem()
...
@@ -441,10 +441,10 @@ int icvInitSystem()
new
QApplication
(
parameterSystemC
,
parameterSystemV
);
new
QApplication
(
parameterSystemC
,
parameterSystemV
);
wasInitialized
=
1
;
wasInitialized
=
1
;
qDebug
()
<<
"init done"
;
//
qDebug()<<"init done";
#if defined( HAVE_QT_OPENGL )//OK tested !
#if defined( HAVE_QT_OPENGL )//OK tested !
qDebug
()
<<
"opengl support available"
;
//
qDebug()<<"opengl support available";
#endif
#endif
}
}
...
@@ -905,7 +905,7 @@ void GuiReceiver::showImage(QString name, void* arr)
...
@@ -905,7 +905,7 @@ void GuiReceiver::showImage(QString name, void* arr)
}
}
else
else
{
{
qDebug
()
<<
"Do nothing (Window or Image NULL)"
<<
endl
;
CV_Error
(
CV_StsNullPtr
,
"Do nothing (Window or Image NULL)"
)
;
}
}
}
}
...
@@ -982,6 +982,11 @@ void GuiReceiver::addButton(QString button_name, int button_type, int initial_bu
...
@@ -982,6 +982,11 @@ void GuiReceiver::addButton(QString button_name, int button_type, int initial_bu
//if (b)//button with this name already exist
//if (b)//button with this name already exist
// return;
// return;
if
(
global_control_panel
->
myLayout
->
count
()
==
0
)
//if that is the first button attach to the control panel, create a new button bar
{
b
=
CvWindow
::
createButtonbar
(
button_name
);
//the bar has the name of the first button attached to it
}
else
{
CvBar
*
lastbar
=
(
CvBar
*
)
global_control_panel
->
myLayout
->
itemAt
(
global_control_panel
->
myLayout
->
count
()
-
1
);
CvBar
*
lastbar
=
(
CvBar
*
)
global_control_panel
->
myLayout
->
itemAt
(
global_control_panel
->
myLayout
->
count
()
-
1
);
if
(
lastbar
->
type
==
type_CvTrackbar
)
//if last bar is a trackbar, create a new buttonbar, else, attach to the current bar
if
(
lastbar
->
type
==
type_CvTrackbar
)
//if last bar is a trackbar, create a new buttonbar, else, attach to the current bar
...
@@ -989,6 +994,8 @@ void GuiReceiver::addButton(QString button_name, int button_type, int initial_bu
...
@@ -989,6 +994,8 @@ void GuiReceiver::addButton(QString button_name, int button_type, int initial_bu
else
else
b
=
(
CvButtonbar
*
)
lastbar
;
b
=
(
CvButtonbar
*
)
lastbar
;
}
b
->
addButton
(
button_name
,(
CvButtonCallback
)
on_change
,
userdata
,
button_type
,
initial_button_state
);
b
->
addButton
(
button_name
,(
CvButtonCallback
)
on_change
,
userdata
,
button_type
,
initial_button_state
);
}
}
...
@@ -1713,6 +1720,8 @@ void CvWindow::readSettings()
...
@@ -1713,6 +1720,8 @@ void CvWindow::readSettings()
//param_name = settings.value("name_window",param_name).toString();
//param_name = settings.value("name_window",param_name).toString();
param_flags
=
settings
.
value
(
"mode_resize"
,
param_flags
).
toInt
();
param_flags
=
settings
.
value
(
"mode_resize"
,
param_flags
).
toInt
();
param_gui_mode
=
settings
.
value
(
"mode_gui"
,
param_gui_mode
).
toInt
();
param_gui_mode
=
settings
.
value
(
"mode_gui"
,
param_gui_mode
).
toInt
();
param_ratio_mode
=
settings
.
value
(
"mode_ratio"
,
param_ratio_mode
).
toInt
();
myview
->
param_keepRatio
=
settings
.
value
(
"view_aspectRatio"
,
myview
->
param_keepRatio
).
toInt
();
myview
->
param_keepRatio
=
settings
.
value
(
"view_aspectRatio"
,
myview
->
param_keepRatio
).
toInt
();
param_flags
=
settings
.
value
(
"mode_resize"
,
param_flags
).
toInt
();
param_flags
=
settings
.
value
(
"mode_resize"
,
param_flags
).
toInt
();
...
@@ -1732,6 +1741,12 @@ void CvWindow::readSettings()
...
@@ -1732,6 +1741,12 @@ void CvWindow::readSettings()
resize
(
size
);
resize
(
size
);
move
(
pos
);
move
(
pos
);
if
(
global_control_panel
)
{
icvLoadControlPanel
();
global_control_panel
->
move
(
settings
.
value
(
"posPanel"
,
global_control_panel
->
pos
()).
toPoint
());
}
}
}
void
CvWindow
::
writeSettings
()
void
CvWindow
::
writeSettings
()
...
@@ -1743,6 +1758,8 @@ void CvWindow::writeSettings()
...
@@ -1743,6 +1758,8 @@ void CvWindow::writeSettings()
settings
.
setValue
(
"size"
,
size
());
settings
.
setValue
(
"size"
,
size
());
settings
.
setValue
(
"mode_resize"
,
param_flags
);
settings
.
setValue
(
"mode_resize"
,
param_flags
);
settings
.
setValue
(
"mode_gui"
,
param_gui_mode
);
settings
.
setValue
(
"mode_gui"
,
param_gui_mode
);
settings
.
setValue
(
"param_ratio_mode"
,
param_ratio_mode
);
settings
.
setValue
(
"view_aspectRatio"
,
myview
->
param_keepRatio
);
settings
.
setValue
(
"view_aspectRatio"
,
myview
->
param_keepRatio
);
settings
.
setValue
(
"matrix_view.m11"
,
myview
->
param_matrixWorld
.
m11
());
settings
.
setValue
(
"matrix_view.m11"
,
myview
->
param_matrixWorld
.
m11
());
...
@@ -1756,8 +1773,134 @@ void CvWindow::writeSettings()
...
@@ -1756,8 +1773,134 @@ void CvWindow::writeSettings()
settings
.
setValue
(
"matrix_view.m33"
,
myview
->
param_matrixWorld
.
m33
());
settings
.
setValue
(
"matrix_view.m33"
,
myview
->
param_matrixWorld
.
m33
());
icvSaveTrackbars
(
&
settings
);
icvSaveTrackbars
(
&
settings
);
if
(
global_control_panel
)
{
icvSaveControlPanel
();
settings
.
setValue
(
"posPanel"
,
global_control_panel
->
pos
());
}
}
}
void
CvWindow
::
icvLoadControlPanel
()
{
QSettings
settings
(
"OpenCV2"
,
QFileInfo
(
QApplication
::
applicationFilePath
()).
fileName
()
+
" control panel"
);
int
size
=
settings
.
beginReadArray
(
"bars"
);
int
subsize
;
CvBar
*
t
;
if
(
size
==
global_control_panel
->
myLayout
->
layout
()
->
count
())
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
t
=
(
CvBar
*
)
global_control_panel
->
myLayout
->
layout
()
->
itemAt
(
i
);
settings
.
setArrayIndex
(
i
);
if
(
t
->
type
==
type_CvTrackbar
)
{
if
(
t
->
name_bar
==
settings
.
value
(
"namebar"
).
toString
())
{
((
CvTrackbar
*
)
t
)
->
slider
->
setValue
(
settings
.
value
(
"valuebar"
).
toInt
());
}
}
if
(
t
->
type
==
type_CvButtonbar
)
{
subsize
=
settings
.
beginReadArray
(
QString
(
"buttonbar"
)
+
i
);
if
(
subsize
==
((
CvButtonbar
*
)
t
)
->
layout
()
->
count
()
)
icvLoadButtonbar
((
CvButtonbar
*
)
t
,
&
settings
);
settings
.
endArray
();
}
}
settings
.
endArray
();
}
void
CvWindow
::
icvSaveControlPanel
()
{
QSettings
settings
(
"OpenCV2"
,
QFileInfo
(
QApplication
::
applicationFilePath
()).
fileName
()
+
" control panel"
);
settings
.
beginWriteArray
(
"bars"
);
CvBar
*
t
;
for
(
int
i
=
0
;
i
<
global_control_panel
->
myLayout
->
layout
()
->
count
();
++
i
)
{
t
=
(
CvBar
*
)
global_control_panel
->
myLayout
->
layout
()
->
itemAt
(
i
);
settings
.
setArrayIndex
(
i
);
if
(
t
->
type
==
type_CvTrackbar
)
{
settings
.
setValue
(
"namebar"
,
QString
(
t
->
name_bar
));
settings
.
setValue
(
"valuebar"
,((
CvTrackbar
*
)
t
)
->
slider
->
value
());
}
if
(
t
->
type
==
type_CvButtonbar
)
{
settings
.
beginWriteArray
(
QString
(
"buttonbar"
)
+
i
);
icvSaveButtonbar
((
CvButtonbar
*
)
t
,
&
settings
);
settings
.
endArray
();
}
}
settings
.
endArray
();
}
void
CvWindow
::
icvSaveButtonbar
(
CvButtonbar
*
b
,
QSettings
*
settings
)
{
QWidget
*
temp
;
QString
myclass
;
for
(
int
i
=
0
;
i
<
b
->
layout
()
->
count
();
++
i
)
{
settings
->
setArrayIndex
(
i
);
temp
=
(
QWidget
*
)
b
->
layout
()
->
itemAt
(
i
)
->
widget
();
myclass
=
QString
(
temp
->
metaObject
()
->
className
());
if
(
myclass
==
"CvPushButton"
)
{
CvPushButton
*
button
=
(
CvPushButton
*
)
temp
;
settings
->
setValue
(
"namebutton"
,
QString
(
button
->
text
())
);
settings
->
setValue
(
"valuebutton"
,
int
(
button
->
isChecked
()));
}
if
(
myclass
==
"CvCheckBox"
)
{
CvCheckBox
*
button
=
(
CvCheckBox
*
)
temp
;
settings
->
setValue
(
"namebutton"
,
QString
(
button
->
text
())
);
settings
->
setValue
(
"valuebutton"
,
int
(
button
->
isChecked
()));
}
if
(
myclass
==
"CvRadioButton"
)
{
CvRadioButton
*
button
=
(
CvRadioButton
*
)
temp
;
settings
->
setValue
(
"namebutton"
,
QString
(
button
->
text
())
);
settings
->
setValue
(
"valuebutton"
,
int
(
button
->
isChecked
()));
}
}
}
void
CvWindow
::
icvLoadButtonbar
(
CvButtonbar
*
b
,
QSettings
*
settings
)
{
QWidget
*
temp
;
QString
myclass
;
for
(
int
i
=
0
;
i
<
b
->
layout
()
->
count
();
++
i
)
{
settings
->
setArrayIndex
(
i
);
temp
=
(
QWidget
*
)
b
->
layout
()
->
itemAt
(
i
)
->
widget
();
myclass
=
QString
(
temp
->
metaObject
()
->
className
());
if
(
myclass
==
"CvPushButton"
)
{
CvPushButton
*
button
=
(
CvPushButton
*
)
temp
;
if
(
button
->
text
()
==
settings
->
value
(
"namebutton"
).
toString
())
button
->
setChecked
(
settings
->
value
(
"valuebutton"
).
toInt
());
}
if
(
myclass
==
"CvCheckBox"
)
{
CvCheckBox
*
button
=
(
CvCheckBox
*
)
temp
;
if
(
button
->
text
()
==
settings
->
value
(
"namebutton"
).
toString
())
button
->
setChecked
(
settings
->
value
(
"valuebutton"
).
toInt
());
}
if
(
myclass
==
"CvRadioButton"
)
{
CvRadioButton
*
button
=
(
CvRadioButton
*
)
temp
;
if
(
button
->
text
()
==
settings
->
value
(
"namebutton"
).
toString
())
button
->
setChecked
(
settings
->
value
(
"valuebutton"
).
toInt
());
}
}
}
void
CvWindow
::
icvLoadTrackbars
(
QSettings
*
settings
)
void
CvWindow
::
icvLoadTrackbars
(
QSettings
*
settings
)
{
{
int
size
=
settings
->
beginReadArray
(
"trackbars"
);
int
size
=
settings
->
beginReadArray
(
"trackbars"
);
...
@@ -1765,13 +1908,10 @@ void CvWindow::icvLoadTrackbars(QSettings *settings)
...
@@ -1765,13 +1908,10 @@ void CvWindow::icvLoadTrackbars(QSettings *settings)
//trackbar are saved in the same order, so no need to use icvFindTrackbarByName
//trackbar are saved in the same order, so no need to use icvFindTrackbarByName
int
start_index
=
0
;
if
(
myBarLayout
->
layout
()
->
count
()
==
size
)
//if not the same number, the window saved and loaded is not the same (nb trackbar not equal)
int
stop_index
=
myBarLayout
->
layout
()
->
count
()
;
for
(
int
i
=
0
;
i
<
size
;
++
i
)
if
(
stop_index
-
start_index
==
size
)
//if not the same number, the window saved and loaded is not the same (nb trackbar not equal)
for
(
int
i
=
start_index
;
i
<
size
+
start_index
;
++
i
)
{
{
settings
->
setArrayIndex
(
i
-
start_index
);
settings
->
setArrayIndex
(
i
);
t
=
(
CvTrackbar
*
)
myBarLayout
->
layout
()
->
itemAt
(
i
);
t
=
(
CvTrackbar
*
)
myBarLayout
->
layout
()
->
itemAt
(
i
);
if
(
t
->
name_bar
==
settings
->
value
(
"name"
).
toString
())
if
(
t
->
name_bar
==
settings
->
value
(
"name"
).
toString
())
...
@@ -1788,13 +1928,10 @@ void CvWindow::icvSaveTrackbars(QSettings *settings)
...
@@ -1788,13 +1928,10 @@ void CvWindow::icvSaveTrackbars(QSettings *settings)
settings
->
beginWriteArray
(
"trackbars"
);
settings
->
beginWriteArray
(
"trackbars"
);
int
start_index
=
0
;
for
(
int
i
=
0
;
i
<
myBarLayout
->
layout
()
->
count
();
++
i
)
{
for
(
int
i
=
start_index
;
i
<
myBarLayout
->
layout
()
->
count
()
-
1
;
++
i
)
{
t
=
(
CvTrackbar
*
)
myBarLayout
->
layout
()
->
itemAt
(
i
);
t
=
(
CvTrackbar
*
)
myBarLayout
->
layout
()
->
itemAt
(
i
);
settings
->
setArrayIndex
(
i
-
start_index
);
settings
->
setArrayIndex
(
i
);
settings
->
setValue
(
"name"
,
t
->
name_bar
);
settings
->
setValue
(
"name"
,
t
->
name_bar
);
//settings->setValue("name", t->getName());
settings
->
setValue
(
"value"
,
t
->
slider
->
value
());
settings
->
setValue
(
"value"
,
t
->
slider
->
value
());
}
}
settings
->
endArray
();
settings
->
endArray
();
...
@@ -1920,7 +2057,7 @@ void ViewPort::saveView()
...
@@ -1920,7 +2057,7 @@ void ViewPort::saveView()
return
;
return
;
}
}
qDebug
()
<<
"file extension not recognized, please choose between JPG, JPEG, BMP or PNG"
;
CV_Error
(
CV_StsNullPtr
,
"file extension not recognized, please choose between JPG, JPEG, BMP or PNG"
)
;
}
}
}
}
...
...
modules/highgui/src/window_QT.h
View file @
e8aad754
...
@@ -304,6 +304,10 @@ private:
...
@@ -304,6 +304,10 @@ private:
void
icvLoadTrackbars
(
QSettings
*
settings
);
void
icvLoadTrackbars
(
QSettings
*
settings
);
void
icvSaveTrackbars
(
QSettings
*
settings
);
void
icvSaveTrackbars
(
QSettings
*
settings
);
void
icvLoadControlPanel
();
void
icvSaveControlPanel
();
void
icvLoadButtonbar
(
CvButtonbar
*
t
,
QSettings
*
settings
);
void
icvSaveButtonbar
(
CvButtonbar
*
t
,
QSettings
*
settings
);
void
createShortcuts
();
void
createShortcuts
();
void
createActions
();
void
createActions
();
...
...
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