Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
isae-group-drone
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RIBEIRO-LUSTOSA Leandro
isae-group-drone
Commits
f8180b05
Commit
f8180b05
authored
2 years ago
by
RIBEIRO-LUSTOSA Leandro
Browse files
Options
Downloads
Patches
Plain Diff
added UDP conexion between tello-vision and Simulink
parent
54778197
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tello-vision.cpp
+48
-0
48 additions, 0 deletions
tello-vision.cpp
tello.slx
+0
-0
0 additions, 0 deletions
tello.slx
with
48 additions
and
0 deletions
tello-vision.cpp
+
48
−
0
View file @
f8180b05
#include
"opencv2/opencv.hpp"
#include
<iostream>
#include
<stdlib.h>
#include
<unistd.h>
#include
<string.h>
#include
<sys/types.h>
#include
<sys/socket.h>
#include
<arpa/inet.h>
#include
<netinet/in.h>
#define PORT 11112
#define MAXLINE 1024
using
namespace
cv
;
int
main
(
int
argc
,
char
**
argv
)
{
int
sockfd
;
char
buffer
[
MAXLINE
];
char
hello
[]
=
"x:12;y:34;"
;
struct
sockaddr_in
servaddr
,
cliaddr
;
// Creating socket file descriptor
if
(
(
sockfd
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
))
<
0
)
{
perror
(
"socket creation failed"
);
exit
(
EXIT_FAILURE
);
}
memset
(
&
servaddr
,
0
,
sizeof
(
servaddr
));
memset
(
&
cliaddr
,
0
,
sizeof
(
cliaddr
));
// Filling server information
servaddr
.
sin_family
=
AF_INET
;
// IPv4
servaddr
.
sin_addr
.
s_addr
=
INADDR_ANY
;
servaddr
.
sin_port
=
htons
(
PORT
+
1
);
// Filling cliaddr information
cliaddr
.
sin_family
=
AF_INET
;
// IPv4
cliaddr
.
sin_addr
.
s_addr
=
INADDR_ANY
;
cliaddr
.
sin_port
=
htons
(
PORT
);
// Bind the socket with the server address
if
(
bind
(
sockfd
,
(
const
struct
sockaddr
*
)
&
servaddr
,
sizeof
(
servaddr
))
<
0
)
{
perror
(
"bind failed"
);
exit
(
EXIT_FAILURE
);
}
int
len
,
n
;
Mat
frame
;
VideoCapture
cap
(
"udp://127.0.0.1:11111"
,
CAP_FFMPEG
);
...
...
@@ -17,6 +61,10 @@ int main(int argc, char** argv) {
imshow
(
"tello vision"
,
frame
);
sendto
(
sockfd
,
(
const
char
*
)
hello
,
strlen
(
hello
),
0
,
(
const
struct
sockaddr
*
)
&
cliaddr
,
sizeof
(
cliaddr
));
if
(
frame
.
empty
()
)
break
;
// end of video stream
if
(
waitKey
(
10
)
==
27
)
break
;
// stop capturing by pressing ESC
...
...
This diff is collapsed.
Click to expand it.
tello.slx
+
0
−
0
View file @
f8180b05
No preview for this file type
This diff is collapsed.
Click to expand it.
Preview
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!
Save comment
Cancel
Please
register
or
sign in
to comment