Halaman ini belum tersedia dalam bahasa lokal Anda. Kami berusaha keras untuk menambahkan lebih banyak versi bahasa. Terima kasih atas dukungan Anda.
Face Recognition Service
Face Recognition Service
- What's New
- Service Overview
- Getting Started
- SDK Reference
- API Reference
-
FAQs
-
General Consulting
- How Can Multiple Faces Be Recognized in an Image with Multiple Faces?
- Can Certificate Photos Be Used for Facial Recognition?
- How Do I Deal with Unauthorization Issues?
- Why Do Recognition Errors Occur?
- What Causes the Low Pass Rate in Face Recognition?
- Why Is the Request Response so Slow?
- What Is the Limit for Free Calls to the Face Detection API?
- How Do I Disable a Service?
- Are There SDKs Available for Mobile Phones (Android and iOS) in FRS?
-
APIs
- How Can I Use FRS APIs?
- What Do I Do If Error FRS.0022 Is Reported When Images Are Accessed on OBS?
- How Do I Obtain the Correct Endpoint?
- How Do I Obtain the Base64 Code of an Image?
- How Do I Set the top_n Parameter in the Face Retrieval API?
- Why Is the Data Returned by FRS Empty?
- What Is the Minimum Bandwidth Needed for FRS?
- How Do I Obtain the URL of the Most Recent Image in an OBS Bucket?
- Can I Query Facial Images Uploaded for Face Recognition?
- Error Codes
- Region and AZ FAQs
- Permissions
- Data Security
-
General Consulting
- Glossary
- General Reference
On this page
Show all
Copied.
SDK API Example
SDK API Example
- Construct a service client.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
String ak = System.getenv("HUAWEICLOUD_SDK_AK"); String sk = System.getenv("HUAWEICLOUD_SDK_SK"); String projectId = "projectId"; //Proxy information. If you need to use a proxy to access the service, add the proxy information here. ProxyHostInfo proxyHostInfo = new ProxyHostInfo("proxy", 8080, "UserName", "Password" ); //Service info String url = "https://face.ap-southeast-1.myhuaweicloud.com"; String region = "ap-southeast-1"; AuthInfo authInfo = new AuthInfo(url, region, ak, sk); FrsClient frsClient = new FrsClient(authInfo, projectId); //FrsClient frsClient = new FrsClient(authInfo, projectId, proxyHostInfo);//If you need to use a proxy to access the service, add the proxy information to the third parameter.
- Create a face set.
1 2 3
CreateExternalFields createExternalFields = new CreateExternalFields(); createExternalFields.addField("testInteger", FieldType.INTEGER); CreateFaceSetResult createFaceSetResult = frsClient.getV2().getFaceSetService().createFaceSet(faceSetName, faceSetCapacity, createExternalFields);
- Add faces.
1 2 3 4 5 6 7
String imageId = "image1"; File image = new File("data/face.jpg"); byte[] fileData = FileUtils.readFileToByteArray(image); String imageBase64 = Base64.encodeBase64String(fileData); AddExternalFields addExternalFields = new AddExternalFields(); addExternalFields.addField("testInteger", 123); AddFaceResult addFaceResult = frsClient.getV2().getFaceService().addFaceByBase64(faceSetName, imageId, imageBase64, addExternalFields);
- Invoke the Face Detection service.
1 2 3
String obsUrl = "/bucket/face.jpg"; String attr = "1,2"; DetectFaceResult detectFaceResult = frsClient.getV2().getDetectService().detectFaceByObsUrl(obsUrl, attr);
NOTE:
In the preceding example, ak and sk indicate the access keys. To obtain the AK/SK, log in to the My Credentials page, choose Access Keys, and click Add Access Key.
projectId: Project ID. For details about how to obtain a project ID, see Obtaining a Project ID.
Parent topic: Java SDK
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot