Amazon Rekognition을 사용하는 코드 예제 AWS SDKs - Amazon Rekognition

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

Amazon Rekognition을 사용하는 코드 예제 AWS SDKs

다음 코드 예제는 Amazon Rekognition을 다음과 함께 사용하는 방법을 보여줍니다. AWS 소프트웨어 개발 키트 (). SDK 이 장의 코드 예제는 이 가이드의 나머지 부분에 있는 코드 예제를 보완하기 위한 것입니다.

기본 사항은 서비스 내에서 필수 작업을 수행하는 방법을 보여주는 코드 예제입니다.

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

시나리오는 서비스 내에서 여러 함수를 호출하거나 다른 함수와 결합하여 특정 작업을 수행하는 방법을 보여주는 코드 예제입니다. AWS 서비스.

전체 목록은 다음과 같습니다. AWS SDK개발자 가이드 및 코드 예제는 을 참조하십시오Rekognition과 함께 사용하기 AWS SDK. 이 항목에는 시작에 대한 정보와 이전 SDK 버전에 대한 세부 정보도 포함되어 있습니다.

시작하기

다음 코드 예제는 Amazon Rekognition을 사용하여 시작하는 방법을 보여줍니다.

C++
SDKC++의 경우
참고

더 많은 정보가 있습니다. GitHub 전체 예제를 찾아 설치 및 실행 방법을 알아보십시오. AWS 코드 예제 리포지토리.

CMakeLists.txt CMake 파일의 코드입니다.

# Set the minimum required version of CMake for this project. cmake_minimum_required(VERSION 3.13) # Set the AWS service components used by this project. set(SERVICE_COMPONENTS rekognition) # Set this project's name. project("hello_rekognition") # Set the C++ standard to use to build this target. # At least C++ 11 is required for the AWS SDK for C++. set(CMAKE_CXX_STANDARD 11) # Use the MSVC variable to determine if this is a Windows build. set(WINDOWS_BUILD ${MSVC}) if (WINDOWS_BUILD) # Set the location where CMake can find the installed libraries for the AWS SDK. string(REPLACE ";" "/aws-cpp-sdk-all;" SYSTEM_MODULE_PATH "${CMAKE_SYSTEM_PREFIX_PATH}/aws-cpp-sdk-all") list(APPEND CMAKE_PREFIX_PATH ${SYSTEM_MODULE_PATH}) endif () # Find the AWS SDK for C++ package. find_package(AWSSDK REQUIRED COMPONENTS ${SERVICE_COMPONENTS}) if (WINDOWS_BUILD AND AWSSDK_INSTALL_AS_SHARED_LIBS) # Copy relevant AWS SDK for C++ libraries into the current binary directory for running and debugging. # set(BIN_SUB_DIR "/Debug") # If you are building from the command line, you may need to uncomment this # and set the proper subdirectory to the executables' location. AWSSDK_CPY_DYN_LIBS(SERVICE_COMPONENTS "" ${CMAKE_CURRENT_BINARY_DIR}${BIN_SUB_DIR}) endif () add_executable(${PROJECT_NAME} hello_rekognition.cpp) target_link_libraries(${PROJECT_NAME} ${AWSSDK_LINK_LIBRARIES})

hello_rekognition.cpp 소스 파일의 코드입니다.

#include <aws/core/Aws.h> #include <aws/rekognition/RekognitionClient.h> #include <aws/rekognition/model/ListCollectionsRequest.h> #include <iostream> /* * A "Hello Rekognition" starter application which initializes an Amazon Rekognition client and * lists the Amazon Rekognition collections in the current account and region. * * main function * * Usage: 'hello_rekognition' * */ int main(int argc, char **argv) { Aws::SDKOptions options; // Optional: change the log level for debugging. // options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug; Aws::InitAPI(options); // Should only be called once. { Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; Aws::Rekognition::RekognitionClient rekognitionClient(clientConfig); Aws::Rekognition::Model::ListCollectionsRequest request; Aws::Rekognition::Model::ListCollectionsOutcome outcome = rekognitionClient.ListCollections(request); if (outcome.IsSuccess()) { const Aws::Vector<Aws::String>& collectionsIds = outcome.GetResult().GetCollectionIds(); if (!collectionsIds.empty()) { std::cout << "collectionsIds: " << std::endl; for (auto &collectionId : collectionsIds) { std::cout << "- " << collectionId << std::endl; } } else { std::cout << "No collections found" << std::endl; } } else { std::cerr << "Error with ListCollections: " << outcome.GetError() << std::endl; } } Aws::ShutdownAPI(options); // Should only be called once. return 0; }
  • 자세한 API 내용은 ListCollections을 참조하십시오. AWS SDK for C++ API참조.