Hi everyone,
I’m currently developing a GH component to control drone. So far, I succeed to send command to control the drone and get the values from the sensor.
However, I would like to get the video from the drone but I don’t have any idea how to display the video on grasshopper.
window form, special component, opencv ? Any suggestions and examples are very welcome.
I don’t know how to convert int recv to video
Find below the code I am using.
private void RunScript(bool Connect, ref object DroneVideo)
{
if(Connect == true && Sequence == 0){
telloVideo.CreateServer();
Sequence = Sequence + 1;
}
if(Connect == true && Sequence > 0){
DroneVideo = telloVideo.TelloVideoReturn();
}
if(Connect == false && Sequence > 0){
telloVideo.CloseServer();
}
Component.ExpireSolution(true);
}
//
TelloVideo telloVideo = new TelloVideo();
int Sequence = 0;
public class TelloVideo{
int recv;
byte[] data = new byte[3000];
string localIP = "192.168.10.2";
IPEndPoint endpoint;
Socket socketTelloVideo;
IPEndPoint sender;
public TelloVideo(){
}
public void CreateServer(){
endpoint = new IPEndPoint(IPAddress.Parse(localIP), 11111);
socketTelloVideo = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
socketTelloVideo.Bind(endpoint);
sender = new IPEndPoint(IPAddress.Any, 11111);
}
public int TelloVideoReturn(){
EndPoint tmpRemote = (EndPoint) sender;
recv = socketTelloVideo.ReceiveFrom(data, ref tmpRemote);
return recv;
}
public void CloseServer(){
socketTelloVideo.Close();
}
}
Best,
Amaury