Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
eaa9006c
Commit
eaa9006c
authored
Jul 19, 2011
by
fattony
Browse files
increased buffersize to 2^16 bytes
parent
22d043ae
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/apps/qgcvideo/QGCVideoMainWindow.cc
View file @
eaa9006c
...
...
@@ -35,6 +35,9 @@
#include
"UDPLink.h"
#include
<QDebug>
QByteArray
imageRecBuffer
=
QByteArray
(
376
*
240
,
255
);
static
int
part
=
0
;
QGCVideoMainWindow
::
QGCVideoMainWindow
(
QWidget
*
parent
)
:
QMainWindow
(
parent
),
link
(
QHostAddress
::
Any
,
5555
),
...
...
@@ -70,29 +73,110 @@ 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
);
switch
(
data
[
0
])
{
case
(
1
):
{
for
(
int
i
=
4
;
i
<
data
.
size
()
/
4
;
i
++
)
{
imageRecBuffer
[
i
]
=
data
[
i
*
4
];
part
=
part
|
1
;
}
}
case
(
2
):
{
for
(
int
i
=
4
;
i
<
data
.
size
()
/
4
;
i
++
)
{
imageRecBuffer
[
i
+
45124
/
4
*
2
]
=
data
[
i
*
4
];
part
=
part
|
2
;
}
}
// case (3):
// {
// for (int i=4; i<data.size()/4; i++)
// {
// imageRecBuffer[i+45124/4*2] = data[i*4];
// part = part | 4;
// }
// }
}
if
(
part
==
3
)
{
for
(
int
i
=
45124
/
4
*
3
;
i
<
376
*
240
;
i
++
)
{
imageRecBuffer
[
i
]
=
255
;
}
QByteArray
tmpImage
(
header
.
toStdString
().
c_str
(),
header
.
toStdString
().
size
());
tmpImage
.
append
(
imageRecBuffer
);
// Load image into window
QImage
test
(
":images/patterns/lenna.jpg"
);
QImage
image
;
if
(
imageRecBuffer
.
isNull
())
{
qDebug
()
<<
"could not convertToPGM()"
;
}
if
(
!
image
.
loadFromData
(
tmpImage
,
"PGM"
))
{
qDebug
()
<<
"could not create extracted image"
;
}
tmpImage
.
clear
();
ui
->
video1Widget
->
copyImage
(
test
);
ui
->
video2Widget
->
copyImage
(
image
);
//ui->video3Widget->copyImage(test);
//ui->video4Widget->copyImage(test);
part
=
0
;
imageRecBuffer
.
clear
();
}
unsigned
char
i0
=
data
[
0
];
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 @
eaa9006c
...
...
@@ -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 @
eaa9006c
...
...
@@ -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
Supports
Markdown
0%
Try again
or
attach a new 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