Esempio n. 1
0
        private static void DistortionCorrect(String token, String endpoint)
        {
            // The obs url of file
            String dataUrl = "";
            // Whether to correct distortion or not
            bool correction = false;

            // post data by native file
            String  data     = utils.ConvertFileToBase64("../../data/modeation-distortion.jpg");
            String  reslut   = Moderation.DistortionCorrectToken(token, data, dataUrl, correction, endpoint);
            JObject joResult = (JObject)JsonConvert.DeserializeObject(reslut);

            if (joResult["result"]["data"].ToString() != "")
            {
                String resultPath = @"../../data/modeation-distortion-token-1.bmp";
                resultPath = utils.Base64ToFileAndSave(joResult["result"]["data"].ToString(), resultPath);
                Console.WriteLine(resultPath);
            }
            else
            {
                Console.WriteLine(reslut);
            }

            // The OBS link must match the region, and the OBS resources of different regions are not shared
            dataUrl = "https://ais-sample-data.obs.cn-north-1.myhuaweicloud.com/vat-invoice.jpg";

            // post data by obs url
            reslut   = Moderation.DistortionCorrectToken(token, "", dataUrl, correction, endpoint);
            joResult = (JObject)JsonConvert.DeserializeObject(reslut);
            if (joResult["result"]["data"].ToString() != "")
            {
                String resultPath = @"../../data/modeation-distortion-token-2.bmp";
                resultPath = utils.Base64ToFileAndSave(joResult["result"]["data"].ToString(), resultPath);
                Console.WriteLine(resultPath);
            }
            else
            {
                Console.WriteLine(reslut);
            }
            Console.ReadKey();
        }