server.cpp
Go to the documentation of this file.
00001 
00002 //      File:           server.cpp
00003 //      Author:         Changchang Wu
00004 //      Description :   driver of a SiftGPU Server.
00005 //
00006 //      Copyright (c) 2007 University of North Carolina at Chapel Hill
00007 //      All Rights Reserved
00008 //
00009 //      Permission to use, copy, modify and distribute this software and its
00010 //      documentation for educational, research and non-profit purposes, without
00011 //      fee, and without a written agreement is hereby granted, provided that the
00012 //      above copyright notice and the following paragraph appear in all copies.
00013 //      
00014 //      The University of North Carolina at Chapel Hill make no representations
00015 //      about the suitability of this software for any purpose. It is provided
00016 //      'as is' without express or implied warranty. 
00017 //
00018 //      Please send BUG REPORTS to ccwu@cs.unc.edu
00019 //
00021 #include <string.h>
00022 #include <iostream>
00023 #include <stdio.h>
00024 using std::cout;
00025 
00026 #include "../SiftGPU/SiftGPU.h"
00027 
00028 //if you included ServerSiftGPU.h here. 
00029 //CreateRemoteSiftGPU can be replaced by new ServerSiftGPU();
00030 
00031 int main(int argc, char** argv)
00032 {
00033 
00034         if(argc >= 2 && strcmp(argv[1], "-server") == 0)
00035         {       
00036                 //run siftgpu server
00037                 std::cout << "Starting server process...\n";
00038                 int port = 7777;
00039                 if(argc >= 3) sscanf(argv[2], "%d", &port);
00041                 RunServerLoop(port, argc - 3, argv + 3);
00042         }else if(argc >=2 && strcmp(argv[1], "-test") == 0)
00043         {
00044                 //start server on same computer and connect...
00045         //note we are using a SiftGPU pointer..
00046                 SiftGPU* siftgpu = CreateRemoteSiftGPU();
00047                 siftgpu->ParseParam(argc - 2, argv + 2);
00048         if(siftgpu->VerifyContextGL()) 
00049         {
00050                         //files on the matchines where the server runs
00051                     siftgpu->RunSIFT("../data/800-1.jpg");
00052                     siftgpu->RunSIFT("../data/800-2.jpg");
00053         }
00054         delete siftgpu; //this will terminate the server
00055         }else if(argc >=4 && strcmp(argv[1], "-test_remote") == 0)
00056         {
00058         char server_name[1024];  int port = 7777;       
00059         strcpy(server_name, argv[2]);
00060         sscanf(argv[3], "%d", &port);
00061                 SiftGPU* siftgpu = CreateRemoteSiftGPU(port, server_name);//new ServerSiftGPU(port, server_name);
00062                 siftgpu->ParseParam(argc - 4, argv + 4);
00063         if(siftgpu->VerifyContextGL()) 
00064         {
00065                         //files on the matchines where the server runs
00066                     siftgpu->RunSIFT("../data/800-1.jpg");
00067                     siftgpu->RunSIFT("../data/800-2.jpg");
00068         }
00069         delete siftgpu;
00070         }else if(argc >=2 && strcmp(argv[1], "-test2") == 0)
00071         {
00072                 //test using two siftgpu servers...usage:
00073         //server_siftgpu -test2 [server1_params] [-server2 [server2_params]]
00074 
00076         //they need to use different ports.
00077         SiftGPU* siftgpu1 = CreateRemoteSiftGPU(7777);//new ServerSiftGPU(7777);
00078         SiftGPU* siftgpu2 = CreateRemoteSiftGPU(8888);//new ServerSiftGPU(8888);
00079 
00080         //split the parameters for the two servers
00081         int argc1 = 0, argc2 = 0;
00082         char** argv1 = argv + 2, **argv2 = 0;
00083         while(argc1 + 2 < argc && strcmp(argv[argc1 + 2], "-server2"))
00084         {
00085             argc1++;
00086         }
00087         if(argc1 + 3 < argc && strcmp(argv[argc1 + 2], "-server2") == 0)
00088         {
00089             argv2 = argv + argc1 + 3;
00090             argc2 = argc - argc1 - 3;
00091         }
00092 
00093         //initialize the two servers with their siftgpu parameters
00094         siftgpu1->ParseParam(argc1, argv1);
00095                 siftgpu2->ParseParam(argc2, argv2);
00096         if(siftgpu1->VerifyContextGL() && siftgpu2->VerifyContextGL()) 
00097         {
00098                     siftgpu1->RunSIFT("../data/800-1.jpg");
00099             siftgpu2->RunSIFT("../data/800-1.jpg");
00100                     siftgpu1->RunSIFT("../data/800-2.jpg");
00101             siftgpu2->RunSIFT("../data/800-2.jpg");
00102         }
00103         delete siftgpu1;
00104         delete siftgpu2;
00105         }else
00106         {
00107         std::cout
00108         <<"try -test [siftgpu_param] to create a local server and a client\n"
00109         <<"try -test2 [siftgpu_param1] [-server2 [siftgpu_param2]]\n"
00110         <<"            to create two servers and two clients\n"
00111         <<"try -test_remote remote_sever_name remote_server_port\n"
00112         <<"            to create a client and connect to remote server\n"
00113         <<"use -server port [siftgpu_param] to start a server\n"
00114         <<"Note [siftgpu_param] allows you to select GPU from multi-GPUs\n"
00115         <<"\n";
00116         }
00117         return 1;
00118 }
00119 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


rgbd_registration
Author(s): Ross Kidson
autogenerated on Thu May 23 2013 15:36:53