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
ea251119
Commit
ea251119
authored
Jul 20, 2011
by
LM
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'videostreaming' of
https://github.com/fattonz/qgroundcontrol
into dev
parents
f75f4424
4bbd02c0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
172 additions
and
14 deletions
+172
-14
QGCVideoMainWindow.cc
src/apps/qgcvideo/QGCVideoMainWindow.cc
+167
-13
QGCVideoMainWindow.h
src/apps/qgcvideo/QGCVideoMainWindow.h
+4
-0
UDPLink.cc
src/comm/UDPLink.cc
+1
-1
No files found.
src/apps/qgcvideo/QGCVideoMainWindow.cc
View file @
ea251119
...
...
@@ -35,6 +35,10 @@
#include "UDPLink.h"
#include <QDebug>
QByteArray
imageRecBuffer1
=
QByteArray
(
376
*
240
,
255
);
QByteArray
imageRecBuffer2
=
QByteArray
(
376
*
240
,
255
);
static
int
part
=
0
;
QGCVideoMainWindow
::
QGCVideoMainWindow
(
QWidget
*
parent
)
:
QMainWindow
(
parent
),
link
(
QHostAddress
::
Any
,
5555
),
...
...
@@ -70,29 +74,179 @@ void QGCVideoMainWindow::receiveBytes(LinkInterface* link, QByteArray data)
// Output bytes and load Lenna!
QString
bytes
;
QString
index
;
QString
ascii
;
for
(
int
i
=
0
;
i
<
data
.
size
();
i
++
)
{
unsigned
char
v
=
data
[
i
];
// TODO FIXME Fabian
// RAW hardcoded to 22x22
int
imgWidth
=
376
;
int
imgHeight
=
240
;
int
imgColors
=
255
;
//const int headerSize = 15;
// Construct PGM header
QString
header
(
"P5
\n
%1 %2
\n
%3
\n
"
);
header
=
header
.
arg
(
imgWidth
).
arg
(
imgHeight
).
arg
(
imgColors
);
unsigned
char
i0
=
data
[
0
];
switch
(
i0
)
{
case
0x01
:
{
for
(
int
i
=
4
;
i
<
data
.
size
()
/
4
;
i
++
)
{
imageRecBuffer1
[
i
]
=
data
[
i
*
4
];
imageRecBuffer2
[
i
]
=
data
[
i
*
4
+
1
];
}
part
=
part
|
1
;
break
;
}
case
0x02
:
{
for
(
int
i
=
4
;
i
<
data
.
size
()
/
4
;
i
++
)
{
imageRecBuffer1
[
i
+
45124
/
4
]
=
data
[
i
*
4
];
imageRecBuffer2
[
i
+
45124
/
4
]
=
data
[
i
*
4
+
1
];
}
part
=
part
|
2
;
break
;
}
case
0x03
:
{
for
(
int
i
=
4
;
i
<
data
.
size
()
/
4
;
i
++
)
{
imageRecBuffer1
[
i
+
45124
/
4
*
2
]
=
data
[
i
*
4
];
imageRecBuffer2
[
i
+
45124
/
4
*
2
]
=
data
[
i
*
4
+
1
];
}
part
=
part
|
4
;
break
;
}
case
0x04
:
{
for
(
int
i
=
4
;
i
<
data
.
size
()
/
4
;
i
++
)
{
imageRecBuffer1
[
i
+
45124
/
4
*
3
]
=
data
[
i
*
4
];
imageRecBuffer2
[
i
+
45124
/
4
*
3
]
=
data
[
i
*
4
+
1
];
}
part
=
part
|
8
;
break
;
}
case
0x05
:
{
for
(
int
i
=
4
;
i
<
data
.
size
()
/
4
;
i
++
)
{
imageRecBuffer1
[
i
+
45124
/
4
*
4
]
=
data
[
i
*
4
];
imageRecBuffer2
[
i
+
45124
/
4
*
4
]
=
data
[
i
*
4
+
1
];
}
part
=
part
|
16
;
break
;
}
case
0x06
:
{
for
(
int
i
=
4
;
i
<
data
.
size
()
/
4
;
i
++
)
{
imageRecBuffer1
[
i
+
45124
/
4
*
5
]
=
data
[
i
*
4
];
imageRecBuffer2
[
i
+
45124
/
4
*
5
]
=
data
[
i
*
4
+
1
];
}
part
=
part
|
32
;
break
;
}
case
0x07
:
{
for
(
int
i
=
4
;
i
<
data
.
size
()
/
4
;
i
++
)
{
imageRecBuffer1
[
i
+
45124
/
4
*
6
]
=
data
[
i
*
4
];
imageRecBuffer2
[
i
+
45124
/
4
*
6
]
=
data
[
i
*
4
+
1
];
}
part
=
part
|
64
;
break
;
}
case
0x08
:
{
for
(
int
i
=
4
;
i
<
data
.
size
()
/
4
;
i
++
)
{
imageRecBuffer1
[
i
+
45124
/
4
*
7
]
=
data
[
i
*
4
];
imageRecBuffer2
[
i
+
45124
/
4
*
7
]
=
data
[
i
*
4
+
1
];
}
part
=
part
|
128
;
break
;
}
}
if
(
part
==
255
)
{
QByteArray
tmpImage1
(
header
.
toStdString
().
c_str
(),
header
.
toStdString
().
size
());
tmpImage1
.
append
(
imageRecBuffer1
);
QByteArray
tmpImage2
(
header
.
toStdString
().
c_str
(),
header
.
toStdString
().
size
());
tmpImage2
.
append
(
imageRecBuffer2
);
// Load image into window
//QImage test(":images/patterns/lenna.jpg");
QImage
image1
;
QImage
image2
;
if
(
imageRecBuffer1
.
isNull
())
{
qDebug
()
<<
"could not convertToPGM()"
;
}
if
(
!
image1
.
loadFromData
(
tmpImage1
,
"PGM"
))
{
qDebug
()
<<
"could not create extracted image1"
;
}
if
(
imageRecBuffer2
.
isNull
())
{
qDebug
()
<<
"could not convertToPGM()"
;
}
if
(
!
image2
.
loadFromData
(
tmpImage2
,
"PGM"
))
{
qDebug
()
<<
"could not create extracted image2"
;
}
tmpImage1
.
clear
();
tmpImage2
.
clear
();
//ui->video1Widget->copyImage(test);
ui
->
video2Widget
->
copyImage
(
image1
);
ui
->
video3Widget
->
copyImage
(
image2
);
//ui->video4Widget->copyImage(test);
part
=
0
;
imageRecBuffer1
.
clear
();
imageRecBuffer2
.
clear
();
}
index
.
append
(
QString
().
sprintf
(
"%02x "
,
i0
));
for
(
int
j
=
0
;
j
<
data
.
size
();
j
++
)
{
unsigned
char
v
=
data
[
j
];
bytes
.
append
(
QString
().
sprintf
(
"%02x "
,
v
));
if
(
data
.
at
(
i
)
>
31
&&
data
.
at
(
i
)
<
127
)
if
(
data
.
at
(
j
)
>
31
&&
data
.
at
(
j
)
<
127
)
{
ascii
.
append
(
data
.
at
(
i
));
ascii
.
append
(
data
.
at
(
j
));
}
else
{
ascii
.
append
(
219
);
}
}
qDebug
()
<<
"Received"
<<
data
.
size
()
<<
"bytes"
;
qDebug
()
<<
bytes
;
qDebug
()
<<
"ASCII:"
<<
ascii
;
qDebug
()
<<
"Received"
<<
data
.
size
()
<<
"bytes"
;
qDebug
()
<<
"index: "
<<
index
;
//qDebug() << bytes;
//qDebug() << "ASCII:" << ascii;
// Load image into window
QImage
test
(
":images/patterns/lenna.jpg"
);
ui
->
video1Widget
->
copyImage
(
test
);
ui
->
video2Widget
->
copyImage
(
test
);
ui
->
video3Widget
->
copyImage
(
test
);
ui
->
video4Widget
->
copyImage
(
test
);
}
src/apps/qgcvideo/QGCVideoMainWindow.h
View file @
ea251119
...
...
@@ -35,6 +35,8 @@
#include <QMainWindow>
#include "UDPLink.h"
namespace
Ui
{
class
QGCVideoMainWindow
;
}
...
...
@@ -47,7 +49,9 @@ public:
explicit
QGCVideoMainWindow
(
QWidget
*
parent
=
0
);
~
QGCVideoMainWindow
();
public
slots
:
void
receiveBytes
(
LinkInterface
*
link
,
QByteArray
data
);
protected:
...
...
src/comm/UDPLink.cc
View file @
ea251119
...
...
@@ -182,7 +182,7 @@ void UDPLink::writeBytes(const char* data, qint64 size)
**/
void
UDPLink
::
readBytes
()
{
const
qint64
maxLength
=
2048
;
const
qint64
maxLength
=
65536
;
char
data
[
maxLength
];
QHostAddress
sender
;
quint16
senderPort
;
...
...
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