#ifndef __SRV_PTZ_H__ #define __SRV_PTZ_H__ #ifdef __cplusplus extern "C" { #endif #include #include #include "capabilities/capa.h" #define HK_IDS_2DE 1 #if defined(HK_IDS_2DE) #define COEF_H_A 180 #define COEF_H_B 180 #define COEF_V_A -52.5 #define COEF_V_B 37.5 #define COEF_Z_A 31 #define COEF_Z_B 1 #define MAX_FOVH 60.2 #define MIN_FOVH 2.3 #define MAX_FOVV 39.0 #define MIN_FOVV 2.1 #endif #define MAX_VAL 360 #define MAX_ZOOM COEF_Z_A #define MIN_ZOOM 0 #define MAX_SPEED MAX_ZOOM #define MIN_SPEED MIN_ZOOM #define MIN_TOUR_TIME 15 #define MIN_TOUR_POS 2 #define MAX_IMG_SCALE 0.5 #define PI 3.14159 #define RAD2ANG(x) (180 / PI * x) #define ANG2RAD(x) (PI / 180 * x) #define COEF_FH_A 1.626 #define COEF_FH_B 0.634 #define COEF_FH_C 0.177 #define COEF_FV_A 0.953 #define COEF_FV_B 0.598 #define COEF_FV_C 0.166 /*PTZ working stat*/ enum PTZStat { RUNNING, IDLE, UNKNOWN, }; /*the current PTZ positions*/ typedef struct _PosCur { float p; float t; float z; enum PTZStat stat; } PosCur; /*the PTZ control command*/ enum PTZCMD { PTZ_CMD_LEFT, PTZ_CMD_RIGHT, PTZ_CMD_UP, PTZ_CMD_DOWN, PTZ_CMD_LEFTUP, PTZ_CMD_LEFTDOWN, PTZ_CMD_RIGHTUP, PTZ_CMD_RIGHTDOWN, PTZ_CMD_ZOOM_IN, PTZ_CMD_ZOOM_OUT, PTZ_CMD_FOCUS_IN, PTZ_CMD_FOCUS_OUT, PTZ_CMD_FOCUS_STOP, }; /*the tradditional preset control command*/ enum PreSetCMD { PRESET_SET, PRESET_GOTO, PRESET_GET, PRESET_REMOVE, }; /*the supported two types of tours*/ enum tourType { TOUR_PRIV, //our self-defined tour type TOUR_COMM, //for the traditional tour type such as Hikon }; /*Set the preset pos table: * Note (pos0_x, pos0_y) and (pos1_x, pos1_y) must be aligned with the image center pixle (x, y) */ typedef struct _PresetToure_node { int x; /*the pixel pos (x, y)*/ int y; int pos0_x; /*the left-up pixel*/ int pos0_y; int pos1_x; /*the right-down pixel*/ int pos1_y; int time_sec; /*the tour time*/ } PresetToure_node; /*Set the preset pos table*/ typedef struct _PresetToure_tradnode { int posToken; /*the preset token*/ int time_sec; /*the tour time*/ }PresetToure_tradnode; /*the operational handle*/ typedef struct _PtzDevs { struct tagCapabilities capa; struct tagProfile *profiles; PresetToure_node *posNode; int posNode_count; PresetToure_tradnode *postradNode; int postradNode_count; timer_t timer_id; sem_t sem_tour; pthread_mutex_t node_mutex; pthread_cond_t cond; /*the device work stat*/ char dev_stat; char wt_stat; /*the touring process work stat*/ char proc_stat; char ip[PROTO_ADDRESS_SIZE]; enum tourType tour_type; } PtzDevs; int proto_PTZInit(void); void proto_PTZClose(void); PtzDevs *proto_PTZGethandle(void); int proto_PTZControl(PtzDevs *DevData, enum PTZCMD cmd, float speed_p, float speed_t, \ float speed_z, const char *username, const char *passwd); int proto_PTZStop(PtzDevs *DevData, const char *username, const char *passwd); int proto_PTZSetStep(PtzDevs *DevData, enum PTZCMD cmd, float pos_p, float pos_t, float pos_z, \ const char *username, const char *passwd); int proto_PTZ_GetStatus(PtzDevs *DevData, PosCur *pos_get, const char *username, const char *passwd); int proto_PTZSet(PtzDevs *DevData, float pos_p, float pos_t, float pos_z, const char *username, const char *passwd); int proto_PTZGetPT(PtzDevs *DevData, int x, int y, float *p, float *t, const char *username, const char *passwd); static float ptz_fovv_get(float pos); static float ptz_fovh_get(float pos); static float pos_calc_p(float pos); static float pos_calc_t(float pos); static float pos_calc_z(float pos); static float pos_res_p(float pos); static float pos_res_t(float pos); static float pos_res_z(float pos); static int img_w_get(PtzDevs *DevData); static int img_h_get(PtzDevs *DevData); int proto_PTZPreset(PtzDevs *DevData, const char *posName, enum PreSetCMD cmd, \ int *posToken, const char *username, const char *passwd); int proto_PTZ_ImagingSet(PtzDevs *DevData, enum PTZCMD cmd, float speed, const char *username, const char *passwd); static void *task_preset_touring(void *arg); float proto_PTZZoom_get(PtzDevs *DevData, int x0, int y0, int x1, int y1); int proto_PTZPreset_tradtour_set(PtzDevs *DevData, PresetToure_tradnode *PosArr, int n); int proto_PTZPreset_tour_set(PtzDevs *DevData, PresetToure_node *PosArr, int n); int proto_PTZPreset_tour_start(PtzDevs *DevData, enum tourType type); void proto_PTZWaitStopped(PtzDevs *DevData, const char *username, const char *passwd); void proto_PTZPreset_tour_stop(PtzDevs *DevData); static void ptz_timer_handler(union sigval para); #ifdef __cplusplus } #endif #endif