All Products
Search
Document Center

Intelligent Media Management:Vehicle detection

Last Updated:Jun 27, 2025

The vehicle detection feature can detect vehicle information in images. This technology is widely used in traffic monitoring, intelligent parking systems, autonomous driving assistance, urban traffic management, electronic toll collection systems, and safety and rescue services. This topic describes how to use the vehicle information detection feature.

Scenarios

  • Traffic management: Vehicle detection can be used in traffic monitoring and management systems, such as identifying images captured for traffic violations to help process these violations.

  • Identification of abnormal vehicles: Vehicle detection can detect images uploaded to Object Storage Service (OSS) buckets to help identify vehicle information and license plate information.

    Note

    Vehicle information includes vehicle locations, vehicle colors, and vehicle types. License plate information includes license plate locations and license plate texts.

  • Traffic analysis: Vehicle detection can help you analyze traffic information such as road usage and traffic distribution.

Prerequisites

  • An AccessKey pair is created and obtained. For more information, see Create an AccessKey pair.

  • OSS is activated, a bucket is created, and objects are uploaded to the bucket. For more information, see Upload objects in the console.

  • Intelligent Media Management (IMM) is activated. For more information, see Activate the service.

  • A project is created in the IMM console. For more information, see Create a project.

    Note
    • You can also call the CreateProject operation to create a project. For more information, see CreateProject.

    • You can call the ListProjects operation to query the existing projects in a specific region.

Usage

Call the DetectImageCars operation to detect vehicle information in images.

Detection information

  • IMM project: test-project

  • Image address: oss://test-bucket/test-object.jpg

  • Image:

    test-object

Sample request

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

Sample response

{
  "Cars": [
    {
      "CarColorConfidence": 0.817,
      "Confidence": 0.994,
      "CarType": "car",
      "CarColor": "gray",
      "LicensePlates": [
        {
          "Confidence": 0.877,
          "Content": "VRED2015",
          "Boundary": {
            "Left": 1269,
            "Top": 715,
            "Height": 23,
            "Width": 140
          }
        }
      ],
      "CarTypeConfidence": 0.749,
      "Boundary": {
        "Left": 1172,
        "Top": 430,
        "Height": 427,
        "Width": 905
      }
    }
  ],
  "RequestId": "2F15B1A9-F671-58B3-B3E4-69C7339EB472"
}
Note

The sample response shows that the detection image contains a gray vehicle with the license plate VRED2015.

Sample code

The following sample code provides an example on how to use IMM SDK for Python to detect vehicle information:

# -*- 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 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. Using these credentials to perform operations is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M.
        # 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, visit https://help.aliyun.com/document_detail/2361894.html.
        imm_access_key_id = os.getenv("AccessKeyId")
        imm_access_key_secret = os.getenv("AccessKeySecret")
        client = Sample.create_client(imm_access_key_id, imm_access_key_secret)
        detect_image_cars_request = imm_20200930_models.DetectImageCarsRequest(
            project_name='test-project',
            source_uri='oss://test-bucket/test-object.jpg'
        )
        runtime = util_models.RuntimeOptions()
        try:
            # You can choose to print the response of the API operation.
            client.detect_image_cars_with_options(detect_image_cars_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. Using these credentials to perform operations is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M.
        # 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, visit https://help.aliyun.com/document_detail/2361894.html.
        imm_access_key_id = os.getenv("AccessKeyId")
        imm_access_key_secret = os.getenv("AccessKeySecret")
        client = Sample.create_client(imm_access_key_id, imm_access_key_secret)
        detect_image_cars_request = imm_20200930_models.DetectImageCarsRequest(
            project_name='test-project',
            source_uri='oss://test-bucket/test-object.jpg'
        )
        runtime = util_models.RuntimeOptions()
        try:
            # You can choose to print the response of the API operation.
            await client.detect_image_cars_with_options_async(detect_image_cars_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:])

Billing

During vehicle detection, the following billing items are generated on both OSS and IMM sides:

  • OSS side: For detailed pricing, see OSS pricing.

    API

    Billing item

    Description

    GetObject

    GET requests

    You are charged request fees based on the number of successful requests.

    Data retrieval of IA objects

    If IA objects are retrieved, you are charged IA data retrieval fees based on the size of retrieved IA objects.

    Data Retrieval Capacity from Archive Direct Read

    If Archive objects in a bucket for which real-time access is enabled are retrieved, you are charged Archive data retrieval fees based on the size of retrieved Archive objects.

    Transfer acceleration

    If you enable transfer acceleration and use an acceleration endpoint to access your bucket, you are charged transfer acceleration fees based on the data size.

    HeadObject

    GET requests

    You are charged request fees based on the number of successful requests.

  • IMM side: For detailed pricing, see IMM billing items.

    Important

    Starting from 11:00 UTC+8 on July 28, 2025, the IMM vehicle information detection service will be integrated into the image detection service, and the free mode will be upgraded to the billing mode. For more information, see IMM billing adjustment announcement.

    API

    Billing item

    Description

    DetectImageCars

    ImageDetect

    You are charged vehicle detection fees based on the number of successful detections.