control.cc

  1 const char *help = "\
  2 progname: control.cc\n\
  3 code2html: This program control a Sony pan/tilt/zoom camera using VISCA serial interface.\n\
  4 version: Torch3 vision2.0, 2003-2005\n\
  5 (c) Sebastien Marcel (marcel@idiap.ch)\n";
  6 
  7 #include <iostream.h>
  8 #include "SonyEviD31.h"
  9 #include "SonyEviD100P.h"
 10 
 11 using namespace Torch;
 12 
 13 int main()
 14 {
 15 	cameraControl *camera;
 16 
 17 	camera = new SonyEviD100P("/dev/ttyS", '1');
 18 	
 19 	if(camera->connect() == false) return 0;
 20 
 21 	int powerStatus;
 22 	char cmd[100];
 23 	
 24 	print("Trying to get the power status of the camera.\n");
 25 	powerStatus = camera->getPowerStatus();
 26 
 27 	switch(powerStatus)
 28 	{
 29 	case -1: 
 30 	   	print("Error couldn't get the power status.\n");
 31 		return 0;
 32 		break;
 33 	case 0: 
 34 		print("The camera is OFF.\n");
 35 		break;
 36 	case 1: 
 37 		print("The camera is ON.\n");
 38 		break;
 39 	default: 
 40 		print("Unexpected value.\n");
 41 		return 0;
 42 	}
 43 
 44 
 45 	do
 46 	{
 47 		cout << ">";
 48 		cin >> cmd;
 49 
 50 		if(strcmp(cmd, "on") == 0)
 51 			camera->setPowerOn();
 52 		
 53 		if(strcmp(cmd, "off") == 0)
 54 			camera->setPowerOff();
 55 		
 56 		if(strcmp(cmd, "backlight") == 0)
 57 		{
 58 		   	cin >> cmd;
 59 		
 60 			if(strcmp(cmd, "on") == 0)
 61 			{
 62 				camera->setBackLightOn();
 63 			}
 64 		
 65 			if(strcmp(cmd, "off") == 0)
 66 			{
 67 				camera->setBackLightOff();
 68 			}
 69 		}
 70 		
 71 		if((strcmp(cmd, "home") == 0) || (strcmp(cmd, "h") == 0))
 72 			camera->goHome();
 73 		
 74 		if((strcmp(cmd, "stop") == 0) || (strcmp(cmd, "s") == 0))
 75 			camera->stopPanTilt();
 76 		
 77 		if((strcmp(cmd, "up") == 0) || (strcmp(cmd, "u") == 0))
 78 			camera->up();
 79 		
 80 		if(strcmp(cmd, "ur") == 0)
 81 			camera->upRight();
 82 		
 83 		if(strcmp(cmd, "ul") == 0)
 84 			camera->upLeft();
 85 		
 86 		if((strcmp(cmd, "down") == 0) || (strcmp(cmd, "d") == 0))
 87 			camera->down();
 88 		
 89 		if(strcmp(cmd, "dr") == 0)
 90 			camera->downRight();
 91 		
 92 		if(strcmp(cmd, "dl") == 0)
 93 			camera->downLeft();
 94 		
 95 		if((strcmp(cmd, "left") == 0) || (strcmp(cmd, "l") == 0))
 96 			camera->left();
 97 		
 98 		if((strcmp(cmd, "right") == 0) || (strcmp(cmd, "r") == 0))
 99 			camera->right();
100 		
101 		if(strcmp(cmd, "panspeed") == 0)
102 		{
103 			cin >> cmd;
104 
105 			camera->setPanSpeed(atoi(cmd));
106 		}
107 		
108 		if(strcmp(cmd, "tiltspeed") == 0)
109 		{
110 			cin >> cmd;
111 
112 			camera->setTiltSpeed(atoi(cmd));
113 		}
114 		
115 		if((strcmp(cmd, "zoomtele") == 0) || (strcmp(cmd, "zoomin") == 0)  || (strcmp(cmd, "zi") == 0))
116 			camera->zoomTeleStd();
117 		
118 		if((strcmp(cmd, "zoomwide") == 0) || (strcmp(cmd, "zoomout") == 0)  || (strcmp(cmd, "zo") == 0))
119 			camera->zoomWideStd();
120 		
121 		if((strcmp(cmd, "stopzoom") == 0) || (strcmp(cmd, "sz") == 0))
122 			camera->stopZoom();
123 		
124 		
125 	} while((strcmp(cmd, "quit") != 0) && (strcmp(cmd, "q") != 0));
126 
127 	delete camera;
128 
129 	return 1;
130 }