HardVRViewController.mm 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. //
  2. // HardVRViewController.m
  3. // XWorld
  4. //
  5. // Created by Apple on 16/8/29.
  6. // Copyright © 2016年 xiongmaitech. All rights reserved.
  7. //
  8. #import "HardVRViewController.h"
  9. #import "VRGLViewController.h"
  10. #include "fisheye.h"
  11. #include "fisheye_opengl.h"
  12. #include "fisheye_errordef.h"
  13. #define RAD_TO_DEG( rad ) ( (rad) * 57.29577951f )
  14. using namespace std;
  15. @interface HardVRViewController ()
  16. {
  17. HANDLE _hFECtx;
  18. FEOPTION _tFEOption;
  19. CGPoint _touchBegPoint;
  20. CGPoint _touchEndPoint;
  21. BOOL _touched;
  22. QUEUE_YUV_DATA _yuvDatas;
  23. unsigned char * _pbyYUV;
  24. pthread_mutex_t lock_yuv;
  25. int _nYUVBufLen;
  26. float fDeltaPan;
  27. float fDeltaTilt;
  28. float pPan;
  29. float pTilt;
  30. NSInteger numbers;
  31. BOOL isOverleft;//
  32. BOOL isGravity;//是否开启重力感应
  33. BOOL _IsYuv;
  34. BOOL isZoomJ;//zoom 减小
  35. BOOL isZoomK;//zoom 扩大
  36. int zoomK;
  37. BOOL isMove;//判断手指停留 惯性停止
  38. BOOL isTouchMove;
  39. BOOL isDraw;//是否开始画图像
  40. }
  41. @property(strong,nonatomic)EAGLContext* context;
  42. @property (strong, nonatomic) NSDate *begDate;
  43. @property (strong,nonatomic) NSDate *endDate;
  44. @end
  45. @implementation HardVRViewController
  46. -(id)init{
  47. self = [super init];
  48. if ( self ) {
  49. }
  50. return self;
  51. }
  52. - (void)viewDidLoad {
  53. [super viewDidLoad];
  54. // Do any additional setup after loading the view.
  55. self.view.backgroundColor = [UIColor blackColor];
  56. self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
  57. if (!self.context) {
  58. NSLog(@"Failed to create ES context");
  59. }
  60. GLKView *view = (GLKView *)self.view;
  61. view.context = self.context;
  62. view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
  63. [EAGLContext setCurrentContext:self.context];
  64. // Initial fisheye library
  65. SCODE scRet = Fisheye_Initial(&_hFECtx, LIBFISHEYE_VERSION);
  66. if (scRet != FISHEYE_S_OK)
  67. {
  68. NSLog(@"Fisheye_Initial Failed. (%lx)", scRet);
  69. }
  70. [self setDewarpType:FE_DEWARP_AROUNDVIEW];
  71. [self setMountType:FE_MOUNT_CEILING];
  72. Fisheye_SetPanTiltZoom(_hFECtx, FE_POSITION_ABSOLUTE, 0, 0, 1);
  73. [self loadYUVImageFromFile];
  74. // UITapGestureRecognizer* singleRecognizer= [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(single:)];
  75. // //点击的次数
  76. // singleRecognizer.numberOfTapsRequired = 1; // 单击
  77. //
  78. // //给self.view添加一个手势监测;
  79. //
  80. // [self.view addGestureRecognizer:singleRecognizer];
  81. _ZoomNumber = 2;
  82. }
  83. //-(void)single:(UITapGestureRecognizer *)sender
  84. //{
  85. //
  86. //}
  87. - (void) setMountType:(FEMOUNTTYPE) mount
  88. {
  89. _tFEOption.MountType = mount;
  90. _tFEOption.Flags = FE_OPTION_MOUNTTYPE;
  91. Fisheye_SetOption(_hFECtx, &_tFEOption);
  92. }
  93. - (void) setDewarpType:(FEDEWARPTYPE) dewarpType
  94. {
  95. _tFEOption.DewarpType = dewarpType;
  96. _tFEOption.Flags = FE_OPTION_DEWARPTYPE;
  97. Fisheye_SetOption(_hFECtx, &_tFEOption);
  98. }
  99. - (void)handleFisheyeInput:(unsigned int)width height:(unsigned int)height buffer:(const void *)buffer
  100. {
  101. // Update InVPicture header
  102. if (_tFEOption.InVPicture.Width != width || _tFEOption.InVPicture.Height != height || _tFEOption.InVPicture.Format != FE_PIXELFORMAT_YUV420P)
  103. {
  104. // Set input image information
  105. _tFEOption.InVPicture.Width = width;
  106. _tFEOption.InVPicture.Height = height;
  107. _tFEOption.InVPicture.Stride = width;
  108. _tFEOption.InVPicture.Format = FE_PIXELFORMAT_YUV420P;
  109. // Set center and radius
  110. _tFEOption.FOVCenter.X = (_tFEOption.InVPicture.Width >> 1);
  111. _tFEOption.FOVCenter.Y = 20;//(_tFEOption.InVPicture.Height >> 1);
  112. _tFEOption.FOVRadius = _tFEOption.InVPicture.Width >> 1;
  113. // Update parameters in fisheye library
  114. _tFEOption.Flags = (FE_OPTION_INIMAGEHEADER | FE_OPTION_FOVCENTER | FE_OPTION_FOVRADIUS);
  115. Fisheye_SetOption(_hFECtx, &_tFEOption);
  116. }
  117. if (_tFEOption.InVPicture.Buffer != (BYTE*)buffer)
  118. {
  119. _tFEOption.InVPicture.Buffer = (BYTE*)buffer;
  120. _tFEOption.Flags = (FE_OPTION_INIMAGEBUFFER);
  121. Fisheye_SetOption(_hFECtx, &_tFEOption);
  122. }
  123. }
  124. - (void)loadYUVImageFromFile
  125. {
  126. SYUVData *pData = [self PopData];
  127. if (pData) {
  128. int nDataLen = pData->width * pData->height * 3 / 2;
  129. if (_nYUVBufLen< nDataLen || _pbyYUV == NULL) {
  130. if (_pbyYUV) {
  131. free(_pbyYUV);
  132. _pbyYUV = NULL;
  133. }
  134. _pbyYUV = (unsigned char *)malloc(nDataLen);//new unsigned char[nDataLen];
  135. _nYUVBufLen = nDataLen;
  136. }
  137. memcpy(_pbyYUV, pData->pData, nDataLen);
  138. [self handleFisheyeInput:pData->width height:pData->height buffer:_pbyYUV];
  139. delete pData;
  140. //[self ClearYUVData];
  141. }
  142. }
  143. - (void) handleDrawLocation:(GLKView *)view
  144. {
  145. unsigned int drawableWidth = (unsigned int)view.drawableWidth;
  146. unsigned int drawableHeight = (unsigned int)view.drawableHeight;
  147. if (_tFEOption.OutVPicture.Width != drawableWidth || _tFEOption.OutVPicture.Height != drawableHeight)
  148. {
  149. _tFEOption.OutVPicture.Width = drawableWidth;
  150. _tFEOption.OutVPicture.Height = drawableHeight;
  151. _tFEOption.OutVPicture.Format = FE_PIXELFORMAT_RGB32;
  152. _tFEOption.OutRoi.Top = 0;
  153. _tFEOption.OutRoi.Top = 0;
  154. _tFEOption.OutRoi.Right = _tFEOption.OutVPicture.Width;
  155. _tFEOption.OutRoi.Bottom = _tFEOption.OutVPicture.Height;//_tFEOption.OutVPicture.Height;
  156. _tFEOption.Flags = (FE_OPTION_OUTIMAGEHEADER | FE_OPTION_OUTROI);
  157. Fisheye_SetOption(_hFECtx, &_tFEOption);
  158. }
  159. }
  160. - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
  161. {
  162. // if (!isDraw) {
  163. // return;
  164. // }
  165. // Clear framebuffer
  166. glClearColor(0, 0, 0, 1.0);
  167. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  168. // load image
  169. [self loadYUVImageFromFile];
  170. // Update draw location
  171. [self handleDrawLocation:view];
  172. if(isZoomK)
  173. {
  174. [self FishEyeZoomK];
  175. }
  176. if (isZoomJ) {
  177. [self FishEyeZoomJ];
  178. }
  179. if(_touched == NO)
  180. {
  181. // if(!isOverturn)
  182. // {
  183. if (numbers>1)
  184. {
  185. }
  186. else
  187. {
  188. float NowZoom=0;
  189. Fisheye_GetPanTiltZoom(_hFECtx, &(pPan), &(pTilt),&NowZoom );//获取扩大活着缩小的倍数
  190. if (NowZoom < _ZoomNumber)
  191. {
  192. if (isTouchMove)
  193. {
  194. [self fishEyeZoomK:NowZoom];
  195. }
  196. }
  197. else
  198. {
  199. float pMaxTilt;//当前放大倍数的边界角度
  200. float pMinTilt;
  201. Fisheye_GetCurrentTiltBoundary(_hFECtx, &(pMinTilt), &(pMaxTilt));
  202. if(pTilt > pMaxTilt)
  203. {
  204. [self fishEyeSpringback:pPan];
  205. }
  206. else
  207. {
  208. // if (self.bFull ==YES && isGravity ==YES)
  209. // {
  210. //
  211. // }
  212. // else
  213. // {
  214. [self fishEyeinertialsystem];
  215. // }
  216. }
  217. }
  218. }
  219. // }
  220. }
  221. SCODE scRet = Fisheye_OneFrame(_hFECtx);
  222. // if (scRet != FISHEYE_S_OK)
  223. // {
  224. // NSLog(@"Fisheye_OneFrame Failed. (%lx)\n", scRet);
  225. // }
  226. }
  227. -(void)PushData:(int)width height:(int)height YUVData:(unsigned char *)pData
  228. {
  229. @synchronized(self)
  230. {
  231. SYUVData *pNew = new SYUVData(width, height, pData);
  232. _yuvDatas.push(pNew);
  233. int nSize = (int)_yuvDatas.size();
  234. for (int i = 4; i < nSize; i++) {
  235. SYUVData *item = _yuvDatas.front();
  236. _yuvDatas.pop();
  237. delete item;
  238. }
  239. }
  240. isDraw = YES;
  241. }
  242. -(SYUVData *)PopData
  243. {
  244. SYUVData *pItem = NULL;
  245. @synchronized(self)
  246. {
  247. if (!_yuvDatas.empty()) {
  248. pItem = _yuvDatas.front();
  249. _yuvDatas.pop();
  250. }
  251. }
  252. return pItem;
  253. }
  254. #pragma mark 滑动开始
  255. -(void)HardTouchbegan:(CGPoint)BegPoint
  256. {
  257. self.begDate=[NSDate date];
  258. _touchBegPoint = BegPoint;
  259. _touched = true;
  260. }
  261. #pragma mark 滑动
  262. -(void)HardTouchMove:(CGPoint)MovePoint
  263. {
  264. if (_touched != true)
  265. {
  266. return;
  267. }
  268. _touchEndPoint = MovePoint;
  269. isTouchMove = YES;
  270. // Calculate the difference between begin position and current position
  271. float fDistanceX = _touchEndPoint.x - _touchBegPoint.x;
  272. float fDistanceY = _touchEndPoint.y - _touchBegPoint.y;
  273. // Fluent control
  274. fDeltaPan = 0;
  275. fDeltaTilt = 0;
  276. float fWidthInView = (_tFEOption.OutRoi.Right - _tFEOption.OutRoi.Left) * self.view.frame.size.width / _tFEOption.OutVPicture.Width;
  277. float fHeightInView = (_tFEOption.OutRoi.Bottom - _tFEOption.OutRoi.Top) * self.view.frame.size.height / _tFEOption.OutVPicture.Height;
  278. if (FE_DEWARP_RECTILINEAR == _tFEOption.DewarpType)
  279. {
  280. float fPan = 0, fTilt = 0, fZoom = 0;
  281. Fisheye_GetPanTiltZoom(_hFECtx, &fPan, &fTilt, &fZoom);
  282. // Move right/left
  283. if (FE_MOUNT_WALL == _tFEOption.MountType)
  284. {
  285. float fAspectRatio = fWidthInView / fHeightInView;
  286. float fD1 = ((float)_touchBegPoint.x / fWidthInView * 2.0f - 1.0f) / fZoom * fAspectRatio;
  287. float fD2 = ((float)_touchEndPoint.x / fWidthInView * 2.0f - 1.0f) / fZoom * fAspectRatio;
  288. float fTheta1 = RAD_TO_DEG(atanf(fD1));
  289. float fTheta2 = RAD_TO_DEG(atanf(fD2));
  290. fDeltaPan = (fTheta2 - fTheta1);
  291. }
  292. else
  293. {
  294. fDeltaPan = RAD_TO_DEG(atanf(fDistanceX / (fWidthInView * 0.5 * fZoom)));
  295. }
  296. // Move up/down
  297. fDeltaTilt = RAD_TO_DEG(atanf(fDistanceY / (fHeightInView * 0.5 * fZoom)));
  298. }
  299. else if (FE_DEWARP_FULLVIEWPANORAMA == _tFEOption.DewarpType)
  300. {
  301. fDeltaPan = fDistanceX / fWidthInView * 360.0f;
  302. }
  303. else if (FE_DEWARP_DUALVIEWPANORAMA == _tFEOption.DewarpType)
  304. {
  305. fDeltaPan = fDistanceX / fWidthInView * 180.0f;
  306. }
  307. else if (FE_DEWARP_AROUNDVIEW == _tFEOption.DewarpType)
  308. {
  309. fDeltaPan = fDistanceX;
  310. fDeltaTilt = fDistanceY;
  311. }
  312. Fisheye_SetPanTiltZoom(_hFECtx, FE_POSITION_RELATIVE, -fDeltaPan/2, fDeltaTilt/2, 0);
  313. // Update points
  314. _touchBegPoint = _touchEndPoint;
  315. }
  316. #pragma mark 滑动结束
  317. -(void)HardTouchEnd:(CGPoint)EndPoint
  318. {
  319. self.endDate=[NSDate date];
  320. numbers=[self comparebegtime];
  321. _touched = false;
  322. }
  323. #pragma mark 捏合手势
  324. -(void)HardtouchesPinch:(CGFloat)Velocity
  325. {
  326. float NowZoom=0;
  327. Fisheye_GetPanTiltZoom(_hFECtx, &(pPan), &(pTilt),&NowZoom );//获取扩大活着缩小的倍数
  328. if(NowZoom > _ZoomNumber)//倍数大于2倍
  329. {
  330. float zo= NowZoom + (Velocity/20);
  331. if (zo >= 3.5 )
  332. {
  333. return;
  334. }
  335. Fisheye_SetPanTiltZoom(_hFECtx, FE_POSITION_RELATIVE, 0, 0,Velocity/20);
  336. }
  337. else//小于2倍
  338. {
  339. float zo= NowZoom + (Velocity/20);
  340. if (zo >= 1.1 )
  341. {
  342. return;
  343. }
  344. Fisheye_SetPanTiltZoom(_hFECtx, FE_POSITION_RELATIVE, 0, 0,Velocity/20);
  345. }
  346. float Zooms=0;
  347. Fisheye_GetPanTiltZoom(_hFECtx, &(pPan), &(pTilt),&Zooms );//获取扩大活着缩小的倍数
  348. if (Zooms > NowZoom)
  349. {
  350. isZoomK = YES;
  351. }
  352. if (Zooms < NowZoom)
  353. {
  354. isZoomJ = YES;
  355. }
  356. }
  357. -(NSInteger)comparebegtime{
  358. NSUInteger unitFlags =
  359. NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond | NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear;
  360. NSCalendar *calendar = [NSCalendar currentCalendar];
  361. NSDateComponents *cps = [calendar components:unitFlags fromDate:self.begDate toDate:self.endDate options:0];
  362. return [cps second];
  363. }
  364. #pragma mark- 自动扩大
  365. -(void)fishEyeZoomK:(float)NowZoom
  366. {
  367. Fisheye_GetPanTiltZoom(_hFECtx, &(pPan), &(pTilt),&NowZoom );//获取扩大活着缩小的倍数
  368. if (NowZoom >= _ZoomNumber)
  369. {
  370. _touched = YES;
  371. isTouchMove = NO;
  372. //[self fishEyeSpringback];
  373. // [self fishEyeSpringback:pPan];
  374. }
  375. else
  376. {
  377. Fisheye_SetPanTiltZoom(_hFECtx, FE_POSITION_RELATIVE, 0, 0.5, 0) ;
  378. Fisheye_SetPanTiltZoom(_hFECtx, FE_POSITION_RELATIVE, 0, 0.5, 0.02) ;
  379. NSLog(@"Fisheye_GetPanTiltZoom---------------->%f",pTilt);
  380. }
  381. }
  382. -(void)fishEyeSpringback:(float)Pan
  383. {
  384. if (fDeltaPan > 0)
  385. {
  386. Fisheye_SetPanTiltZoom(_hFECtx, FE_POSITION_RELATIVE, -(fDeltaPan), -3, 0) ;
  387. fDeltaPan = fDeltaPan*2/3;
  388. }
  389. else
  390. {
  391. Fisheye_SetPanTiltZoom(_hFECtx, FE_POSITION_RELATIVE, -(fDeltaPan), -3, 0) ;
  392. fDeltaPan = fDeltaPan*2/3;
  393. }
  394. }
  395. #pragma mark-惯性移动
  396. -(void)fishEyeinertialsystem
  397. {
  398. if (fDeltaPan > 0 && fDeltaPan < 0.1)
  399. {
  400. fDeltaPan = 0.15;
  401. }
  402. if (fDeltaPan > -0.1 && fDeltaPan < 0)
  403. {
  404. fDeltaPan = -0.15;
  405. }
  406. if (fDeltaTilt > 0 && fDeltaTilt < 0.1)
  407. {
  408. fDeltaTilt = 0.15;
  409. }
  410. if (fDeltaTilt > -0.1 && fDeltaTilt < 0)
  411. {
  412. fDeltaTilt = -0.15;
  413. }
  414. Fisheye_SetPanTiltZoom(_hFECtx, FE_POSITION_RELATIVE, -fDeltaPan, 0, 0) ;
  415. float fDeltaT = fDeltaTilt/2;
  416. float fDeltaP = fDeltaPan/2;
  417. fDeltaTilt = fDeltaT;
  418. fDeltaPan = fDeltaP;
  419. }
  420. #pragma mark 惯性滑动停止
  421. -(void)MoveStop
  422. {
  423. fDeltaPan=0;
  424. fDeltaTilt=0;
  425. }
  426. - (void)didReceiveMemoryWarning {
  427. [super didReceiveMemoryWarning];
  428. // Dispose of any resources that can be recreated.
  429. }
  430. -(void)HardoutputRotationData:(double)rotationX rotationY:(double)rotationY
  431. {
  432. float Zoom = 0;
  433. Fisheye_GetPanTiltZoom(_hFECtx, &(pPan), &(pTilt), &Zoom);//获取当前试图的放大倍数
  434. double fDistanceX = rotationX;
  435. double fDistanceY = rotationY;
  436. if (fDistanceX < 10 && fDistanceX > -10) {//限制陀螺仪的转动(x坐标)
  437. if(fDistanceY < 10 && fDistanceY > -10){//限制陀螺仪的转动(y坐标)
  438. return;
  439. }else{
  440. fDistanceX = 0;
  441. }
  442. }
  443. if (isOverleft) {
  444. fDistanceY = 0-fDistanceY;
  445. }else{
  446. fDistanceX = 0-fDistanceX;
  447. }
  448. if (Zoom >= 2) {//试图放大倍数大于2 限制转动距离
  449. }
  450. else
  451. {
  452. fDistanceY = fDistanceY/3;
  453. fDistanceX = fDistanceX/3;
  454. }
  455. // Fluent control
  456. float fDeltaPans = 0;
  457. float fDeltaTilts = 0;
  458. float fWidthInView = (_tFEOption.OutRoi.Right - _tFEOption.OutRoi.Left) * self.view.frame.size.width / _tFEOption.OutVPicture.Width;
  459. float fHeightInView = (_tFEOption.OutRoi.Bottom - _tFEOption.OutRoi.Top) * self.view.frame.size.height / _tFEOption.OutVPicture.Height;
  460. if (FE_DEWARP_AROUNDVIEW == _tFEOption.DewarpType || FE_DEWARP_RECTILINEAR== _tFEOption.DewarpType)
  461. {
  462. float fPan = 0, fTilt = 0, fZoom = 0;
  463. Fisheye_GetPanTiltZoom(_hFECtx, &fPan, &fTilt, &fZoom);
  464. // Move right/left
  465. if (FE_MOUNT_WALL == _tFEOption.MountType)
  466. {
  467. float fAspectRatio = fWidthInView / fHeightInView;
  468. float fD1 = ((float)_touchBegPoint.x / fWidthInView * 2.0f - 1.0f) / fZoom * fAspectRatio;
  469. float fD2 = ((float)_touchEndPoint.x / fWidthInView * 2.0f - 1.0f) / fZoom * fAspectRatio;
  470. float fTheta1 = RAD_TO_DEG(atanf(fD1));
  471. float fTheta2 = RAD_TO_DEG(atanf(fD2));
  472. fDeltaPans = (fTheta2 - fTheta1);
  473. }
  474. else
  475. {
  476. fDeltaPans = RAD_TO_DEG(atanf(fDistanceX / (fWidthInView * 0.5 * fZoom)));
  477. }
  478. // Move up/down
  479. fDeltaTilts = RAD_TO_DEG(atanf(fDistanceY / (fHeightInView * 0.5 * fZoom)));
  480. }
  481. else if (FE_DEWARP_FULLVIEWPANORAMA == _tFEOption.DewarpType)
  482. {
  483. fDeltaPans = fDistanceX / fWidthInView * 360.0f;
  484. }
  485. else if (FE_DEWARP_DUALVIEWPANORAMA == _tFEOption.DewarpType)
  486. {
  487. fDeltaPans = fDistanceX / fWidthInView * 180.0f;
  488. }
  489. Fisheye_SetPanTiltZoom(_hFECtx, FE_POSITION_RELATIVE, -fDeltaPans, fDeltaTilts, 0);
  490. }
  491. #pragma mark 手势扩大
  492. -(void)FishEyeZoomK
  493. {
  494. float NowZoom=0;
  495. Fisheye_GetPanTiltZoom(_hFECtx, &(pPan), &(pTilt),&NowZoom );//获取扩大活着缩小的倍数
  496. if (NowZoom < 2)
  497. {
  498. float fP = 0 ;
  499. float fT = 0.5;
  500. Fisheye_SetPanTiltZoom(_hFECtx, FE_POSITION_RELATIVE, fP, fT, 0.0015) ;
  501. Fisheye_GetPanTiltZoom(_hFECtx, &(pPan), &(pTilt),&NowZoom );//获取扩大活着缩小的倍数
  502. NSLog(@"this is-----------------pTlit%f",pTilt);
  503. if(pTilt >-60)
  504. {
  505. Fisheye_SetPanTiltZoom(_hFECtx, FE_POSITION_RELATIVE, 0, 0.3, 0.02) ;
  506. }
  507. }
  508. else
  509. {
  510. isTouchMove = NO;
  511. isZoomK = NO;
  512. _touched = NO;
  513. }
  514. Fisheye_GetPanTiltZoom(_hFECtx, &(pPan), &(pTilt),&NowZoom );//获取扩大活着缩小的倍数
  515. }
  516. #pragma mark 手势缩小
  517. -(void)FishEyeZoomJ
  518. {
  519. float NowZoom=0;
  520. Fisheye_GetPanTiltZoom(_hFECtx, &(pPan), &(pTilt),&NowZoom );//获取扩大活着缩小的倍数
  521. NSLog(@"================================%f",NowZoom);
  522. if (NowZoom < 2)
  523. {
  524. float fP = 0 ;
  525. float fT = -0.6;
  526. Fisheye_SetPanTiltZoom(_hFECtx, FE_POSITION_RELATIVE, fP, fT, 0) ;
  527. Fisheye_SetPanTiltZoom(_hFECtx, FE_POSITION_RELATIVE, 0, -0.6, -0.05) ;
  528. }
  529. Fisheye_GetPanTiltZoom(_hFECtx, &(pPan), &(pTilt),&NowZoom );//获取扩大活着缩小的倍数
  530. if (pTilt == -90 && NowZoom <= 1.01) {
  531. isZoomJ = NO;
  532. isTouchMove = NO;
  533. }
  534. }
  535. /*
  536. #pragma mark - Navigation
  537. // In a storyboard-based application, you will often want to do a little preparation before navigation
  538. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  539. // Get the new view controller using [segue destinationViewController].
  540. // Pass the selected object to the new view controller.
  541. }
  542. */
  543. @end