Demo Project of Dark Enhance
Two authentication methods, token authentication and AK/SK authentication, are available. This section uses AK/SK authentication as an example.
This demo project corresponds to the POST /v1.0/vision/dark-enhance URI. Replace the AK/SK information with the actual AK/SK to run the demo.
- Configure the AK/SK in the DarkEnhanceDemo.java file. The sample code is as follows:
// 1. Configure the basic information for accessing Dark Enhance and generate a client connection object. AisAccess service = ServiceAccessBuilder.builder() .ak("######") // your ak .sk("######") // your sk .region("cn-north-1") // Configuration of Image Recognition in the CN North-Beijing1 region .connectionTimeout(5000) // Timeout limit for connecting to the target URL .connectionRequestTimeout(1000) // Timeout limit for obtaining available connections from the connection pool .socketTimeout(20000) // Timeout limit for obtaining server response data .build(); - Select a local image or use the default image of the sample project, and modify the original image path (data/dark-enhance-demo-1.bmp) and the path for saving the image generated after processing (data/dark-enhance-demo-1.cooked.bmp) in the DarkEnhanceDemo.java file.
// // 2. Construct the parameters required for accessing Dark Enhance. // String uri = "/v1.0/vision/dark-enhance"; byte[] fileData = FileUtils.readFileToByteArray(new File("data/dark-enhance-demo-1.bmp")); String fileBase64Str = Base64.encodeBase64String(fileData); JSONObject json = new JSONObject(); json.put("image", fileBase64Str); json.put("brightness", 0.9); // 3. Pass the URI and required parameters of Dark Enhance. // Pass the parameters in JSON objects and call the service using POST. HttpResponse response = service.post(uri, json.toJSONString()); // 4. Check whether the API call is successful. If 200 is returned, the API call succeeds. Otherwise, it fails. ResponseProcessUtils.processResponseStatus(response); // 5. Process the character stream returned by the service and create the image file processed by Dark Enhance. ResponseProcessUtils.processResponseWithImage(response, "data/dark-enhance-demo-1.cooked.bmp"); - Execute the DarkEnhanceDemo.java file to output the recognition result to the console. If 200 is displayed on the console, the program is successfully executed. Figure 1 shows the original image and enhanced image.
Last Article: Demo Project of Recapture Detection
Next Article: Demo Project of Defog

Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.