Sending a amount of objects recognize from Roborealm to a C++ program
Recognition
First if you need to download is the Roborealm software and install the trail program
The add these 3 modules to the action bar below
Explanation
Roberts Edge
Read more here (http://www.roborealm.com/help/Roberts_Edge.php)
The Roberts Edge filter is use to detect edges based applying a horizontal and verticle filter in sequence. Both filters are applied to the image and summed to form the final result. The two filters are basic convolution filters of the form:
Horizontal Filter
Vertical Filter
Object Recognition
The is the actual software that is going to be used to recognize the object. The is already installed in the program. Not needed for other installations.
Socket_Client
The is used to send the data using TCP/UDP/FTP
Working
Object recognition
- Click in the "Object recognition" then on the "Edit button
- Bottem Left there is a button that states "Add Object
- Drag the box on the object you want to recognize and give it a name you want
Socket
- Make sure the socket is set to 4040
- Click the drop down in the send sequence and click on "Object_Count" and click "Insert"
3)Make sure it states "Stop" in the bottom left that means the server is active
Now your roboRealm side is set up 100%
Now we will go the the console application to receive the response from the application
include
< windows.h> #include
< stdio.h> #include
< string.h> #include
< stdlib.h>
#pragma comment(lib, "ws2_32.lib") // the port number to listen on ... needs to match that used in RR interface # define SERVER_PORTNUM 4040 WSADATA winsock_data; WORD version_required; /* Version 1.1 */ // This is where the server starts void main(int argc, char * argv[]) { version_required = 0x0101; /* Version 1.1 */ WSAStartup(version_required, & winsock_data);
int hSocket;
int server;
int sockaddr_in_length = sizeof(struct sockaddr_in);
int fromlen = sizeof(struct sockaddr_in);
if ((server = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
printf("Could not create socket!");
exit(-1);
}
int enable = 1;
if ((setsockopt(server, SOL_SOCKET, SO_REUSEADDR, (char * ) & enable, sizeof(enable))) < 0) {
printf("Could not set socket option SO_REUSEADDR!");
exit(-1);
}
if ((setsockopt(server, SOL_SOCKET, SO_KEEPALIVE, (char * ) & enable, sizeof(enable))) < 0) {
printf("Could not set socket option SO_KEEPALIVE!");
exit(-1);
}
if ((setsockopt(server, IPPROTO_TCP, TCP_NODELAY, (char * ) & enable, sizeof(enable))) < 0) {
printf("Could not set socket option TCP_NODELAY!");
exit(-1);
}
struct linger ling;
ling.l_onoff = 1;
ling.l_linger = 10;
if ((setsockopt(server, SOL_SOCKET, SO_LINGER, (char * ) & ling, sizeof(linger))) < 0) {
printf("Could not set socket option SO_LINGER!");
exit(-1);
}
/* sytem's location of the sock */
struct sockaddr_in sockaddr;
/* id of foreign calling process */
struct sockaddr_in caller;
/* register the sock */
sockaddr.sin_family = AF_INET;
sockaddr.sin_addr.s_addr = INADDR_ANY; /* not choosy about who calls*/
sockaddr.sin_port = htons(SERVER_PORTNUM);
if (bind(server, (struct sockaddr * ) & sockaddr, sizeof(sockaddr)) != 0) {
exit(-2);
}
if (listen(server, 1024) != 0) {
exit(-3);
}
unsigned char buffer[8192];
while (true) {
printf("Waiting ...\n");
::listen(server, 1024);
if ((hSocket = accept(server, (struct sockaddr * ) & caller, & fromlen)) < 0) {
printf("Accept failed!");
continue;
}
printf("Connected.\n");
while (true) {
int len = recv(hSocket, (char * ) buffer, sizeof(buffer), NULL);
// termination signal -1 on attribute length
if (len <= 0) break;
int i;
for (i = 0; i < len; i++) {
if (buffer[i] <= 32) {
printf("\\%d", buffer[i]);
} else
if (buffer[i] >= 128) {
printf("\\%d", buffer[i]);
} else
printf("%c", buffer[i]);
}
printf("\r\n");
if (buffer[0] == 128)
send(hSocket, "Hello!", 7, 0);
}
printf("\nDisconnected.\n");
shutdown(hSocket, 1);
shutdown(hSocket, 0);
closesocket(hSocket);
}
printf("Exiting\n");
closesocket(server);
}
Congratulations @carel111! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Do not miss the last post from @steemitboard:
Vote for @Steemitboard as a witness to get one more award and increased upvotes!