Tüm Ürünler
Search
Belge Merkezi

Intelligent Media Management:QR kod tanıma

Son Güncelleme:Oct 05, 2026

Bu konu, QR kod tanıma özelliğinin nasıl kullanılacağını açıklar.

Senaryolar

  • QR kod ile ödeme: Ödemeyi yapan kişiler, ödemeleri tamamlamak için bir QR kodu tarayabilir.

  • QR kod ile pazarlama ve reklam: Pazarlamacılar ve reklamcılar, ürünleri tanıtmak amacıyla afişlere ve ürün ambalajlarına QR kod ekleyebilir.

Genel Bakış

Intelligent Media Management (IMM), fotoğraflar ve ekran görüntüleri gibi görsel dosyalardan bir veya daha fazla QR kodun ya da barkodun konumlarını ve içeriklerini algılamanızı sağlayan QR kod tanıma özelliğini sunar. Bu özellik, kodların ilettiği konum bilgilerini ve metin bilgilerini döndürür. Konum bilgileri; sol üst köşe x ekseni, sol üst köşe y ekseni, genişlik ve yükseklik değerlerini içerir. Aşağıdaki şekilde bu bilgiler gösterilmektedir.

  • QR kod

    figqcode11

  • Barkod

    image

QR kod tanıma özelliğini kullanarak iş uygulamalarınızda QR kod veya barkod tarama ve okuma işlevlerini uygulayabilirsiniz. Ayrıca, bu özelliği temel alarak görsellerdeki QR kodları veya barkodları engelleyen ya da bulanıklaştıran özellikler geliştirebilirsiniz.

Ön Koşullar

  • Bir AccessKey çifti oluşturulmuş ve edinilmiş olmalıdır. Daha fazla bilgi için bkz. AccessKey oluşturma.

  • Object Storage Service (OSS) etkinleştirilmiş, bir paket oluşturulmuş ve nesneler pakete yüklenmiş olmalıdır. Daha fazla bilgi için bkz. Nesneleri yükleme.

  • IMM etkinleştirilmiş olmalıdır. Daha fazla bilgi için bkz. IMM'yi etkinleştirme.

  • IMM konsolunda bir proje oluşturulmuş olmalıdır. Daha fazla bilgi için bkz. Proje oluşturma.

    Not
    • CreateProject işlemine çağrı yaparak bir proje oluşturabilirsiniz. Daha fazla bilgi için bkz. CreateProject.

    • ListProjects işlemine çağrı yaparak belirli bir bölgedeki mevcut projeleri sorgulayabilirsiniz. Daha fazla bilgi için bkz. ListProjects.

Kullanım

Bir görselden barkodları algılamak için DetectImageCodes işlemini çağırın.

Not

QR kod algılama işlemiyle bir görselden en fazla beş QR kod tespit edebilirsiniz.

QR kod algılama örneği

Görsel bilgileri

  • IMM projesi: test-project

  • Görsel depolama konumu: oss://test-bucket/test-object1.jpg

  • Örnek görsel

    figqcode11

Örnek istek

{
    "ProjectName": "test-project",
    "SourceURI": "oss://test-bucket/test-object1.jpg",
}

Örnek yanıt

{
  "Codes": [
    {
      "Type": "qrcode",
      "Content": "https://www.aliyun.com/product/imm",
      "Boundary": {
        "Left": 447,
        "Top": 288,
        "Height": 720,
        "Width": 767
      }
    }
  ],
  "RequestId": "9692C8B4-2AAF-55DE-91A0-B0B53725FBAB"
}
Not

Yukarıdaki örnek yanıt, görselin bir QR kod içerdiğini göstermektedir.

Örnek kod

Aşağıdaki örnek kod, bir görselden QR kodları algılamak üzere IMM SDK for Python'ın nasıl kullanılacağını göstermektedir.

# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import sys
import os
from typing import List

from alibabacloud_imm20200930.client import Client as imm20200930Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_imm20200930 import models as imm_20200930_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient

