element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Sensors
  • Technologies
  • More
Sensors
Blog Controlling google earth using 3D Gesture MGC3130 Hillstar Dev Kit Part - 2
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Sensors to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ss_shrenik
  • Date Created: 14 Aug 2014 6:13 PM Date Created
  • Views 419 views
  • Likes 0 likes
  • Comments 0 comments
  • 3d_gesture
  • 3d_gesture_technology
Related
Recommended

Controlling google earth using 3D Gesture MGC3130 Hillstar Dev Kit Part - 2

ss_shrenik
ss_shrenik
14 Aug 2014

Hi,

 

     Even after I am done with my basic demo long back, I am writing this blog post which I wanted to write before only. Anyway, in this blog post I am giving insight about how did I implement MGC3130 side software. In fact, what I did is written on top of SDK demo code that can be found with SDK called "console". This demo code gives all gesture related data on console. E.g. x,y,z co-ordinates, circle gesture detection, left-right,top-bottom vice versa. Means, In order to use the gesture output to control Google earth, I could use the same console data. But here the main question was how can I control Google earth, obviously using Google API's. I preferred to use Google's Python APIs for same. Now, In this case, I need to send these data whatever I get on console to the program which will control Google earth using Python APIs. Now there can be two options to send this data from C program to Python is to use socket programming or using shared memory. I preferred socket programming and thought to transfer this data on TCP socket over local IP to Python program. So I need to write TCP client which sends  the data from TCP client which is implemented in C within SDK provided to TCP Server which is basically python program running.

 

image

 

 

Code snippets -

     Here, I am just going to give details about add on codes which I did to make this application, rather than providing complete code.

 

Following is the TCP Client implemented in C (You can find lot of examples online about TCP client implementation in C),

 

/*
    Create a TCP socket
*/

#include<stdio.h>
#include<winsock2.h>
#include "console.h"


#pragma comment(lib,"ws2_32.lib") //Winsock Library

 WSADATA wsa;
 SOCKET s;
 struct sockaddr_in server;
 char *message;


int tcpInit(void)
{
       printf("\nInitialising Winsock...");
    if (WSAStartup(MAKEWORD(2,2),&wsa) != 0)
    {
        printf("Failed. Error Code : %d",WSAGetLastError());
        return 1;
    }
     
    printf("Initialised.\n");
     
    //Create a socket
    if((s = socket(AF_INET , SOCK_STREAM , 0 )) == INVALID_SOCKET)
    {
        printf("Could not create socket : %d" , WSAGetLastError());
    }

    printf("Socket created.\n");
    server.sin_addr.s_addr = inet_addr("127.0.0.1");
    server.sin_family = AF_INET;
    server.sin_port = htons(5005 );

    //Connect to remote server
    if (connect(s , (struct sockaddr *)&server , sizeof(server)) < 0)
    {
        puts("connect error");
        return 1;
    }
  return 0;
}
int tcpSendData(char *uData)
{
     //while (1)
     //{
  //puts("Connected");


  retry:  
  //Send some data
  //message = "GET / HTTP/1.1\r\n\r\n";
  if( send(s , uData , strlen(uData) , 0) < 0)
  {
  puts("Send failed");
  return 1;
  goto retry;
  }
  Sleep(1);
  puts("Data Send\n");
    //}
  return 0;
}
 //   closesocket(s);
   // WSACleanup();
  //  return 0;
//}

image

 

          As you can see the function tcpSendData is used to send data over TCP socket to local Ip over 5005 port. This function is called in gestic.c file, when gesture is detected. Following is the code snippet for same.

 

       if(data->gestic_gesture != NULL) {
            /* Remember last gesture and reset it after 1s = 200 updates */
            if(data->gestic_gesture->gesture > 0 && data->gestic_gesture->gesture <= 6)
                data->last_gesture = data->gestic_gesture->gesture;
            else if(data->gestic_gesture->last_event > 1) //Shrenik
                data->last_gesture = 0;


            printf("Gesture:          %s \n", gestures[data->last_gesture]);
  
if(strcmp(gestures[data->last_gesture],"DNULL"))
  {
  tcpSendData(gestures[data->last_gesture]);
}


  }

 

 

I am attaching the modified console project from SDK, with this blog for reference which can be used to do such application. In Next blog I will talk about Python side program. Let me know if anyone have queries about same.

 

 

Thanks,

Shrenik.

Attachments:
GestureCode.rar
  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube