예제 #1
0
 def detect_vehicle_advance(self, request, runtime):
     # Step 0: init client
     access_key_id = self._credential.get_access_key_id()
     access_key_secret = self._credential.get_access_key_secret()
     auth_config = rpc_models.Config(access_key_id=access_key_id,
                                     access_key_secret=access_key_secret,
                                     type='access_key',
                                     endpoint='openplatform.aliyuncs.com',
                                     protocol=self._protocol,
                                     region_id=self._region_id)
     auth_client = OpenPlatformClient(auth_config)
     auth_request = open_platform_models.AuthorizeFileUploadRequest(
         product='objectdet', region_id=self._region_id)
     auth_response = open_platform_models.AuthorizeFileUploadResponse()
     oss_config = oss_models.Config(access_key_secret=access_key_secret,
                                    type='access_key',
                                    protocol=self._protocol,
                                    region_id=self._region_id)
     oss_client = None
     file_obj = file_form_models.FileField()
     oss_header = oss_models.PostObjectRequestHeader()
     upload_request = oss_models.PostObjectRequest()
     oss_runtime = ossutil_models.RuntimeOptions()
     OpenApiUtilClient.convert(runtime, oss_runtime)
     detect_vehicle_req = objectdet_20191230_models.DetectVehicleRequest()
     OpenApiUtilClient.convert(request, detect_vehicle_req)
     auth_response = auth_client.authorize_file_upload_with_options(
         auth_request, runtime)
     oss_config.access_key_id = auth_response.access_key_id
     oss_config.endpoint = OpenApiUtilClient.get_endpoint(
         auth_response.endpoint, auth_response.use_accelerate,
         self._endpoint_type)
     oss_client = OSSClient(oss_config)
     file_obj = file_form_models.FileField(
         filename=auth_response.object_key,
         content=request.image_urlobject,
         content_type='')
     oss_header = oss_models.PostObjectRequestHeader(
         access_key_id=auth_response.access_key_id,
         policy=auth_response.encoded_policy,
         signature=auth_response.signature,
         key=auth_response.object_key,
         file=file_obj,
         success_action_status='201')
     upload_request = oss_models.PostObjectRequest(
         bucket_name=auth_response.bucket, header=oss_header)
     oss_client.post_object(upload_request, oss_runtime)
     detect_vehicle_req.image_url = 'http://%s.%s/%s' % (
         TeaConverter.to_unicode(auth_response.bucket),
         TeaConverter.to_unicode(auth_response.endpoint),
         TeaConverter.to_unicode(auth_response.object_key))
     detect_vehicle_resp = self.detect_vehicle_with_options(
         detect_vehicle_req, runtime)
     return detect_vehicle_resp
예제 #2
0
 def classify_fnfadvance(self, request, runtime):
     # Step 0: init client
     access_key_id = self._credential.get_access_key_id()
     access_key_secret = self._credential.get_access_key_secret()
     auth_config = rpc_models.Config(access_key_id=access_key_id,
                                     access_key_secret=access_key_secret,
                                     type="access_key",
                                     endpoint="openplatform.aliyuncs.com",
                                     protocol=self._protocol,
                                     region_id=self._region_id)
     auth_client = OpenPlatformClient(auth_config)
     auth_request = open_platform_models.AuthorizeFileUploadRequest(
         product="imageprocess", region_id=self._region_id)
     auth_response = open_platform_models.AuthorizeFileUploadResponse()
     oss_config = oss_models.Config(access_key_secret=access_key_secret,
                                    type="access_key",
                                    protocol=self._protocol,
                                    region_id=self._region_id)
     oss_client = None
     file_obj = file_form_models.FileField()
     oss_header = oss_models.PostObjectRequestHeader()
     upload_request = oss_models.PostObjectRequest()
     oss_runtime = ossutil_models.RuntimeOptions()
     RPCUtilClient.convert(runtime, oss_runtime)
     classify_fnfreq = imageprocess_20200320_models.ClassifyFNFRequest()
     RPCUtilClient.convert(request, classify_fnfreq)
     auth_response = auth_client.authorize_file_upload_with_options(
         auth_request, runtime)
     oss_config.access_key_id = auth_response.access_key_id
     oss_config.endpoint = RPCUtilClient.get_endpoint(
         auth_response.endpoint, auth_response.use_accelerate,
         self._endpoint_type)
     oss_client = OSSClient(oss_config)
     file_obj = file_form_models.FileField(
         filename=auth_response.object_key,
         content=request.image_url_object,
         content_type="")
     oss_header = oss_models.PostObjectRequestHeader(
         access_key_id=auth_response.access_key_id,
         policy=auth_response.encoded_policy,
         signature=auth_response.signature,
         key=auth_response.object_key,
         file=file_obj,
         success_action_status="201")
     upload_request = oss_models.PostObjectRequest(
         bucket_name=auth_response.bucket, header=oss_header)
     oss_client.post_object(upload_request, oss_runtime)
     classify_fnfreq.image_url = "http://" + str(
         auth_response.bucket) + "." + str(
             auth_response.endpoint) + "/" + str(
                 auth_response.object_key) + ""
     classify_fnfresp = self.classify_fnf(classify_fnfreq, runtime)
     return classify_fnfresp
예제 #3
0
    def segment_video_body_advance(self, request, runtime):
        # Step 0: init client
        access_key_id = self._credential.get_access_key_id()
        access_key_secret = self._credential.get_access_key_secret()
        auth_config = _rpc_models.Config(
            access_key_id=access_key_id,
            access_key_secret=access_key_secret,
            type="access_key",
            endpoint="openplatform.aliyuncs.com",
            protocol=self._protocol,
            region_id=self._region_id
        )
        auth_client = OpenPlatformClient(auth_config)
        auth_request = open_platform_models.AuthorizeFileUploadRequest(
            product="videoseg",
            region_id=self._region_id
        )
        auth_response = auth_client.authorize_file_upload_with_options(auth_request, runtime)
        # Step 1: request OSS api to upload file
        oss_config = _oss_models.Config(
            access_key_id=auth_response.access_key_id,
            access_key_secret=access_key_secret,
            type="access_key",
            endpoint=RPCUtilClient.get_endpoint(auth_response.endpoint, auth_response.use_accelerate, self._endpoint_type),
            protocol=self._protocol,
            region_id=self._region_id
        )
        oss_client = OSSClient(oss_config)
        file_obj = file_form_models.FileField(
            filename=auth_response.object_key,
            content=request.video_url_object,
            content_type=""
        )
        oss_header = _oss_models.PostObjectRequestHeader(
            access_key_id=auth_response.access_key_id,
            policy=auth_response.encoded_policy,
            signature=auth_response.signature,
            key=auth_response.object_key,
            file=file_obj,
            success_action_status="201"
        )
        upload_request = _oss_models.PostObjectRequest(
            bucket_name=auth_response.bucket,
            header=oss_header
        )
        oss_runtime = ossutil_models.RuntimeOptions(

        )
        RPCUtilClient.convert(runtime, oss_runtime)
        oss_client.post_object(upload_request, oss_runtime)
        # Step 2: request final api
        segment_video_bodyreq = videoseg_20200320_models.SegmentVideoBodyRequest(

        )
        RPCUtilClient.convert(request, segment_video_bodyreq)
        segment_video_bodyreq.video_url = "http://" + str(auth_response.bucket) + "." + str(auth_response.endpoint) + "/" + str(auth_response.object_key) + ""
        segment_video_body_resp = self.segment_video_body(segment_video_bodyreq, runtime)
        return segment_video_body_resp
예제 #4
0
 def image_blind_pic_watermark_advance(self, request, runtime):
     # Step 0: init client
     access_key_id = self._credential.get_access_key_id()
     access_key_secret = self._credential.get_access_key_secret()
     auth_config = _rpc_models.Config(access_key_id=access_key_id,
                                      access_key_secret=access_key_secret,
                                      type="access_key",
                                      endpoint="openplatform.aliyuncs.com",
                                      protocol=self._protocol,
                                      region_id=self._region_id)
     auth_client = OpenPlatformClient(auth_config)
     auth_request = open_platform_models.AuthorizeFileUploadRequest(
         product="imageenhan", region_id=self._region_id)
     auth_response = auth_client.authorize_file_upload_with_options(
         auth_request, runtime)
     # Step 1: request OSS api to upload file
     oss_config = _oss_models.Config(
         access_key_id=auth_response.access_key_id,
         access_key_secret=access_key_secret,
         type="access_key",
         endpoint=RPCUtilClient.get_endpoint(auth_response.endpoint,
                                             auth_response.use_accelerate,
                                             self._endpoint_type),
         protocol=self._protocol,
         region_id=self._region_id)
     oss_client = OSSClient(oss_config)
     file_obj = file_form_models.FileField(
         filename=auth_response.object_key,
         content=request.origin_image_urlobject,
         content_type="")
     oss_header = _oss_models.PostObjectRequestHeader(
         access_key_id=auth_response.access_key_id,
         policy=auth_response.encoded_policy,
         signature=auth_response.signature,
         key=auth_response.object_key,
         file=file_obj,
         success_action_status="201")
     upload_request = _oss_models.PostObjectRequest(
         bucket_name=auth_response.bucket, header=oss_header)
     oss_runtime = ossutil_models.RuntimeOptions()
     RPCUtilClient.convert(runtime, oss_runtime)
     oss_client.post_object(upload_request, oss_runtime)
     # Step 2: request final api
     image_blind_pic_watermarkreq = imageenhan_20190930_models.ImageBlindPicWatermarkRequest(
     )
     RPCUtilClient.convert(request, image_blind_pic_watermarkreq)
     image_blind_pic_watermarkreq.origin_image_url = "http://" + str(
         auth_response.bucket) + "." + str(
             auth_response.endpoint) + "/" + str(
                 auth_response.object_key) + ""
     image_blind_pic_watermark_resp = self.image_blind_pic_watermark(
         image_blind_pic_watermarkreq, runtime)
     return image_blind_pic_watermark_resp
예제 #5
0
 def liveness_detect_advance(self, request, runtime):
     # Step 0: init client
     access_key_id = self._credential.get_access_key_id()
     access_key_secret = self._credential.get_access_key_secret()
     security_token = self._credential.get_security_token()
     credential_type = self._credential.get_type()
     open_platform_endpoint = self._open_platform_endpoint
     if UtilClient.is_unset(open_platform_endpoint):
         open_platform_endpoint = 'openplatform.aliyuncs.com'
     if UtilClient.is_unset(credential_type):
         credential_type = 'access_key'
     auth_config = rpc_models.Config(access_key_id=access_key_id,
                                     access_key_secret=access_key_secret,
                                     security_token=security_token,
                                     type=credential_type,
                                     endpoint=open_platform_endpoint,
                                     protocol=self._protocol,
                                     region_id=self._region_id)
     auth_client = OpenPlatformClient(auth_config)
     auth_request = open_platform_models.AuthorizeFileUploadRequest(
         product='Cloudauth', region_id=self._region_id)
     auth_response = open_platform_models.AuthorizeFileUploadResponse()
     oss_config = oss_models.Config(access_key_secret=access_key_secret,
                                    type='access_key',
                                    protocol=self._protocol,
                                    region_id=self._region_id)
     oss_client = None
     file_obj = file_form_models.FileField()
     oss_header = oss_models.PostObjectRequestHeader()
     upload_request = oss_models.PostObjectRequest()
     oss_runtime = ossutil_models.RuntimeOptions()
     OpenApiUtilClient.convert(runtime, oss_runtime)
     liveness_detect_req = cloudauth_20201112_models.LivenessDetectRequest()
     OpenApiUtilClient.convert(request, liveness_detect_req)
     if not UtilClient.is_unset(request.media_file_object):
         auth_response = auth_client.authorize_file_upload_with_options(
             auth_request, runtime)
         oss_config.access_key_id = auth_response.access_key_id
         oss_config.endpoint = OpenApiUtilClient.get_endpoint(
             auth_response.endpoint, auth_response.use_accelerate,
             self._endpoint_type)
         oss_client = OSSClient(oss_config)
         file_obj = file_form_models.FileField(
             filename=auth_response.object_key,
             content=request.media_file_object,
             content_type='')
         oss_header = oss_models.PostObjectRequestHeader(
             access_key_id=auth_response.access_key_id,
             policy=auth_response.encoded_policy,
             signature=auth_response.signature,
             key=auth_response.object_key,
             file=file_obj,
             success_action_status='201')
         upload_request = oss_models.PostObjectRequest(
             bucket_name=auth_response.bucket, header=oss_header)
         oss_client.post_object(upload_request, oss_runtime)
         liveness_detect_req.media_file = 'http://%s.%s/%s' % (
             TeaConverter.to_unicode(auth_response.bucket),
             TeaConverter.to_unicode(auth_response.endpoint),
             TeaConverter.to_unicode(auth_response.object_key))
     liveness_detect_resp = self.liveness_detect_with_options(
         liveness_detect_req, runtime)
     return liveness_detect_resp