SDK for SAP ABAP를 사용한 Amazon Rekognition 예제 - AWS SDK 코드 예제

Doc AWS SDK 예제 GitHub 리포지토리에서 더 많은 SDK 예제를 사용할 수 있습니다. AWS

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

SDK for SAP ABAP를 사용한 Amazon Rekognition 예제

다음 코드 예제에서는 Amazon Rekognition과 함께 AWS SDK for SAP ABAP를 사용하여 작업을 수행하고 일반적인 시나리오를 구현하는 방법을 보여줍니다.

작업은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 개별 서비스 함수를 직접적으로 호출하는 방법을 보여주며 관련 시나리오의 컨텍스트에 맞는 작업을 볼 수 있습니다.

각 예시에는 전체 소스 코드에 대한 링크가 포함되어 있으며, 여기에서 컨텍스트에 맞춰 코드를 설정하고 실행하는 방법에 대한 지침을 찾을 수 있습니다.

주제

작업

다음 코드 예시는 CompareFaces의 사용 방법을 보여줍니다.

자세한 내용은 이미지에 있는 얼굴 비교를 참조하세요.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. " Create S3 object reference for the source image DATA(lo_source_s3obj) = NEW /aws1/cl_reks3object( iv_bucket = iv_source_s3_bucket iv_name = iv_source_s3_key ). " Create source image object DATA(lo_source_image) = NEW /aws1/cl_rekimage( io_s3object = lo_source_s3obj ). " Create S3 object reference for the target image DATA(lo_target_s3obj) = NEW /aws1/cl_reks3object( iv_bucket = iv_target_s3_bucket iv_name = iv_target_s3_key ). " Create target image object DATA(lo_target_image) = NEW /aws1/cl_rekimage( io_s3object = lo_target_s3obj ). " Compare faces oo_result = lo_rek->comparefaces( io_sourceimage = lo_source_image io_targetimage = lo_target_image iv_similaritythreshold = iv_similarity ). DATA(lt_face_matches) = oo_result->get_facematches( ). DATA(lt_unmatched_faces) = oo_result->get_unmatchedfaces( ). " Get counts of matched and unmatched faces DATA(lv_matched_count) = lines( lt_face_matches ). DATA(lv_unmatched_count) = lines( lt_unmatched_faces ). " Output detailed comparison results DATA(lv_message) = |Face comparison completed: | && |{ lv_matched_count } matched face(s), | && |{ lv_unmatched_count } unmatched face(s).|. MESSAGE lv_message TYPE 'I'. CATCH /aws1/cx_rekinvalids3objectex. MESSAGE 'Invalid S3 object.' TYPE 'E'. CATCH /aws1/cx_rekinvalidparameterex. MESSAGE 'Invalid parameter value.' TYPE 'E'. ENDTRY.
  • API 세부 정보는 AWS SDK for SAP ABAP API 참조CompareFaces를 참조하세요.

다음 코드 예시는 CreateCollection의 사용 방법을 보여 줍니다.

자세한 내용은 컬렉션 생성을 참조하세요.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. oo_result = lo_rek->createcollection( iv_collectionid = iv_collection_id ). MESSAGE 'Collection created successfully.' TYPE 'I'. CATCH /aws1/cx_rekresrcalrdyexistsex. MESSAGE 'Collection already exists.' TYPE 'E'. CATCH /aws1/cx_rekinvalidparameterex. MESSAGE 'Invalid parameter value.' TYPE 'E'. ENDTRY.
  • API 세부 정보는 AWS SDK for SAP ABAP API 참조CreateCollection을 참조하세요.

다음 코드 예시는 DeleteCollection의 사용 방법을 보여 줍니다.

자세한 내용은 컬렉션 삭제를 참조하세요.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. lo_rek->deletecollection( iv_collectionid = iv_collection_id ). MESSAGE 'Collection deleted successfully.' TYPE 'I'. CATCH /aws1/cx_rekresourcenotfoundex. MESSAGE 'Collection not found.' TYPE 'E'. CATCH /aws1/cx_rekinvalidparameterex. MESSAGE 'Invalid parameter value.' TYPE 'E'. ENDTRY.
  • API 세부 정보는 AWS SDK for SAP ABAP API 참조DeleteCollection을 참조하세요.

다음 코드 예시는 DeleteFaces의 사용 방법을 보여 줍니다.

자세한 내용은 컬렉션에서 얼굴 삭제를 참조하세요.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. oo_result = lo_rek->deletefaces( iv_collectionid = iv_collection_id it_faceids = it_face_ids ). DATA(lt_deleted_faces) = oo_result->get_deletedfaces( ). DATA(lv_deleted_count) = lines( lt_deleted_faces ). DATA(lv_msg6) = |{ lv_deleted_count } face(s) deleted successfully.|. MESSAGE lv_msg6 TYPE 'I'. CATCH /aws1/cx_rekresourcenotfoundex. MESSAGE 'Collection not found.' TYPE 'E'. CATCH /aws1/cx_rekinvalidparameterex. MESSAGE 'Invalid parameter value.' TYPE 'E'. ENDTRY.
  • API 세부 정보는 AWS SDK for SAP ABAP API 참조DeleteFaces를 참조하세요.

다음 코드 예시는 DescribeCollection의 사용 방법을 보여 줍니다.

자세한 내용은 컬렉션 설명을 참조하세요.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. oo_result = lo_rek->describecollection( iv_collectionid = iv_collection_id ). DATA(lv_face_count) = oo_result->get_facecount( ). DATA(lv_msg) = |Collection described: { lv_face_count } face(s) indexed.|. MESSAGE lv_msg TYPE 'I'. CATCH /aws1/cx_rekresourcenotfoundex. MESSAGE 'Collection not found.' TYPE 'E'. CATCH /aws1/cx_rekinvalidparameterex. MESSAGE 'Invalid parameter value.' TYPE 'E'. ENDTRY.
  • API 세부 정보는 AWS SDK for SAP ABAP API 참조DescribeCollection을 참조하세요.

다음 코드 예시는 DetectFaces의 사용 방법을 보여 줍니다.

자세한 내용은 이미지에서 얼굴 감지를 참조하세요.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. " Create S3 object reference for the image DATA(lo_s3object) = NEW /aws1/cl_reks3object( iv_bucket = iv_s3_bucket iv_name = iv_s3_key ). " Create image object DATA(lo_image) = NEW /aws1/cl_rekimage( io_s3object = lo_s3object ). " Detect faces in the image with all attributes DATA(lt_attributes) = VALUE /aws1/cl_rekattributes_w=>tt_attributes( ). DATA(lo_attr_wrapper) = NEW /aws1/cl_rekattributes_w( iv_value = 'ALL' ). INSERT lo_attr_wrapper INTO TABLE lt_attributes. oo_result = lo_rek->detectfaces( io_image = lo_image it_attributes = lt_attributes ). DATA(lt_face_details) = oo_result->get_facedetails( ). DATA(lv_detected_count) = lines( lt_face_details ). DATA(lv_msg8) = |{ lv_detected_count } face(s) detected in image.|. MESSAGE lv_msg8 TYPE 'I'. CATCH /aws1/cx_rekinvalids3objectex. MESSAGE 'Invalid S3 object.' TYPE 'E'. CATCH /aws1/cx_rekinvalidparameterex. MESSAGE 'Invalid parameter value.' TYPE 'E'. ENDTRY.
  • API 세부 정보는 AWS SDK for SAP ABAP API 참조의 DetectFaces를 참조하세요.

다음 코드 예시는 DetectLabels의 사용 방법을 보여 줍니다.

자세한 내용은 이미지에서 레이블 감지를 참조하세요.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. " Create S3 object reference for the image DATA(lo_s3object) = NEW /aws1/cl_reks3object( iv_bucket = iv_s3_bucket iv_name = iv_s3_key ). " Create image object DATA(lo_image) = NEW /aws1/cl_rekimage( io_s3object = lo_s3object ). " Detect labels in the image oo_result = lo_rek->detectlabels( io_image = lo_image iv_maxlabels = iv_max_labels ). DATA(lt_labels) = oo_result->get_labels( ). DATA(lv_label_count) = lines( lt_labels ). DATA(lv_msg9) = |{ lv_label_count } label(s) detected in image.|. MESSAGE lv_msg9 TYPE 'I'. CATCH /aws1/cx_rekinvalids3objectex. MESSAGE 'Invalid S3 object.' TYPE 'E'. CATCH /aws1/cx_rekinvalidparameterex. MESSAGE 'Invalid parameter value.' TYPE 'E'. ENDTRY.
  • API 세부 정보는 AWS SDK for SAP ABAP API 참조의 DetectLabels를 참조하세요.

다음 코드 예시는 DetectModerationLabels의 사용 방법을 보여 줍니다.

자세한 내용은 부적절한 이미지 감지를 참조하세요.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. " Create S3 object reference for the image DATA(lo_s3object) = NEW /aws1/cl_reks3object( iv_bucket = iv_s3_bucket iv_name = iv_s3_key ). " Create image object DATA(lo_image) = NEW /aws1/cl_rekimage( io_s3object = lo_s3object ). " Detect moderation labels oo_result = lo_rek->detectmoderationlabels( io_image = lo_image ). DATA(lt_moderation_labels) = oo_result->get_moderationlabels( ). DATA(lv_mod_count) = lines( lt_moderation_labels ). DATA(lv_msg10) = |{ lv_mod_count } moderation label(s) detected.|. MESSAGE lv_msg10 TYPE 'I'. CATCH /aws1/cx_rekinvalids3objectex. MESSAGE 'Invalid S3 object.' TYPE 'E'. CATCH /aws1/cx_rekinvalidparameterex. MESSAGE 'Invalid parameter value.' TYPE 'E'. ENDTRY.

다음 코드 예시는 DetectText의 사용 방법을 보여 줍니다.

자세한 내용은 이미지에서 텍스트 감지를 참조하세요.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. " Create S3 object reference for the image DATA(lo_s3object) = NEW /aws1/cl_reks3object( iv_bucket = iv_s3_bucket iv_name = iv_s3_key ). " Create image object DATA(lo_image) = NEW /aws1/cl_rekimage( io_s3object = lo_s3object ). " Detect text in the image oo_result = lo_rek->detecttext( io_image = lo_image ). DATA(lt_text_detections) = oo_result->get_textdetections( ). DATA(lv_text_count) = lines( lt_text_detections ). DATA(lv_msg11) = |{ lv_text_count } text detection(s) found.|. MESSAGE lv_msg11 TYPE 'I'. CATCH /aws1/cx_rekinvalids3objectex. MESSAGE 'Invalid S3 object.' TYPE 'E'. CATCH /aws1/cx_rekinvalidparameterex. MESSAGE 'Invalid parameter value.' TYPE 'E'. ENDTRY.
  • API 세부 정보는 AWS SDK for SAP ABAP API 참조의 DetectText를 참조하세요.

다음 코드 예시는 IndexFaces의 사용 방법을 보여 줍니다.

자세한 내용은 컬렉션에 얼굴 추가를 참조하세요.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. " Create S3 object reference for the image DATA(lo_s3object) = NEW /aws1/cl_reks3object( iv_bucket = iv_s3_bucket iv_name = iv_s3_key ). " Create image object DATA(lo_image) = NEW /aws1/cl_rekimage( io_s3object = lo_s3object ). " Index faces in the image oo_result = lo_rek->indexfaces( iv_collectionid = iv_collection_id io_image = lo_image iv_externalimageid = iv_external_id iv_maxfaces = iv_max_faces ). DATA(lt_face_records) = oo_result->get_facerecords( ). DATA(lv_indexed_count) = lines( lt_face_records ). DATA(lv_msg2) = |{ lv_indexed_count } face(s) indexed successfully.|. MESSAGE lv_msg2 TYPE 'I'. CATCH /aws1/cx_rekresourcenotfoundex. MESSAGE 'Collection not found.' TYPE 'E'. CATCH /aws1/cx_rekinvalids3objectex. MESSAGE 'Invalid S3 object.' TYPE 'E'. CATCH /aws1/cx_rekinvalidparameterex. MESSAGE 'Invalid parameter value.' TYPE 'E'. ENDTRY.
  • API 세부 정보는 SDK for SAP ABAP API 참조의 IndexFaces를 참조하세요. AWS

다음 코드 예시는 ListCollections의 사용 방법을 보여 줍니다.

자세한 내용은 컬렉션 나열을 참조하세요.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. oo_result = lo_rek->listcollections( iv_maxresults = iv_max_results ). DATA(lt_collection_ids) = oo_result->get_collectionids( ). DATA(lv_coll_count) = lines( lt_collection_ids ). DATA(lv_msg7) = |{ lv_coll_count } collection(s) found.|. MESSAGE lv_msg7 TYPE 'I'. CATCH /aws1/cx_rekinvalidparameterex. MESSAGE 'Invalid parameter value.' TYPE 'E'. ENDTRY.
  • API 세부 정보는 AWS SDK for SAP ABAP API 참조ListCollections를 참조하세요.

다음 코드 예시는 ListFaces의 사용 방법을 보여 줍니다.