class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client(
        access_key_id: str,
        access_key_secret: str,
    ) -> imm20200930Client:
        """
        Use your AccessKey ID and AccessKey secret to initialize the client. 
        @param access_key_id:
        @param access_key_secret:
        @return: Client
        @throws Exception
        """
        config = open_api_models.Config(
            access_key_id=access_key_id,
            access_key_secret=access_key_secret
        )
        # Specify the IMM endpoint. 
        config.endpoint = f'imm.cn-beijing.aliyuncs.com'
        return imm20200930Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        # The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. To prevent security risks, we recommend that you call API operations or perform routine O&M as a RAM user. 
        # We recommend that you do not include your AccessKey pair (AccessKey ID and AccessKey secret) in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account may be compromised. 
        # In this example, the AccessKey pair is read from the environment variables to implement identity verification for API access. For information about how to configure environment variables, see https://www.alibabacloud.com/help/document_detail/2361894.html. 
        imm_access_key_id = os.getenv("AccessKeyId")
        imm_access_key_secret = os.getenv("AccessKeySecret")
        # Initialize the client. 
        client = Sample.create_client(imm_access_key_id, imm_access_key_secret)
        detect_image_codes_request = imm_20200930_models.DetectImageCodesRequest(
            project_name='test-project',
            source_uri='oss://test-bucket/test-object1.jpg'
        )
        runtime = util_models.RuntimeOptions()
        try:
            # You can choose to print the response of the API operation. 
            client.detect_image_codes_with_options(detect_image_codes_request, runtime)
        except Exception as error:
            # Print the error message if necessary. 
            UtilClient.assert_as_string(error.message)

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        # The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. To prevent security risks, we recommend that you call API operations or perform routine O&M as a RAM user. 
        # We recommend that you do not include your AccessKey pair (AccessKey ID and AccessKey secret) in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account may be compromised. 
        # In this example, the AccessKey pair is read from the environment variables to implement identity verification for API access. For information about how to configure environment variables, see https://www.alibabacloud.com/help/document_detail/2361894.html. 
        imm_access_key_id = os.getenv("AccessKeyId")
        imm_access_key_secret = os.getenv("AccessKeySecret")
        # Initialize the client. 
        client = Sample.create_client(imm_access_key_id, imm_access_key_secret)
        detect_image_codes_request = imm_20200930_models.DetectImageCodesRequest(
            project_name='test-project',
            source_uri='oss://test-bucket/test-object1.jpg'
        )
        runtime = util_models.RuntimeOptions()
        try:
            # You can choose to print the response of the API operation. 
            await client.detect_image_codes_with_options_async(detect_image_codes_request, runtime)
        except Exception as error:
            # Print the error message if necessary. 
            UtilClient.assert_as_string(error.message)

if __name__ == '__main__':
    Sample.main(sys.argv[1:])

Barkod algılama örneği

Görsel bilgileri

  • IMM projesi: test-project

  • Görsel depolama konumu: oss://test-bucket/test-object2.jpg

  • Örnek görsel

    test-object

Örnek istek

{
    "ProjectName": "test-project",
    "SourceURI": "oss://test-bucket/test-object2.jpg",
}

Örnek yanıt

{
  "Codes": [
    {
      "Type": "barcode",
      "Confidence": 0.433,
      "Content": "",
      "Boundary": {
        "Left": 162,
        "Top": 393,
        "Height": 86,
        "Width": 78
      }
    }
  ],
  "RequestId": "391A3AEC-FF64-5450-96DF-18DBDC234B2F"
}
Not

Yukarıdaki örnek yanıt, görselin bir barkod içerdiğini göstermektedir.

Örnek kod

# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import sys
import os
from typing import List

from alibabacloud_imm20200930.client import Client as imm20200930Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_imm20200930 import models as imm_20200930_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient

class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client(
        access_key_id: str,
        access_key_secret: str,
    ) -> imm20200930Client:
        """
        Use your AccessKey ID and AccessKey secret to initialize the client. 
        @param access_key_id:
        @param access_key_secret:
        @return: Client
        @throws Exception
        """
        config = open_api_models.Config(
            access_key_id=access_key_id,
            access_key_secret=access_key_secret
        )
        # Specify the IMM endpoint. 
        config.endpoint = f'imm.cn-beijing.aliyuncs.com'
        return imm20200930Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        # The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. To prevent security risks, we recommend that you call API operations or perform routine O&M as a RAM user. 
        # We recommend that you do not include your AccessKey pair (AccessKey ID and AccessKey secret) in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account may be compromised. 
        # In this example, the AccessKey pair is read from the environment variables to implement identity verification for API access. For information about how to configure environment variables, see https://www.alibabacloud.com/help/document_detail/2361894.html. 
        imm_access_key_id = os.getenv("AccessKeyId")
        imm_access_key_secret = os.getenv("AccessKeySecret")
        # Initialize the client. 
        client = Sample.create_client(imm_access_key_id, imm_access_key_secret)
        detect_image_codes_request = imm_20200930_models.DetectImageCodesRequest(
            project_name='test-project',
            source_uri='oss://test-bucket/test-object2.jpg'
        )
        runtime = util_models.RuntimeOptions()
        try:
            # You can choose to print the response of the API operation. 
            client.detect_image_codes_with_options(detect_image_codes_request, runtime)
        except Exception as error:
            # Print the error message if necessary. 
            UtilClient.assert_as_string(error.message)

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        # The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. To prevent security risks, we recommend that you call API operations or perform routine O&M as a RAM user. 
        # We recommend that you do not include your AccessKey pair (AccessKey ID and AccessKey secret) in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account may be compromised. 
        # In this example, the AccessKey pair is read from the environment variables to implement identity verification for API access. For information about how to configure environment variables, see https://www.alibabacloud.com/help/document_detail/2361894.html. 
        imm_access_key_id = os.getenv("AccessKeyId")
        imm_access_key_secret = os.getenv("AccessKeySecret")
        # Initialize the client. 
        client = Sample.create_client(imm_access_key_id, imm_access_key_secret)
        detect_image_codes_request = imm_20200930_models.DetectImageCodesRequest(
            project_name='test-project',
            source_uri='oss://test-bucket/test-object2.jpg'
        )
        runtime = util_models.RuntimeOptions()
        try:
            # You can choose to print the response of the API operation. 
            await client.detect_image_codes_with_options_async(detect_image_codes_request, runtime)
        except Exception as error:
            # Print the error message if necessary. 
            UtilClient.assert_as_string(error.message)

if __name__ == '__main__':
    Sample.main(sys.argv[1:])