#include <stdio.h>
|
#include <stdlib.h>
|
#include <assert.h>
|
|
#include "PTZBinding.nsmap"
|
#include "capabilities/capa.h"
|
#include "ptz/ptz.h"
|
#include "probe/probe.h"
|
#include "proto_comm.h"
|
#include "proto_dbg.h"
|
|
int main(int argc, char **argv)
|
{
|
int ret;
|
PosCur pos_get;
|
int preset0, preset1, preset2;
|
float pval, tval, zval;
|
float speed_p, speed_t, speed_z;
|
PtzDevs *handle = NULL;
|
|
ret = proto_PTZInit();
|
if (ret < 0) {
|
printf("PTZ initialization failure!\n");
|
|
return 0;
|
}
|
|
handle = proto_PTZGethandle();
|
|
/*test case 1: Get the current position*/
|
proto_PTZ_GetStatus(handle, &pos_get, USERNAME, PASSWORD);
|
printf("current pos: p %3.2f, t %3.2f, z %3.2f\n", pos_get.p, pos_get.t, pos_get.z);
|
/*test case 1 end*/
|
|
/*test case 2: run toward different directions with different speed, e.g. left\right\left-down\right-up and etc.*/
|
speed_p = MIN_SPEED;
|
speed_t = MIN_SPEED;
|
/*run toward left direction with the lowest speed*/
|
proto_PTZControl(handle, PTZ_CMD_LEFT, speed_p, speed_t, 0, USERNAME, PASSWORD);
|
|
sleep(25);
|
|
/*stop run*/
|
proto_PTZStop(handle, USERNAME, PASSWORD);
|
|
speed_p = MAX_SPEED;
|
speed_t = MAX_SPEED;
|
/*run toward left-down direction with the highest speed*/
|
proto_PTZControl(handle, PTZ_CMD_LEFTDOWN, speed_p, speed_t, 0, USERNAME, PASSWORD);
|
|
sleep(25);
|
|
/*stop run*/
|
proto_PTZStop(handle, USERNAME, PASSWORD);
|
|
speed_p = (MIN_SPEED + MAX_SPEED) / 2;
|
speed_t = MAX_SPEED;
|
/*run toward right-down with the mid speed*/
|
proto_PTZControl(handle, PTZ_CMD_RIGHTDOWN, speed_p, speed_t, 0, USERNAME, PASSWORD);
|
|
sleep(25);
|
|
/*stop run*/
|
proto_PTZStop(handle, USERNAME, PASSWORD);
|
|
speed_p = (MIN_SPEED + MAX_SPEED) / 2;
|
speed_t = (MIN_SPEED + MAX_SPEED) / 2;
|
/*run toward right direction with mid speed*/
|
proto_PTZControl(handle, PTZ_CMD_RIGHT, speed_p, speed_t, 0, USERNAME, PASSWORD);
|
|
sleep(25);
|
|
/*stop run*/
|
proto_PTZStop(handle, USERNAME, PASSWORD);
|
|
/*Get the current position*/
|
proto_PTZ_GetStatus(handle, &pos_get, USERNAME, PASSWORD);
|
printf("current pos: p %3.2f, t %3.2f, z %3.2f\n", pos_get.p, pos_get.t, pos_get.z);
|
/*test case 2 end*/
|
|
/*test case 3: Preset set - set the tradditional preset pos like hikon*/
|
proto_PTZPreset(handle, "index_0", PRESET_SET, &preset0, USERNAME, PASSWORD);
|
|
proto_PTZPreset(handle, "index_1", PRESET_SET, &preset1, USERNAME, PASSWORD);
|
|
proto_PTZPreset(handle, "index_2", PRESET_SET, &preset2, USERNAME, PASSWORD);
|
/*test case 3 end*/
|
|
/*test case 4: Preset goto - go to the preset pos*/
|
proto_PTZPreset(handle, NULL, PRESET_GOTO, &preset0, USERNAME, PASSWORD);
|
|
proto_PTZPreset(handle, NULL, PRESET_GOTO, &preset1, USERNAME, PASSWORD);
|
|
proto_PTZPreset(handle, NULL, PRESET_GOTO, &preset2, USERNAME, PASSWORD);
|
/*test case 4 end*/
|
|
/*test case 5: Preset remove - delete the preset pos*/
|
proto_PTZPreset(handle, NULL, PRESET_REMOVE, &preset0, USERNAME, PASSWORD);
|
|
proto_PTZPreset(handle, NULL, PRESET_REMOVE, &preset1, USERNAME, PASSWORD);
|
|
proto_PTZPreset(handle, NULL, PRESET_REMOVE, &preset2, USERNAME, PASSWORD);
|
/*test case 5 end*/
|
|
/*test case 6: zoom-in*/
|
zval = MAX_ZOOM;
|
proto_PTZSet(handle, 0, 0, zval, USERNAME, PASSWORD);
|
proto_PTZWaitStopped(handle, USERNAME, PASSWORD);
|
/*test case 6 end*/
|
|
/*test case 7: zoom out*/
|
zval = MAX_ZOOM / 2;
|
proto_PTZSet(handle, 0, 0, zval, USERNAME, PASSWORD);
|
proto_PTZWaitStopped(handle, USERNAME, PASSWORD);
|
|
zval = MIN_ZOOM;
|
proto_PTZSet(handle, 0, 0, zval, USERNAME, PASSWORD);
|
proto_PTZWaitStopped(handle, USERNAME, PASSWORD);
|
/*test case 7 end*/
|
|
/*test case 8: put the pixel (x, y) at the center of the image*/
|
proto_PTZ_GetStatus(handle, &pos_get, USERNAME, PASSWORD);
|
proto_PTZGetPT(handle, 0, 0, &pval, &tval, USERNAME, PASSWORD);
|
proto_PTZSet(handle, pval, tval, pos_get.z, USERNAME, PASSWORD);
|
sleep(20);
|
/*test case 8 end*/
|
|
/*test case 9:
|
* firstly, put the object enter point at the image center;
|
* secondly, zoom in the object that is describled with left-up and right-down pixel;
|
* finally, restore the image as original size;
|
*/
|
float data;
|
proto_PTZ_GetStatus(handle, &pos_get, USERNAME, PASSWORD);
|
proto_PTZGetPT(handle, 0, 0, &pval, &tval, USERNAME, PASSWORD);
|
proto_PTZSet(handle, pval, tval, pos_get.z, USERNAME, PASSWORD);
|
proto_PTZWaitStopped(handle, USERNAME, PASSWORD);
|
data = proto_PTZZoom_get(handle, 1280 / 2 - 1280 / 4, 960 / 4, 1280 * 3 / 4, 960 * 3 / 4);
|
proto_PTZSet(handle, 0, 0, data, USERNAME, PASSWORD);
|
proto_PTZWaitStopped(handle, USERNAME, PASSWORD);
|
|
proto_PTZSet(handle, 0, 0, 1, USERNAME, PASSWORD);
|
proto_PTZWaitStopped(handle, USERNAME, PASSWORD);
|
/*test case 9 end*/
|
|
/*test case 10: Preset touring*/
|
/*test case 10-1:
|
*set the preset tour whose type is the tradditional one like hikon mode*/
|
/*Set the preset pos table*/
|
PresetToure_tradnode posTradnode[] = {
|
{2, MIN_TOUR_TIME},
|
{3, MIN_TOUR_TIME + 20},
|
{4, MIN_TOUR_TIME}
|
};
|
|
proto_PTZPreset_tradtour_set(handle, posTradnode, sizeof(posTradnode) / sizeof(posTradnode[0]));
|
|
/*Start the tradditional tour*/
|
ret = proto_PTZPreset_tour_start(handle, TOUR_COMM);
|
if (ret) {
|
printf("start the tour failed!\n");
|
|
goto EXIT;
|
}
|
|
sleep(6000);
|
|
/*Stop the preset tour*/
|
proto_PTZPreset_tour_stop(handle);
|
|
/*test case 10-2:
|
*set the self-defined preset tour by ourselves*/
|
/*Set the preset pos table*/
|
PresetToure_node posNode[] = {
|
{0, 0, 1280 / 2 - 50, 960 / 2 - 50, 1280 /2 + 50, 960 / 2 + 50, MIN_TOUR_TIME},
|
{1280, 960, 1280 / 2 - 500, 980 / 2 - 400, 1280 / 2 + 500, 980 / 2 + 400, 20},
|
{600, 300, 1280 / 2 - 200, 980 / 2 - 200, 1280 / 2 + 200, 980 /2 + 200, MIN_TOUR_TIME}
|
};
|
proto_PTZPreset_tour_set(handle, posNode, sizeof(posNode) / sizeof(posNode[0]));
|
ret = proto_PTZPreset_tour_start(handle, TOUR_PRIV);
|
if (ret) {
|
printf("start the tour failed!\n");
|
|
goto EXIT;
|
}
|
|
printf("in starting re-set test to press key:\n");
|
getchar();
|
proto_PTZPreset_tour_set(handle, posNode, sizeof(posNode) / sizeof(posNode[0]));
|
|
printf("stop the tour to press the key:\n");
|
getchar();
|
proto_PTZPreset_tour_stop(handle);
|
/*test case 10 end*/
|
|
EXIT:
|
|
/*finally, remember release the resources when exitting!!!*/
|
printf("now release the handle:\n");
|
proto_PTZClose();
|
|
return 0;
|
}
|
|