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
4bbd02c0
Commit
4bbd02c0
authored
Jul 19, 2011
by
fattony
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added byte decoding for current image stream
parent
eaa9006c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
104 additions
and
34 deletions
+104
-34
QGCVideoMainWindow.cc
src/apps/qgcvideo/QGCVideoMainWindow.cc
+104
-34
No files found.
src/apps/qgcvideo/QGCVideoMainWindow.cc
View file @
4bbd02c0
...
...
@@ -35,7 +35,8 @@
#include "UDPLink.h"
#include <QDebug>
QByteArray
imageRecBuffer
=
QByteArray
(
376
*
240
,
255
);
QByteArray
imageRecBuffer1
=
QByteArray
(
376
*
240
,
255
);
QByteArray
imageRecBuffer2
=
QByteArray
(
376
*
240
,
255
);
static
int
part
=
0
;
QGCVideoMainWindow
::
QGCVideoMainWindow
(
QWidget
*
parent
)
:
...
...
@@ -91,71 +92,140 @@ void QGCVideoMainWindow::receiveBytes(LinkInterface* link, QByteArray data)
QString
header
(
"P5
\n
%1 %2
\n
%3
\n
"
);
header
=
header
.
arg
(
imgWidth
).
arg
(
imgHeight
).
arg
(
imgColors
);
switch
(
data
[
0
])
unsigned
char
i0
=
data
[
0
];
switch
(
i0
)
{
case
(
1
)
:
case
0x01
:
{
for
(
int
i
=
4
;
i
<
data
.
size
()
/
4
;
i
++
)
{
imageRecBuffer
[
i
]
=
data
[
i
*
4
];
part
=
part
|
1
;
imageRecBuffer
1
[
i
]
=
data
[
i
*
4
];
imageRecBuffer2
[
i
]
=
data
[
i
*
4
+
1
]
;
}
part
=
part
|
1
;
break
;
}
case
(
2
)
:
case
0x02
:
{
for
(
int
i
=
4
;
i
<
data
.
size
()
/
4
;
i
++
)
{
imageRecBuffer
[
i
+
45124
/
4
*
2
]
=
data
[
i
*
4
];
part
=
part
|
2
;
imageRecBuffer
1
[
i
+
45124
/
4
]
=
data
[
i
*
4
];
imageRecBuffer2
[
i
+
45124
/
4
]
=
data
[
i
*
4
+
1
]
;
}
part
=
part
|
2
;
break
;
}
// 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
++
)
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
:
{
imageRecBuffer
[
i
]
=
255
;
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
;
}
QByteArray
tmpImage
(
header
.
toStdString
().
c_str
(),
header
.
toStdString
().
size
());
tmpImage
.
append
(
imageRecBuffer
);
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
image
;
//QImage test(":images/patterns/lenna.jpg");
QImage
image1
;
QImage
image2
;
if
(
imageRecBuffer
.
isNull
())
if
(
imageRecBuffer
1
.
isNull
())
{
qDebug
()
<<
"could not convertToPGM()"
;
}
if
(
!
image
.
loadFromData
(
tmpImage
,
"PGM"
))
if
(
!
image
1
.
loadFromData
(
tmpImage1
,
"PGM"
))
{
qDebug
()
<<
"could not create extracted image"
;
qDebug
()
<<
"could not create extracted image1"
;
}
if
(
imageRecBuffer2
.
isNull
())
{
qDebug
()
<<
"could not convertToPGM()"
;
}
tmpImage
.
clear
();
ui
->
video1Widget
->
copyImage
(
test
);
ui
->
video2Widget
->
copyImage
(
image
);
//ui->video3Widget->copyImage(test);
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
;
imageRecBuffer
.
clear
();
imageRecBuffer1
.
clear
();
imageRecBuffer2
.
clear
();
}
unsigned
char
i0
=
data
[
0
];
index
.
append
(
QString
().
sprintf
(
"%02x "
,
i0
));
for
(
int
j
=
0
;
j
<
data
.
size
();
j
++
)
{
...
...
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