【Fisheye】Enabling Fisheye Dewarping And EPTZ Control
サンプルプログラム
//
// Device Network SDK (Fisheye)
//
// Enable Fisheye Expansion and E-PTZ Control
// Sample Code for Enabling Fisheye Dewarping and E-PTZ Control via Player SDK
//
#include <stdio.h>
#include <iostream>
#include “stdafx.h”
#include “SynPlayMode.h”
#include “SynPlayModeDlg.h”
#include “PlayM4.h
#include “Windows.h”
void FisheyePlay()
{
BOOL bRet = FALSE;
FISHEYEPARAM stFEPara1 = {0};
FISHEYEPARAM stFEPara2 = {0};
FISHEYEPARAM stFEPara3 = {0};
//Get the player SDK port
PlayM4_GetPort(&m_lPort);
if (-1 == m_lPort)
{
CString str;
str.Format(“PlayM4_GetPort fail\n”);
MessageBox(str);
return;
}
//Open the video file to play
if (FALSE == PlayM4_OpenFile(m_lPort,m_strFileName.GetBuffer(m_strFileName.GetLength())))
{
CString str;
str.Format(“PlayM4_OpenFile fail[0x%x]\n”,PlayM4_GetLastError(m_lPort));
MessageBox(str);
goto EXIT1;
}
//Play the video file
if (FALSE == PlayM4_Play(m_lPort,GetDlgItem(IDC_FISHEYE_MAIN_WND)->GetSafeHwnd()))
{
CString str;
str.Format(“PlayM4_Play fail[0x%x]\n”,PlayM4_GetLastError(m_lPort));
MessageBox(str);
goto EXIT2;
}
//Enable the fisheye dewarping
if (FALSE == PlayM4_FEC_Enable(m_lPort))
{
CString str;
str.Format(“PlayM4_FEC_Enable fail[0x%x]\n”,PlayM4_GetLastError(m_lPort));
MessageBox(str);
goto EXIT2;
}
//Sub port 1 , ceiling mounting, PTZ mode, get the sub port for fisheye dewarping
if (FALSE == PlayM4_FEC_GetPort(m_lPort,&m_nSubPort1,FEC_PLACE_CEILING,FEC_CORRECT_PTZ))
{
CString str;
str.Format(“PlayM4_FEC_GetPort1 fail[0x%x]\n”,PlayM4_GetLastError(m_lPort));
MessageBox(str);
goto EXIT3;
}
//Update the position and the zooming value
stFEPara1.nUpDateType = FEC_UPDATE_PTZPARAM | FEC_UPDATE_PTZZOOM; //Updated type
stFEPara1.stPTZParam.fPTZPositionX = 0.2; //The central coordinates of PTZ view
stFEPara1.stPTZParam.fPTZPositionY = 0.3;
stFEPara1.fZoom = 0.1; //The range parameter of PTZ view
// stCycleParam is available to all ssub ports of fisheye dewarping.
//Set fisheye dewarping parameters
if (FALSE == PlayM4_FEC_SetParam(m_lPort,m_nSubPort1,&stFEPara1))
{
CString str;
str.Format(“PlayM4_FEC_SetParam1 fail[0x%x]\n”,PlayM4_GetLastError(m_lPort));
MessageBox(str);
goto EXIT3;
}
//Sub port 2 , ceiling mounting, PTZ mode, get the sub port for fisheye dewarping
if (FALSE == PlayM4_FEC_GetPort(m_lPort,&m_nSubPort2,FEC_PLACE_CEILING,FEC_CORRECT_PTZ))
{
CString str;
str.Format(“PlayM4_FEC_GetPort2 fail[0x%x]\n”,PlayM4_GetLastError(m_lPort));
MessageBox(str);
goto EXIT3;
}
//Update the position
stFEPara2.nUpDateType = FEC_UPDATE_PTZPARAM;
stFEPara2.stPTZParam.fPTZPositionX = 0.7; //(0,1)
stFEPara2.stPTZParam.fPTZPositionY = 0.8; //(0,1)
//Set fisheye dewarping parameters
if (FALSE == PlayM4_FEC_SetParam(m_lPort,m_nSubPort2,&stFEPara2))
{
CString str;
str.Format(“PlayM4_FEC_SetParam2 fail[0x%x]\n”,PlayM4_GetLastError(m_lPort));
MessageBox(str);
goto EXIT3;
}
//Zoom in/out
stFEPara3.nUpDateType = FEC_UPDATE_PTZZOOM;
stFEPara3.fZoom = 0.9; //(0,1)
//Set fisheye dewarping parameters
if (FALSE == PlayM4_FEC_SetParam(m_lPort,m_nSubPort2,&stFEPara3))
{
CString str;
str.Format(“PlayM4_FEC_SetParam3 fail[0x%x]\n”,PlayM4_GetLastError(m_lPort));
MessageBox(str);
goto EXIT3;
}
//Sub port 3 , ceiling mounting, PTZ mode, get the sub port for fisheye dewarping
if (FALSE == PlayM4_FEC_GetPort(m_lPort,&m_nSubPort3,FEC_PLACE_CEILING,FEC_CORRECT_PTZ))
{
CString str;
str.Format(“PlayM4_FEC_GetPort2 fail[0x%x]\n”,PlayM4_GetLastError(m_lPort));
MessageBox(str);
goto EXIT3;
}
//Set fisheye dewarping parameters
stFEPara3.nUpDateType = FEC_UPDATE_PTZPARAM;
stFEPara3.stPTZParam.fPTZPositionX = 0.7; //(0,1)
stFEPara3.stPTZParam.fPTZPositionY = 0.8; //(0,1)
stFEPara3.fZoom = 0.9; //(0,1)
if (FALSE == PlayM4_FEC_SetParam(m_lPort,m_nSubPort2,&stFEPara3))
{
CString str;
str.Format(“PlayM4_FEC_SetParam3 fail[0x%x]\n”,PlayM4_GetLastError(m_lPort));
MessageBox(str);
goto EXIT3;
}
//Set fisheye dewarping parameters
stFEPara3.nUpDateType = FEC_UPDATE_PTZZOOM;
if (FALSE == PlayM4_FEC_SetParam(m_lPort,m_nSubPort2,&stFEPara3))
{
CString str;
str.Format(“PlayM4_FEC_SetParam3 fail[0x%x]\n”,PlayM4_GetLastError(m_lPort));
MessageBox(str);
goto EXIT3;
}
//Set the display window
PlayM4_FEC_SetWnd(m_lPort,m_nSubPort1,GetDlgItem(IDC_FISHEYE_SUB_WND1)->GetSafeHwnd());
PlayM4_FEC_SetWnd(m_lPort,m_nSubPort2,GetDlgItem(IDC_FISHEYE_SUB_WND2)->GetSafeHwnd());
PlayM4_FEC_SetWnd(m_lPort,m_nSubPort3,GetDlgItem(IDC_FISHEYE_SUB_WND3)->GetSafeHwnd());
return;
EXIT3:
//Delete the sub port of fisheye dewarping
if (-1 != m_nSubPort1)
{
PlayM4_FEC_DelPort(m_lPort,m_nSubPort1);
m_nSubPort1 = -1;
}
//Delete the sub port of fisheye dewarping
if (-1 != m_nSubPort2)
{
PlayM4_FEC_DelPort(m_lPort,m_nSubPort2);
m_nSubPort2 = -1;
}
//Delete the sub port of fisheye dewarping
if (-1 != m_nSubPort3)
{
PlayM4_FEC_DelPort(m_lPort,m_nSubPort3);
m_nSubPort3 = -1;
}
//Disable fisheye dewarping
PlayM4_FEC_Disable(m_lPort);
EXIT2:
PlayM4_CloseFile(m_lPort);
EXIT1:
if (-1 != m_lPort)
{
PlayM4_FreePort(m_lPort);
m_lPort = -1;
}
}