|
|
#ifdef GY_OS_AMBA |
|
|
#pragma once |
|
|
#ifndef PTZ_H |
|
|
#define PTZ_H |
|
|
#include "define_inc.h" |
|
|
#include "utility.h" |
|
|
#include "nweb.h" |
|
|
#include <setjmp.h> |
|
|
|
|
|
#ifndef TRY_CATCH |
|
|
#define TRY_CATCH |
|
|
#define TRY do{ jmp_buf ex_buf__; if( !setjmp(ex_buf__) ){ |
|
|
#define CATCH } else { |
|
|
#define ETRY } }while(0) |
|
|
#define THROW longjmp(ex_buf__, 1) |
|
|
#endif |
|
|
|
|
|
#define SYS_FEATURE_PTZ 0x4000000 |
|
|
#define SYS_FEATURE_LDC 0x8000000 |
|
|
#define SYS_FEATURE_LPR 0x10000000 |
|
|
|
|
|
#define MIN_PRESET_NUMBER 0 |
|
|
#define MAX_PRESET_NUMBER 256 |
|
|
|
|
|
#define MAX_RECORD_BOX_SIZE 5 |
|
|
|
|
|
#define GO_HOME_SLEEP 3000 |
|
|
|
|
|
//#define MATH_PI 3.14 «½Æ©w¸q |
|
|
|
|
|
#define MAX_PTZ_INFO 100 |
|
|
#define TIMER_TEN_SEC 10 |
|
|
#define TIMER_ONE_SEC 1 |
|
|
#define TIMER_UPDATE_PTZ_SETTING 1 //Second |
|
|
#define TIMER_GO_HOME_PRESET 600 //Second |
|
|
|
|
|
#define PTZ_DEFAULT_SENSITIVITY 0 |
|
|
#define PTZ_CENTER_AREA_X2_MIN 45//2 //zoom in 10x define center area X%, don't move |
|
|
#define PTZ_CENTER_AREA_X2_MAX 55//2 //zoom in 10x define center area X%, don't move |
|
|
#define PTZ_CENTER_AREA_X5_MIN 40//5 //zoom in 5x |
|
|
#define PTZ_CENTER_AREA_X5_MAX 60//5 //zoom in 5x |
|
|
#define PTZ_CENTER_AREA_X8_MIN 35//8 //zoom in 1x |
|
|
#define PTZ_CENTER_AREA_X8_MAX 65//8 //zoom in 1x |
|
|
#define PTZ_TRACKING_OBJ_NUMBER 512 |
|
|
#define PTZ_ZOOMIN_LIMIT 100 //70% W&H |
|
|
#define PTZ_LOSE_OBJ_LIMIT 25 //max lose times |
|
|
#define PTZ_MISSING_OBJ_LIMIT_LONG 15 //max lose times |
|
|
#define PTZ_MISSING_OBJ_LIMIT_SHORT 9 //max lose times |
|
|
|
|
|
#define PTZ_FILTER_AREA_MIN 45 |
|
|
#define PTZ_FILTER_AREA_MAX 55 |
|
|
|
|
|
//TIMER |
|
|
#define PTZ_UPDATE_STATUS_TIMER 100 //100ms |
|
|
#define PTZ_TRACKING_RESUME_TIME 50 // 300 sec |
|
|
#define PTZ_IS_TRACKING_TIMER 5 // 10 second |
|
|
|
|
|
#define PTZ_ZOOM_FREQUENCE_MOD 6 |
|
|
|
|
|
#define PTZ_MISS_OBJ_MAGIC_FLAG 987654321 |
|
|
|
|
|
//#define PTZ_TEST |
|
|
/* |
|
|
typedef struct { |
|
|
char sUrl[512]; |
|
|
char sContent[512]; |
|
|
char sUsername[128]; |
|
|
char sPassword[128]; |
|
|
char sMethod[32]; |
|
|
int iPort; |
|
|
} PTZconnectInfo;*/ |
|
|
|
|
|
typedef struct PTZ_VIRTUAL_BOX { |
|
|
int left_x; |
|
|
int top_y; |
|
|
int right_x; |
|
|
int bottom_y; |
|
|
int center_x; |
|
|
int center_y; |
|
|
int width; |
|
|
int height; |
|
|
|
|
|
char name[50]; |
|
|
float confidence; |
|
|
int obj_type; |
|
|
int class_id; |
|
|
int obj_tracking_id; |
|
|
double obj_dwell_time; |
|
|
|
|
|
int iFirstTrackingFlag; |
|
|
} PTZ_VIRTUAL_BOX; |
|
|
|
|
|
typedef struct PTZ_ZONE_INFO { |
|
|
int iMetadata1_num; |
|
|
char sMetaOut1[PTZ_TRACKING_OBJ_NUMBER][50]; |
|
|
//char sMetaOut1[MAX_MSG_LEN * 10]; |
|
|
int iZoneToPreset; |
|
|
} PTZ_ZONE_INFO; |
|
|
|
|
|
typedef struct PTZ_HANDLE { |
|
|
int iIsMirror; |
|
|
int iIsFlip; |
|
|
int iIsAtHomePOS; |
|
|
int iIsInPreset; |
|
|
int iIsInAutopan; |
|
|
int iIsInAutoTracking; |
|
|
int iHomePreset; |
|
|
int iIsGoingHome; |
|
|
|
|
|
//int iIsStayHomePos; |
|
|
//int iSwitchTrackOnOff; |
|
|
|
|
|
int iIsPTZ; |
|
|
int iRunPTZUpdateStatusThread_flag; |
|
|
int iRunPTZTrackingThread_flag; |
|
|
int iRunPTZZoomThread_flag; |
|
|
|
|
|
//Home preset pos. |
|
|
int iHomePanABS; |
|
|
int iHomeTiltABS; |
|
|
int iHomeZoomABS; |
|
|
|
|
|
//pan, tilt and zoom absolute value |
|
|
int iPanABS; |
|
|
int iTiltABS; |
|
|
int iZoomABS; |
|
|
|
|
|
//Recovery Timer |
|
|
int iRT_min; |
|
|
int iRT_sec; |
|
|
|
|
|
int iZoomRunning; |
|
|
|
|
|
//PTZ_VIRTUAL_BOX stPTZlockTrackingBox; |
|
|
PTZ_VIRTUAL_BOX stPTZCandidateBoxTable[MAX_DETECT_OBJECTS]; |
|
|
int iCandidateBoxCount; |
|
|
int iIsGetLockTrackingBox; |
|
|
PTZ_VIRTUAL_BOX stPTZLockTrackingBox; |
|
|
|
|
|
PTZ_VIRTUAL_BOX stPTZOutsideBox; |
|
|
|
|
|
PTZ_VIRTUAL_BOX stPTZRecordOldOutsideBox[MAX_RECORD_BOX_SIZE]; |
|
|
int iRecordOldOutsideBoxCount; |
|
|
|
|
|
//int iLockBoxArea_min; |
|
|
//int iLockBoxArea_max; |
|
|
|
|
|
//double dwMoveAngel; |
|
|
//int iMoveSpeed_x; |
|
|
//int iMoveSpeed_y; |
|
|
|
|
|
|
|
|
//int iIs_enable_alarm; |
|
|
//time_t tOperatTime; |
|
|
//time_t tChangAutoPanTime; |
|
|
//time_t tOperatZoomTime; |
|
|
//time_t tTrackingTotalTime; |
|
|
//time_t tUpdateLockBoxTime; |
|
|
time_t tUpdateCandidateTableTime; |
|
|
|
|
|
|
|
|
//int LostTime; |
|
|
//int ResumTime; |
|
|
|
|
|
//PTZ_VIRTUAL_BOX stRecordCenterPoint[5]; |
|
|
//int iRecordCenterPointNumber; |
|
|
|
|
|
// iPTZ_sensitivity; |
|
|
int iPTZ_speed; |
|
|
|
|
|
//int iTimer_send_count; |
|
|
//int g_ptz_zoom_iou; |
|
|
int iLockObjFOV; |
|
|
|
|
|
int iTraffic_cnfidence; |
|
|
//char MetaData1[MAX_MSG_LEN * 10]; |
|
|
//char *metadata1[MAX_MSG_LEN * 10]; //for filter |
|
|
int iMetadata1_num; |
|
|
char sMetaOut1[PTZ_TRACKING_OBJ_NUMBER][50]; |
|
|
|
|
|
int iEnable_PTZ; |
|
|
int iTracking_fov_min; |
|
|
int iTracking_fov_max; |
|
|
int iEnable_tracking; |
|
|
int iTracking_mode; |
|
|
int iTracking_entering_zone; |
|
|
int iTracking_resume_dwell; |
|
|
int iIMG_source_w; |
|
|
int iIMG_source_h; |
|
|
|
|
|
int iLockBoxIdx; |
|
|
int iLoseLockObjCount; |
|
|
int iPauseTrackFlag; |
|
|
int iMissObjMomnentCount; |
|
|
|
|
|
int iThreadRunningFlag; |
|
|
|
|
|
int iUpdateOutsideBox; |
|
|
|
|
|
int tDiffTrackingSecond; |
|
|
|
|
|
int iZoomFreqMod; |
|
|
int iZoomFreqCount; |
|
|
int iGoCenterFreqFrame; |
|
|
int iGoCenterFreqCount; |
|
|
int iZoneToPresetAnyOne; |
|
|
//int iZoneToPreset[MAX_DETECTION_ZONE]; |
|
|
|
|
|
} PTZ_HANDLE; |
|
|
|
|
|
extern CURL* g_http_handle; |
|
|
|
|
|
extern pthread_mutex_t mutex_curl; |
|
|
|
|
|
extern ChannelInfo viewChannelData[MAX_AI_ENGINE_VIEW]; |
|
|
extern DetectionZoneInfo viewDetectionZone[MAX_AI_ENGINE_VIEW][MAX_DETECTION_ZONE]; |
|
|
extern SystemSettingInfo SystemSetting; |
|
|
extern AccountDataInfo accountData[MAX_ACCOUNT_DATA_NUM]; //20201027 sophia add |
|
|
|
|
|
|
|
|
extern PTZ_HANDLE g_stPTZ_Handle; |
|
|
extern pthread_mutex_t mutex_update_candidate; |
|
|
extern pthread_mutex_t mutex_send_cgi; |
|
|
//extern CURLM* g_multi_handle; |
|
|
//extern int g_handle_count; |
|
|
extern amba_content stAMBAcontent; |
|
|
|
|
|
//PTZ_HANDLE *CreatePTZHandle(); |
|
|
//void DeletePTZHandle(PTZ_HANDLE *pInPTZHandle); |
|
|
|
|
|
void SetPtzSensitivity(int iSensitivity); |
|
|
int UpdatePTZIPcamSetting(); |
|
|
int UpdatePTZCurPos(); |
|
|
|
|
|
int SetPTZNewPan(int new_pan); |
|
|
int SetPTZNewTilt(int new_tilt); |
|
|
int move_PTZ_in_the_direction(int new_pan, int new_tilt); |
|
|
void* ptz_stop_thread(void * ptr); |
|
|
|
|
|
void Mirror_Flip_posInfo(detection_pos *PosInfo, int iTotalElementSize, int iIm_width, int iIm_height, int iMirrorFlag, int iFlipFlag); |
|
|
int MirrorBondingBox(int x, int w); |
|
|
int FlipBondingBox(int y, int h); |
|
|
|
|
|
extern int g_IsPTZDevice; |
|
|
extern int g_check_if_OK_thermal; |
|
|
|
|
|
int StartPTZupdateStatusThread(); |
|
|
void StopPTZupdateStatusThread(); |
|
|
//void Free_PTZ_g_curl_connect(); |
|
|
|
|
|
void StartPTZtrackingThread(); |
|
|
void StopPTZtrackingThread(); |
|
|
|
|
|
void *ptz_update_status_thread(void *ptr); |
|
|
void *ptz_do_tracking_thread(void *ptr); |
|
|
void *ptz_do_zoom_thread(void *ptr); |
|
|
|
|
|
void UpdatePTZsourceWH(int iVideo_source_w, int iVideo_source_h); |
|
|
//void UpdatePTZConfigSetting(char *sEnable_ptz, char *sEnable_tracking, char *sTracking_fov_min, |
|
|
// char *sTracking_fov_max, char *sConfidence2, int iPTZMode, int iIsTrackingEnterZone, char *sTracking_resume_dwell, |
|
|
// char *sInMetadata1, int iZoneToPreset[]); |
|
|
void UpdatePTZConfigSetting(); |
|
|
void PTZUpdateTrackingInfo(detection_pos *posInfo, int iTotalElementSize, int iResW, int iResH); |
|
|
|
|
|
int IsPTZ(); |
|
|
int IsPTZMirror(); |
|
|
int IsPTZFlip(); |
|
|
int IsPTZMirrowFlip(); |
|
|
int IsPTZatHomePos(); |
|
|
int IsPTZinPreset(); |
|
|
int IsPTZinAutoPan(); |
|
|
int IsPTZinAutoTracking(); |
|
|
int IsPTZEnableAlarm(int iInZone_idx); |
|
|
int IsTracking(); |
|
|
|
|
|
int GetHomePreset(); |
|
|
int GetPTZActionState(); |
|
|
int StartTracking(); |
|
|
int StopTracking(); |
|
|
int EnableAlarmQuaue(); |
|
|
int DisableAlarmQueue(); |
|
|
//void PerformDetection(); |
|
|
int GetPTZStatus(); |
|
|
void StopPtz(); |
|
|
void GoPreset(int iPresetNumber); |
|
|
void StartStopAutopan(int iStartStopFlag); |
|
|
//int check_ptz(char* sUrl, char* sSendbuf, char *sUsername, char *sPassword, char *sMethod, int iPort); |
|
|
int check_ptz(char *outputData); |
|
|
|
|
|
float FindPointDistance(int x1, int y1, int x2, int y2); |
|
|
void send_request(char *szIP, char *sUrl, char *sSendbuf, char *sUsername, char *sPassword, char *sMethod, int iPort, char *sOutputData, char* function_id); |
|
|
|
|
|
int net_curl_ptz_cmd(const char *sUrl, const char *sData, void *callback_data, char *method, |
|
|
char *sUserNmae, char *sPassWord, int iPort, char *sOutputData, char* function_id); |
|
|
|
|
|
int get_g_PTZ_model(); |
|
|
|
|
|
int net_curl_status_cmd(const char *sUrl, const char *sData, void *callback_data, char *method, |
|
|
char *sUserNmae, char *sPassWord, int iPort, char *sOutputData,char* function_id); |
|
|
|
|
|
size_t ptz_cmd_curl_callback(void *ptr, size_t size, size_t nmemb, void *stream); |
|
|
|
|
|
int UpdateRecoveryTime(); |
|
|
void update_PTZ_limits(); |
|
|
|
|
|
#endif |
|
|
#endif |