001// ______________________________________________________ 002// Generated by codegen - https://gitee.com/l0km/codegen 003// template: thrift/client/perservice/client.service.decorator.class.vm 004// ______________________________________________________ 005 006 007package net.gdface.sdk.thrift; 008import java.nio.ByteBuffer; 009import java.util.List; 010import java.util.Map; 011import net.gdface.image.ImageErrorException; 012import net.gdface.image.MatType; 013import net.gdface.sdk.CodeInfo; 014import net.gdface.sdk.CompareResult; 015import net.gdface.sdk.FRect; 016import net.gdface.sdk.FaceApi; 017import net.gdface.sdk.FseResult; 018import net.gdface.sdk.NotFaceDetectedException; 019import net.gdface.thrift.TypeTransformer; 020import net.gdface.thrift.ClientFactory; 021 022import com.facebook.swift.service.RuntimeTApplicationException; 023import com.google.common.net.HostAndPort; 024 025import static com.google.common.base.Preconditions.*; 026 027/** 028 * 基于thrift/swift框架生成的client端代码提供{@link FaceApi}接口的RPC实现(线程安全)<br> 029 * 转发所有{@link FaceApi}接口方法到{@link #delegate()}指定的实例<br> 030 * 所有服务端抛出的{@link RuntimeException}异常被封装到{@link ServiceRuntimeException}中抛出<br> 031 * Example:<br> 032 * <pre> 033 * FaceApiThriftClient thriftInstance = ClientFactory 034 * .builder() 035 * .setHostAndPort("127.0.0.1",26413) 036 * .build(FaceApi.class, FaceApiThriftClient.class); 037 * </pre> 038 * 计算机生成代码(generated by automated tools ThriftServiceDecoratorGenerator @author guyadong)<br> 039 * @author guyadong 040 * 041 */ 042public class FaceApiThriftClient implements FaceApi { 043 private final ClientFactory factory; 044 045 public ClientFactory getFactory() { 046 return factory; 047 } 048 public FaceApiThriftClient(ClientFactory factory) { 049 super(); 050 this.factory = checkNotNull(factory,"factory is null"); 051 } 052 /** 053 * @param host RPC service host 054 * @param port RPC service port 055 */ 056 public FaceApiThriftClient(String host,int port) { 057 this(ClientFactory.builder().setHostAndPort(host,port)); 058 } 059 /** 060 * @param hostAndPort RPC service host and port 061 */ 062 public FaceApiThriftClient(HostAndPort hostAndPort) { 063 this(ClientFactory.builder().setHostAndPort(hostAndPort)); 064 } 065 /** 066 * test if connectable for RPC service 067 * @return return {@code true} if connectable ,otherwise {@code false} 068 */ 069 public boolean testConnect(){ 070 return factory.testConnect(); 071 } 072 073 /** 074 * @return 返回{@link net.gdface.sdk.thrift.client.FaceApi}实例 075 */ 076 protected net.gdface.sdk.thrift.client.FaceApi delegate() { 077 return factory.applyInstance(net.gdface.sdk.thrift.client.FaceApi.class); 078 } 079 @Override 080 public String toString() { 081 StringBuilder builder = new StringBuilder(); 082 builder.append("FaceApiThriftClient [factory="); 083 builder.append(factory); 084 builder.append(",interface="); 085 builder.append(FaceApi.class.getName()); 086 builder.append("]"); 087 return builder.toString(); 088 } 089 @Override 090 public double compare2Face(byte[] imgData1, 091 CodeInfo facePos1, 092 byte[] imgData2, 093 CodeInfo facePos2) 094 throws ImageErrorException,NotFaceDetectedException{ 095 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 096 try{ 097 return instance.compare2Face(imgData1, 098 TypeTransformer.getInstance().to( 099 facePos1, 100 CodeInfo.class, 101 net.gdface.sdk.thrift.client.CodeInfo.class), 102 imgData2, 103 TypeTransformer.getInstance().to( 104 facePos2, 105 CodeInfo.class, 106 net.gdface.sdk.thrift.client.CodeInfo.class)); 107 } 108 catch(net.gdface.sdk.thrift.client.ImageErrorException e){ 109 throw TypeTransformer.getInstance().to( 110 e, 111 net.gdface.sdk.thrift.client.ImageErrorException.class, 112 ImageErrorException.class); 113 } 114 catch(net.gdface.sdk.thrift.client.NotFaceDetectedException e){ 115 throw TypeTransformer.getInstance().to( 116 e, 117 net.gdface.sdk.thrift.client.NotFaceDetectedException.class, 118 NotFaceDetectedException.class); 119 } 120 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 121 throw new ServiceRuntimeException(e); 122 } 123 finally{ 124 factory.releaseInstance(instance); 125 } 126 } 127 @Override 128 public double compareCode(byte[] code1, 129 byte[] code2) 130 { 131 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 132 try{ 133 return instance.compareCode(code1, 134 code2); 135 } 136 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 137 throw new ServiceRuntimeException(e); 138 } 139 finally{ 140 factory.releaseInstance(instance); 141 } 142 } 143 @Override 144 public double[] compareCodes(byte[] code1, 145 CodeInfo[] codes) 146 { 147 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 148 try{ 149 return TypeTransformer.getInstance().todoubleArray( 150 instance.compareCodes(code1, 151 TypeTransformer.getInstance().to( 152 codes, 153 CodeInfo.class, 154 net.gdface.sdk.thrift.client.CodeInfo.class)), 155 double.class, 156 double.class); 157 } 158 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 159 throw new ServiceRuntimeException(e); 160 } 161 catch(RuntimeTApplicationException e){ 162 return net.gdface.thrift.ThriftUtils.returnNull(e); 163 } 164 finally{ 165 factory.releaseInstance(instance); 166 } 167 } 168 @Override 169 public CompareResult compareFaces(byte[] code, 170 byte[] imgData, 171 int faceNum) 172 throws ImageErrorException,NotFaceDetectedException{ 173 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 174 try{ 175 return TypeTransformer.getInstance().to( 176 instance.compareFaces(code, 177 imgData, 178 faceNum), 179 net.gdface.sdk.thrift.client.CompareResult.class, 180 CompareResult.class); 181 } 182 catch(net.gdface.sdk.thrift.client.ImageErrorException e){ 183 throw TypeTransformer.getInstance().to( 184 e, 185 net.gdface.sdk.thrift.client.ImageErrorException.class, 186 ImageErrorException.class); 187 } 188 catch(net.gdface.sdk.thrift.client.NotFaceDetectedException e){ 189 throw TypeTransformer.getInstance().to( 190 e, 191 net.gdface.sdk.thrift.client.NotFaceDetectedException.class, 192 NotFaceDetectedException.class); 193 } 194 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 195 throw new ServiceRuntimeException(e); 196 } 197 catch(RuntimeTApplicationException e){ 198 return net.gdface.thrift.ThriftUtils.returnNull(e); 199 } 200 finally{ 201 factory.releaseInstance(instance); 202 } 203 } 204 @Override 205 public List<Double> compareFeatures(byte[] code1, 206 List<byte[]> codes) 207 { 208 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 209 try{ 210 return TypeTransformer.getInstance().to( 211 instance.compareFeatures(code1, 212 TypeTransformer.getInstance().to( 213 codes, 214 byte[].class, 215 byte[].class)), 216 Double.class, 217 Double.class); 218 } 219 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 220 throw new ServiceRuntimeException(e); 221 } 222 catch(RuntimeTApplicationException e){ 223 return net.gdface.thrift.ThriftUtils.returnNull(e); 224 } 225 finally{ 226 factory.releaseInstance(instance); 227 } 228 } 229 @Override 230 public double detectAndCompare2Face(byte[] imgData1, 231 FRect detectRect1, 232 byte[] imgData2, 233 FRect detectRect2) 234 throws ImageErrorException,NotFaceDetectedException{ 235 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 236 try{ 237 return instance.detectAndCompare2Face(imgData1, 238 TypeTransformer.getInstance().to( 239 detectRect1, 240 FRect.class, 241 net.gdface.sdk.thrift.client.FRect.class), 242 imgData2, 243 TypeTransformer.getInstance().to( 244 detectRect2, 245 FRect.class, 246 net.gdface.sdk.thrift.client.FRect.class)); 247 } 248 catch(net.gdface.sdk.thrift.client.ImageErrorException e){ 249 throw TypeTransformer.getInstance().to( 250 e, 251 net.gdface.sdk.thrift.client.ImageErrorException.class, 252 ImageErrorException.class); 253 } 254 catch(net.gdface.sdk.thrift.client.NotFaceDetectedException e){ 255 throw TypeTransformer.getInstance().to( 256 e, 257 net.gdface.sdk.thrift.client.NotFaceDetectedException.class, 258 NotFaceDetectedException.class); 259 } 260 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 261 throw new ServiceRuntimeException(e); 262 } 263 finally{ 264 factory.releaseInstance(instance); 265 } 266 } 267 @Override 268 public CodeInfo[] detectAndGetCodeInfo(byte[] imgData, 269 int faceNum) 270 throws ImageErrorException,NotFaceDetectedException{ 271 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 272 try{ 273 return TypeTransformer.getInstance().toArray( 274 instance.detectAndGetCodeInfo(imgData, 275 faceNum), 276 net.gdface.sdk.thrift.client.CodeInfo.class, 277 CodeInfo.class); 278 } 279 catch(net.gdface.sdk.thrift.client.ImageErrorException e){ 280 throw TypeTransformer.getInstance().to( 281 e, 282 net.gdface.sdk.thrift.client.ImageErrorException.class, 283 ImageErrorException.class); 284 } 285 catch(net.gdface.sdk.thrift.client.NotFaceDetectedException e){ 286 throw TypeTransformer.getInstance().to( 287 e, 288 net.gdface.sdk.thrift.client.NotFaceDetectedException.class, 289 NotFaceDetectedException.class); 290 } 291 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 292 throw new ServiceRuntimeException(e); 293 } 294 catch(RuntimeTApplicationException e){ 295 return net.gdface.thrift.ThriftUtils.returnNull(e); 296 } 297 finally{ 298 factory.releaseInstance(instance); 299 } 300 } 301 @Override 302 public CodeInfo detectCenterFace(byte[] imgData) 303 throws ImageErrorException,NotFaceDetectedException{ 304 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 305 try{ 306 return TypeTransformer.getInstance().to( 307 instance.detectCenterFace(imgData), 308 net.gdface.sdk.thrift.client.CodeInfo.class, 309 CodeInfo.class); 310 } 311 catch(net.gdface.sdk.thrift.client.ImageErrorException e){ 312 throw TypeTransformer.getInstance().to( 313 e, 314 net.gdface.sdk.thrift.client.ImageErrorException.class, 315 ImageErrorException.class); 316 } 317 catch(net.gdface.sdk.thrift.client.NotFaceDetectedException e){ 318 throw TypeTransformer.getInstance().to( 319 e, 320 net.gdface.sdk.thrift.client.NotFaceDetectedException.class, 321 NotFaceDetectedException.class); 322 } 323 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 324 throw new ServiceRuntimeException(e); 325 } 326 catch(RuntimeTApplicationException e){ 327 return net.gdface.thrift.ThriftUtils.returnNull(e); 328 } 329 finally{ 330 factory.releaseInstance(instance); 331 } 332 } 333 @Override 334 public CodeInfo[] detectFace(byte[] imgData) 335 throws ImageErrorException{ 336 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 337 try{ 338 return TypeTransformer.getInstance().toArray( 339 instance.detectFace(imgData), 340 net.gdface.sdk.thrift.client.CodeInfo.class, 341 CodeInfo.class); 342 } 343 catch(net.gdface.sdk.thrift.client.ImageErrorException e){ 344 throw TypeTransformer.getInstance().to( 345 e, 346 net.gdface.sdk.thrift.client.ImageErrorException.class, 347 ImageErrorException.class); 348 } 349 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 350 throw new ServiceRuntimeException(e); 351 } 352 catch(RuntimeTApplicationException e){ 353 return net.gdface.thrift.ThriftUtils.returnNull(e); 354 } 355 finally{ 356 factory.releaseInstance(instance); 357 } 358 } 359 @Override 360 public CodeInfo detectMaxFace(byte[] imgData) 361 throws ImageErrorException,NotFaceDetectedException{ 362 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 363 try{ 364 return TypeTransformer.getInstance().to( 365 instance.detectMaxFace(imgData), 366 net.gdface.sdk.thrift.client.CodeInfo.class, 367 CodeInfo.class); 368 } 369 catch(net.gdface.sdk.thrift.client.ImageErrorException e){ 370 throw TypeTransformer.getInstance().to( 371 e, 372 net.gdface.sdk.thrift.client.ImageErrorException.class, 373 ImageErrorException.class); 374 } 375 catch(net.gdface.sdk.thrift.client.NotFaceDetectedException e){ 376 throw TypeTransformer.getInstance().to( 377 e, 378 net.gdface.sdk.thrift.client.NotFaceDetectedException.class, 379 NotFaceDetectedException.class); 380 } 381 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 382 throw new ServiceRuntimeException(e); 383 } 384 catch(RuntimeTApplicationException e){ 385 return net.gdface.thrift.ThriftUtils.returnNull(e); 386 } 387 finally{ 388 factory.releaseInstance(instance); 389 } 390 } 391 @Override 392 public CodeInfo[] getCodeInfo(byte[] imgData, 393 int faceNum, 394 CodeInfo[] facePos) 395 throws NotFaceDetectedException{ 396 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 397 try{ 398 return TypeTransformer.getInstance().toArray( 399 instance.getCodeInfo(imgData, 400 faceNum, 401 TypeTransformer.getInstance().to( 402 facePos, 403 CodeInfo.class, 404 net.gdface.sdk.thrift.client.CodeInfo.class)), 405 net.gdface.sdk.thrift.client.CodeInfo.class, 406 CodeInfo.class); 407 } 408 catch(net.gdface.sdk.thrift.client.NotFaceDetectedException e){ 409 throw TypeTransformer.getInstance().to( 410 e, 411 net.gdface.sdk.thrift.client.NotFaceDetectedException.class, 412 NotFaceDetectedException.class); 413 } 414 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 415 throw new ServiceRuntimeException(e); 416 } 417 catch(RuntimeTApplicationException e){ 418 return net.gdface.thrift.ThriftUtils.returnNull(e); 419 } 420 finally{ 421 factory.releaseInstance(instance); 422 } 423 } 424 @Override 425 public CodeInfo getCodeInfo(byte[] imgData, 426 CodeInfo facePos) 427 { 428 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 429 try{ 430 return TypeTransformer.getInstance().to( 431 instance.getCodeInfoSingle(imgData, 432 TypeTransformer.getInstance().to( 433 facePos, 434 CodeInfo.class, 435 net.gdface.sdk.thrift.client.CodeInfo.class)), 436 net.gdface.sdk.thrift.client.CodeInfo.class, 437 CodeInfo.class); 438 } 439 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 440 throw new ServiceRuntimeException(e); 441 } 442 catch(RuntimeTApplicationException e){ 443 return net.gdface.thrift.ThriftUtils.returnNull(e); 444 } 445 finally{ 446 factory.releaseInstance(instance); 447 } 448 } 449 @Override 450 public byte[] getFeature(Map<ByteBuffer, CodeInfo> faces) 451 throws NotFaceDetectedException{ 452 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 453 try{ 454 return instance.getFeature(TypeTransformer.getInstance().to( 455 faces, 456 ByteBuffer.class, 457 CodeInfo.class, 458 byte[].class, 459 net.gdface.sdk.thrift.client.CodeInfo.class)); 460 } 461 catch(net.gdface.sdk.thrift.client.NotFaceDetectedException e){ 462 throw TypeTransformer.getInstance().to( 463 e, 464 net.gdface.sdk.thrift.client.NotFaceDetectedException.class, 465 NotFaceDetectedException.class); 466 } 467 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 468 throw new ServiceRuntimeException(e); 469 } 470 catch(RuntimeTApplicationException e){ 471 return net.gdface.thrift.ThriftUtils.returnNull(e); 472 } 473 finally{ 474 factory.releaseInstance(instance); 475 } 476 } 477 @Override 478 public boolean hasFace(byte[] imgData) 479 throws ImageErrorException{ 480 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 481 try{ 482 return instance.hasFace(imgData); 483 } 484 catch(net.gdface.sdk.thrift.client.ImageErrorException e){ 485 throw TypeTransformer.getInstance().to( 486 e, 487 net.gdface.sdk.thrift.client.ImageErrorException.class, 488 ImageErrorException.class); 489 } 490 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 491 throw new ServiceRuntimeException(e); 492 } 493 finally{ 494 factory.releaseInstance(instance); 495 } 496 } 497 @Override 498 public boolean isLocal(){ 499 return false; 500 } 501 @Override 502 public CodeInfo[] matDetectAndGetCodeInfo(MatType matType, 503 byte[] matData, 504 int width, 505 int height, 506 int faceNum) 507 throws NotFaceDetectedException{ 508 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 509 try{ 510 return TypeTransformer.getInstance().toArray( 511 instance.matDetectAndGetCodeInfo(TypeTransformer.getInstance().to( 512 matType, 513 MatType.class, 514 net.gdface.sdk.thrift.client.MatType.class), 515 matData, 516 width, 517 height, 518 faceNum), 519 net.gdface.sdk.thrift.client.CodeInfo.class, 520 CodeInfo.class); 521 } 522 catch(net.gdface.sdk.thrift.client.NotFaceDetectedException e){ 523 throw TypeTransformer.getInstance().to( 524 e, 525 net.gdface.sdk.thrift.client.NotFaceDetectedException.class, 526 NotFaceDetectedException.class); 527 } 528 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 529 throw new ServiceRuntimeException(e); 530 } 531 catch(RuntimeTApplicationException e){ 532 return net.gdface.thrift.ThriftUtils.returnNull(e); 533 } 534 finally{ 535 factory.releaseInstance(instance); 536 } 537 } 538 @Override 539 public CodeInfo[] matDetectFace(MatType matType, 540 byte[] matData, 541 int width, 542 int height) 543 { 544 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 545 try{ 546 return TypeTransformer.getInstance().toArray( 547 instance.matDetectFace(TypeTransformer.getInstance().to( 548 matType, 549 MatType.class, 550 net.gdface.sdk.thrift.client.MatType.class), 551 matData, 552 width, 553 height), 554 net.gdface.sdk.thrift.client.CodeInfo.class, 555 CodeInfo.class); 556 } 557 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 558 throw new ServiceRuntimeException(e); 559 } 560 catch(RuntimeTApplicationException e){ 561 return net.gdface.thrift.ThriftUtils.returnNull(e); 562 } 563 finally{ 564 factory.releaseInstance(instance); 565 } 566 } 567 @Override 568 public CodeInfo matDetectMaxFace(MatType matType, 569 byte[] matData, 570 int width, 571 int height) 572 throws NotFaceDetectedException{ 573 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 574 try{ 575 return TypeTransformer.getInstance().to( 576 instance.matDetectMaxFace(TypeTransformer.getInstance().to( 577 matType, 578 MatType.class, 579 net.gdface.sdk.thrift.client.MatType.class), 580 matData, 581 width, 582 height), 583 net.gdface.sdk.thrift.client.CodeInfo.class, 584 CodeInfo.class); 585 } 586 catch(net.gdface.sdk.thrift.client.NotFaceDetectedException e){ 587 throw TypeTransformer.getInstance().to( 588 e, 589 net.gdface.sdk.thrift.client.NotFaceDetectedException.class, 590 NotFaceDetectedException.class); 591 } 592 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 593 throw new ServiceRuntimeException(e); 594 } 595 catch(RuntimeTApplicationException e){ 596 return net.gdface.thrift.ThriftUtils.returnNull(e); 597 } 598 finally{ 599 factory.releaseInstance(instance); 600 } 601 } 602 @Override 603 public CodeInfo[] matGetCodeInfo(MatType matType, 604 byte[] matData, 605 int width, 606 int height, 607 int facenum, 608 CodeInfo[] facePos) 609 throws NotFaceDetectedException{ 610 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 611 try{ 612 return TypeTransformer.getInstance().toArray( 613 instance.matGetCodeInfo(TypeTransformer.getInstance().to( 614 matType, 615 MatType.class, 616 net.gdface.sdk.thrift.client.MatType.class), 617 matData, 618 width, 619 height, 620 facenum, 621 TypeTransformer.getInstance().to( 622 facePos, 623 CodeInfo.class, 624 net.gdface.sdk.thrift.client.CodeInfo.class)), 625 net.gdface.sdk.thrift.client.CodeInfo.class, 626 CodeInfo.class); 627 } 628 catch(net.gdface.sdk.thrift.client.NotFaceDetectedException e){ 629 throw TypeTransformer.getInstance().to( 630 e, 631 net.gdface.sdk.thrift.client.NotFaceDetectedException.class, 632 NotFaceDetectedException.class); 633 } 634 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 635 throw new ServiceRuntimeException(e); 636 } 637 catch(RuntimeTApplicationException e){ 638 return net.gdface.thrift.ThriftUtils.returnNull(e); 639 } 640 finally{ 641 factory.releaseInstance(instance); 642 } 643 } 644 @Override 645 public CodeInfo matGetCodeInfo(MatType matType, 646 byte[] matData, 647 int width, 648 int height, 649 CodeInfo facePos) 650 { 651 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 652 try{ 653 return TypeTransformer.getInstance().to( 654 instance.matGetCodeInfoSingle(TypeTransformer.getInstance().to( 655 matType, 656 MatType.class, 657 net.gdface.sdk.thrift.client.MatType.class), 658 matData, 659 width, 660 height, 661 TypeTransformer.getInstance().to( 662 facePos, 663 CodeInfo.class, 664 net.gdface.sdk.thrift.client.CodeInfo.class)), 665 net.gdface.sdk.thrift.client.CodeInfo.class, 666 CodeInfo.class); 667 } 668 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 669 throw new ServiceRuntimeException(e); 670 } 671 catch(RuntimeTApplicationException e){ 672 return net.gdface.thrift.ThriftUtils.returnNull(e); 673 } 674 finally{ 675 factory.releaseInstance(instance); 676 } 677 } 678 @Override 679 public boolean matHasFace(MatType matType, 680 byte[] matData, 681 int width, 682 int height) 683 { 684 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 685 try{ 686 return instance.matHasFace(TypeTransformer.getInstance().to( 687 matType, 688 MatType.class, 689 net.gdface.sdk.thrift.client.MatType.class), 690 matData, 691 width, 692 height); 693 } 694 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 695 throw new ServiceRuntimeException(e); 696 } 697 finally{ 698 factory.releaseInstance(instance); 699 } 700 } 701 @Override 702 public FseResult[] matSearchFaces(MatType matType, 703 byte[] matData, 704 int width, 705 int height, 706 CodeInfo facePos, 707 double similarty, 708 int rows) 709 throws ImageErrorException,NotFaceDetectedException{ 710 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 711 try{ 712 return TypeTransformer.getInstance().toArray( 713 instance.matSearchFaces(TypeTransformer.getInstance().to( 714 matType, 715 MatType.class, 716 net.gdface.sdk.thrift.client.MatType.class), 717 matData, 718 width, 719 height, 720 TypeTransformer.getInstance().to( 721 facePos, 722 CodeInfo.class, 723 net.gdface.sdk.thrift.client.CodeInfo.class), 724 similarty, 725 rows), 726 net.gdface.sdk.thrift.client.FseResult.class, 727 FseResult.class); 728 } 729 catch(net.gdface.sdk.thrift.client.ImageErrorException e){ 730 throw TypeTransformer.getInstance().to( 731 e, 732 net.gdface.sdk.thrift.client.ImageErrorException.class, 733 ImageErrorException.class); 734 } 735 catch(net.gdface.sdk.thrift.client.NotFaceDetectedException e){ 736 throw TypeTransformer.getInstance().to( 737 e, 738 net.gdface.sdk.thrift.client.NotFaceDetectedException.class, 739 NotFaceDetectedException.class); 740 } 741 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 742 throw new ServiceRuntimeException(e); 743 } 744 catch(RuntimeTApplicationException e){ 745 return net.gdface.thrift.ThriftUtils.returnNull(e); 746 } 747 finally{ 748 factory.releaseInstance(instance); 749 } 750 } 751 @Override 752 public Boolean matWearMask(MatType matType, 753 byte[] matData, 754 int width, 755 int height, 756 CodeInfo faceInfo) 757 { 758 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 759 try{ 760 return instance.matWearMask(TypeTransformer.getInstance().to( 761 matType, 762 MatType.class, 763 net.gdface.sdk.thrift.client.MatType.class), 764 matData, 765 width, 766 height, 767 TypeTransformer.getInstance().to( 768 faceInfo, 769 CodeInfo.class, 770 net.gdface.sdk.thrift.client.CodeInfo.class)); 771 } 772 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 773 throw new ServiceRuntimeException(e); 774 } 775 catch(RuntimeTApplicationException e){ 776 return net.gdface.thrift.ThriftUtils.returnNull(e); 777 } 778 finally{ 779 factory.releaseInstance(instance); 780 } 781 } 782 @Override 783 public Map<String, String> sdkCapacity() 784 { 785 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 786 try{ 787 return TypeTransformer.getInstance().to( 788 instance.sdkCapacity(), 789 String.class, 790 String.class, 791 String.class, 792 String.class); 793 } 794 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 795 throw new ServiceRuntimeException(e); 796 } 797 catch(RuntimeTApplicationException e){ 798 return net.gdface.thrift.ThriftUtils.returnNull(e); 799 } 800 finally{ 801 factory.releaseInstance(instance); 802 } 803 } 804 @Override 805 public FseResult[] searchFaces(byte[] imgData, 806 CodeInfo facePos, 807 double similarty, 808 int rows) 809 throws ImageErrorException,NotFaceDetectedException{ 810 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 811 try{ 812 return TypeTransformer.getInstance().toArray( 813 instance.searchFaces(imgData, 814 TypeTransformer.getInstance().to( 815 facePos, 816 CodeInfo.class, 817 net.gdface.sdk.thrift.client.CodeInfo.class), 818 similarty, 819 rows), 820 net.gdface.sdk.thrift.client.FseResult.class, 821 FseResult.class); 822 } 823 catch(net.gdface.sdk.thrift.client.ImageErrorException e){ 824 throw TypeTransformer.getInstance().to( 825 e, 826 net.gdface.sdk.thrift.client.ImageErrorException.class, 827 ImageErrorException.class); 828 } 829 catch(net.gdface.sdk.thrift.client.NotFaceDetectedException e){ 830 throw TypeTransformer.getInstance().to( 831 e, 832 net.gdface.sdk.thrift.client.NotFaceDetectedException.class, 833 NotFaceDetectedException.class); 834 } 835 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 836 throw new ServiceRuntimeException(e); 837 } 838 catch(RuntimeTApplicationException e){ 839 return net.gdface.thrift.ThriftUtils.returnNull(e); 840 } 841 finally{ 842 factory.releaseInstance(instance); 843 } 844 } 845 @Override 846 public FseResult[] searchFeatures(byte[] feature, 847 double similarty, 848 int rows) 849 { 850 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 851 try{ 852 return TypeTransformer.getInstance().toArray( 853 instance.searchFeatures(feature, 854 similarty, 855 rows), 856 net.gdface.sdk.thrift.client.FseResult.class, 857 FseResult.class); 858 } 859 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 860 throw new ServiceRuntimeException(e); 861 } 862 catch(RuntimeTApplicationException e){ 863 return net.gdface.thrift.ThriftUtils.returnNull(e); 864 } 865 finally{ 866 factory.releaseInstance(instance); 867 } 868 } 869 @Override 870 public Boolean wearMask(byte[] imgData, 871 CodeInfo faceInfo) 872 throws ImageErrorException{ 873 net.gdface.sdk.thrift.client.FaceApi instance = delegate(); 874 try{ 875 return instance.wearMask(imgData, 876 TypeTransformer.getInstance().to( 877 faceInfo, 878 CodeInfo.class, 879 net.gdface.sdk.thrift.client.CodeInfo.class)); 880 } 881 catch(net.gdface.sdk.thrift.client.ImageErrorException e){ 882 throw TypeTransformer.getInstance().to( 883 e, 884 net.gdface.sdk.thrift.client.ImageErrorException.class, 885 ImageErrorException.class); 886 } 887 catch(net.gdface.sdk.thrift.client.ServiceRuntimeException e){ 888 throw new ServiceRuntimeException(e); 889 } 890 catch(RuntimeTApplicationException e){ 891 return net.gdface.thrift.ThriftUtils.returnNull(e); 892 } 893 finally{ 894 factory.releaseInstance(instance); 895 } 896 } 897}