Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
5856f869
Commit
5856f869
authored
Jul 21, 2017
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Camera parameters caching.
parent
62c380c6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
1 deletion
+61
-1
QGCCameraControl.cc
src/Camera/QGCCameraControl.cc
+58
-1
QGCCameraControl.h
src/Camera/QGCCameraControl.h
+3
-0
No files found.
src/Camera/QGCCameraControl.cc
View file @
5856f869
...
...
@@ -12,6 +12,7 @@
#include "QGCMapEngine.h"
#include <QDir>
#include <QStandardPaths>
#include <QDomDocument>
#include <QDomNodeList>
...
...
@@ -110,6 +111,7 @@ QGCCameraControl::QGCCameraControl(const mavlink_camera_information_t *info, Veh
,
_vehicle
(
vehicle
)
,
_compID
(
compID
)
,
_version
(
0
)
,
_cached
(
false
)
,
_storageFree
(
0
)
,
_storageTotal
(
0
)
,
_netManager
(
NULL
)
...
...
@@ -121,7 +123,7 @@ QGCCameraControl::QGCCameraControl(const mavlink_camera_information_t *info, Veh
const
char
*
url
=
(
const
char
*
)
info
->
cam_definition_uri
;
if
(
url
[
0
]
!=
0
)
{
//-- Process camera definition file
_h
ttpRequest
(
url
);
_h
andleDefinitionFile
(
url
);
}
else
{
_initWhenReady
();
}
...
...
@@ -432,6 +434,7 @@ QGCCameraControl::_setVideoStatus(VideoStatus status)
bool
QGCCameraControl
::
_loadCameraDefinitionFile
(
QByteArray
&
bytes
)
{
QByteArray
originalData
(
bytes
);
//-- Handle localization
if
(
!
_handleLocalization
(
bytes
))
{
return
false
;
...
...
@@ -456,6 +459,17 @@ QGCCameraControl::_loadCameraDefinitionFile(QByteArray& bytes)
qWarning
()
<<
"Unable to load camera parameters from camera definition"
;
return
false
;
}
//-- If this is new, cache it
if
(
!
_cached
)
{
QString
cacheFile
=
_cacheFile
();
qCDebug
(
CameraControlLog
)
<<
"Saving camera definition file"
<<
cacheFile
;
QFile
file
(
cacheFile
);
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
))
{
qWarning
()
<<
QString
(
"Could not save cache file %1. Error: %2"
).
arg
(
cacheFile
).
arg
(
file
.
errorString
());
}
else
{
file
.
write
(
originalData
);
}
}
return
true
;
}
...
...
@@ -1065,6 +1079,49 @@ QGCCameraControl::_loadNameValue(QDomNode option, const QString factName, FactMe
return
true
;
}
//-----------------------------------------------------------------------------
QString
QGCCameraControl
::
_cacheFile
()
{
QString
cacheFile
;
cacheFile
.
sprintf
(
"%s/%s_%s_%03d.xml"
,
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
parameterSavePath
().
toStdString
().
c_str
(),
_info
.
vendor_name
,
_info
.
model_name
,
_info
.
cam_definition_version
);
return
cacheFile
;
}
//-----------------------------------------------------------------------------
void
QGCCameraControl
::
_handleDefinitionFile
(
const
QString
&
url
)
{
//-- First check and see if we have it cached
QString
cacheFile
=
_cacheFile
();
QFile
xmlFile
(
cacheFile
);
if
(
!
xmlFile
.
exists
())
{
qCDebug
(
CameraControlLog
)
<<
"No camera definition file cached"
;
_httpRequest
(
url
);
return
;
}
if
(
!
xmlFile
.
open
(
QIODevice
::
ReadOnly
))
{
qWarning
()
<<
"Could not read cached camera definition file:"
<<
cacheFile
;
_httpRequest
(
url
);
return
;
}
QByteArray
bytes
=
xmlFile
.
readAll
();
QDomDocument
doc
;
if
(
!
doc
.
setContent
(
bytes
,
false
))
{
qWarning
()
<<
"Could not parse cached camera definition file:"
<<
cacheFile
;
_httpRequest
(
url
);
return
;
}
//-- We have it
qCDebug
(
CameraControlLog
)
<<
"Using cached camera definition file:"
<<
cacheFile
;
_cached
=
true
;
emit
dataReady
(
bytes
);
}
//-----------------------------------------------------------------------------
void
QGCCameraControl
::
_httpRequest
(
const
QString
&
url
)
...
...
src/Camera/QGCCameraControl.h
View file @
5856f869
...
...
@@ -183,15 +183,18 @@ private:
void
_updateActiveList
();
void
_updateRanges
(
Fact
*
pFact
);
void
_httpRequest
(
const
QString
&
url
);
void
_handleDefinitionFile
(
const
QString
&
url
);
QStringList
_loadExclusions
(
QDomNode
option
);
QString
_getParamName
(
const
char
*
param_id
);
QString
_cacheFile
();
protected:
Vehicle
*
_vehicle
;
int
_compID
;
mavlink_camera_information_t
_info
;
int
_version
;
bool
_cached
;
uint32_t
_storageFree
;
uint32_t
_storageTotal
;
QNetworkAccessManager
*
_netManager
;
...
...
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