자세한 내용은 컬렉션 내 얼굴 나열을 참조하세요.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. oo_result = lo_rek->listfaces( iv_collectionid = iv_collection_id iv_maxresults = iv_max_results ). DATA(lt_faces) = oo_result->get_faces( ). DATA(lv_face_count2) = lines( lt_faces ). DATA(lv_msg3) = |{ lv_face_count2 } face(s) found in collection.|. MESSAGE lv_msg3 TYPE 'I'. CATCH /aws1/cx_rekresourcenotfoundex. MESSAGE 'Collection not found.' TYPE 'E'. CATCH /aws1/cx_rekinvalidparameterex. MESSAGE 'Invalid parameter value.' TYPE 'E'. ENDTRY.
  • API 세부 정보는 AWS SDK for SAP ABAP API 참조ListFaces를 참조하세요.

다음 코드 예시는 RecognizeCelebrities의 사용 방법을 보여 줍니다.

자세한 내용은 이미지에서 유명인 인식을 참조하세요.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. " Create S3 object reference for the image DATA(lo_s3object) = NEW /aws1/cl_reks3object( iv_bucket = iv_s3_bucket iv_name = iv_s3_key ). " Create image object DATA(lo_image) = NEW /aws1/cl_rekimage( io_s3object = lo_s3object ). " Recognize celebrities oo_result = lo_rek->recognizecelebrities( io_image = lo_image ). DATA(lt_celebrity_faces) = oo_result->get_celebrityfaces( ). DATA(lv_celeb_count) = lines( lt_celebrity_faces ). DATA(lv_msg12) = |{ lv_celeb_count } celebrity/celebrities recognized.|. MESSAGE lv_msg12 TYPE 'I'. CATCH /aws1/cx_rekinvalids3objectex. MESSAGE 'Invalid S3 object.' TYPE 'E'. CATCH /aws1/cx_rekinvalidparameterex. MESSAGE 'Invalid parameter value.' TYPE 'E'. ENDTRY.

다음 코드 예시는 SearchFaces의 사용 방법을 보여 줍니다.

자세한 내용은 얼굴 검색(얼굴 ID)을 참조하세요.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. oo_result = lo_rek->searchfaces( iv_collectionid = iv_collection_id iv_faceid = iv_face_id iv_facematchthreshold = iv_threshold iv_maxfaces = iv_max_faces ). DATA(lt_face_matches) = oo_result->get_facematches( ). DATA(lv_match_count2) = lines( lt_face_matches ). DATA(lv_msg5) = |Face search completed: { lv_match_count2 } match(es) found.|. MESSAGE lv_msg5 TYPE 'I'. CATCH /aws1/cx_rekresourcenotfoundex. MESSAGE 'Collection or face not found.' TYPE 'E'. CATCH /aws1/cx_rekinvalidparameterex. MESSAGE 'Invalid parameter value.' TYPE 'E'. ENDTRY.
  • API 세부 정보는 AWS SDK for SAP ABAP API 참조SearchFaces를 참조하세요.

다음 코드 예시는 SearchFacesByImage의 사용 방법을 보여 줍니다.

자세한 내용은 얼굴 검색(이미지)을 참조하세요.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. " Create S3 object reference for the image DATA(lo_s3object) = NEW /aws1/cl_reks3object( iv_bucket = iv_s3_bucket iv_name = iv_s3_key ). " Create image object DATA(lo_image) = NEW /aws1/cl_rekimage( io_s3object = lo_s3object ). " Search for matching faces oo_result = lo_rek->searchfacesbyimage( iv_collectionid = iv_collection_id io_image = lo_image iv_facematchthreshold = iv_threshold iv_maxfaces = iv_max_faces ). DATA(lt_face_matches) = oo_result->get_facematches( ). DATA(lv_match_count) = lines( lt_face_matches ). DATA(lv_msg4) = |Face search completed: { lv_match_count } match(es) found.|. MESSAGE lv_msg4 TYPE 'I'. CATCH /aws1/cx_rekresourcenotfoundex. MESSAGE 'Collection not found.' TYPE 'E'. CATCH /aws1/cx_rekinvalids3objectex. MESSAGE 'Invalid S3 object.' TYPE 'E'. CATCH /aws1/cx_rekinvalidparameterex. MESSAGE 'Invalid parameter value.' TYPE 'E'. ENDTRY.
  • API 세부 정보는 SDK for SAP ABAP API 참조의 SearchFacesByImage를 참조하세요. AWS