Bir görüntüdeki araç ve plaka bilgilerini algılamak için araç algılama özelliğini kullanabilirsiniz. Bu konu, araç algılama özelliğini kullanırken belirtebileceğiniz parametreleri açıklar ve bir görüntüdeki araç ile plaka bilgilerinin nasıl algılanacağına ilişkin bir örnek sunar.
Senaryolar
Trafik yönetimi: Araç algılama, trafik ihlalleri için çekilen görüntüleri tanımlayarak bu ihlallerin işlenmesine yardımcı olmak amacıyla trafik izleme ve yönetim sistemlerinde kullanılabilir.
-
Anormal araçların tespiti: Araç algılama, Object Storage Service (OSS) paketlerine yüklenen görüntüleri tarayarak araç ve plaka bilgilerinin tespit edilmesine yardımcı olur.
NotAraç bilgileri; araç konumlarını, renklerini ve tiplerini içerir. Plaka bilgileri ise plaka konumlarını ve metinlerini kapsar.
Trafik analizi: Araç algılama, yol kullanımı ve trafik dağılımı gibi trafik bilgilerinin analiz edilmesine olanak tanır.
Nasıl kullanılır
Ön koşullar
Intelligent Media Management (IMM) hizmetini etkinleştirdiniz.
OSS'de bir paket oluşturdunuz ve işlenecek dosyaları bu pakete yüklediniz.
Bir IMM Project oluşturup eşlediniz. Projeyi OSS konsolu aracılığıyla veya bir API çağırarak eşleyebilirsiniz. IMM Project, paket ile aynı bölgede bulunmalıdır.
Kullanıcıya gerekli izinleri verdiniz.
Araç algılama
Aşağıdaki örnek kod, yaygın programlama dilleri için OSS SDK'larını kullanarak bir görüntüdeki araç ve plaka bilgilerini algılamak üzere parametrelerin nasıl belirtileceğini gösterir. Farklı programlama dilleri kullanarak bu işlemi gerçekleştirmek istiyorsanız parametreleri aşağıdaki örnek koda göre uyarlayın.
Java
OSS SDK for Java 3.17.4 veya sonraki bir sürüm gereklidir.
import com.aliyun.oss.ClientBuilderConfiguration;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.common.auth.CredentialsProviderFactory;
import com.aliyun.oss.common.auth.EnvironmentVariableCredentialsProvider;
import com.aliyun.oss.common.comm.SignVersion;
import com.aliyun.oss.model.OSSObject;
import com.aliyun.oss.model.GetObjectRequest;
import com.aliyuncs.exceptions.ClientException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public class Demo1 {
public static void main(String[] args) throws ClientException, ClientException {
// Specify the endpoint of the region in which the bucket is located.
String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
// Specify the ID of the Alibaba Cloud region in which the bucket is located. Example: cn-hangzhou.
String region = "cn-hangzhou";
// Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
// Specify the name of the bucket.
String bucketName = "examplebucket";
// If the image is stored in the root directory of the bucket, enter the image name. If the image is not stored in the root directory of the bucket, you must specify the full path of the image. Example: exampledir/example.jpg.
String key = "example.jpg";
// Create an OSSClient instance.
// Call the shutdown method to release resources when the OSSClient is no longer in use.
ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
OSS ossClient = OSSClientBuilder.create()
.endpoint(endpoint)
.credentialsProvider(credentialsProvider)
.clientConfiguration(clientBuilderConfiguration)
.region(region)
.build();
try {
// Create a processing instruction to detect vehicle information and license plate information in the image.
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, key);
getObjectRequest.setProcess("image/cars");
// Use the process parameter of the getObject method to pass the processing instruction.
OSSObject ossObject = ossClient.getObject(getObjectRequest);
// Read and display the query results.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = ossObject.getObjectContent().read(buffer)) != -1) {
baos.write(buffer, 0, bytesRead);
}
String imageCars = baos.toString("UTF-8");
System.out.println("Image Cars:");
System.out.println(imageCars);
} catch (IOException e) {
System.out.println("Error: " + e.getMessage());
} finally {
// Shut down the OSSClient instance.
ossClient.shutdown();
}
}
}
Python
OSS SDK for Python 2.18.4 veya sonraki bir sürüm gereklidir.
# -*- coding: utf-8 -*-
import oss2
from oss2.credentials import EnvironmentVariableCredentialsProvider
# Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
auth = oss2.ProviderAuthV4(EnvironmentVariableCredentialsProvider())
# Specify the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com.
endpoint = 'https://oss-cn-hangzhou.aliyuncs.com'
# Specify the ID of the Alibaba Cloud region in which the bucket is located.
region = 'cn-hangzhou'
bucket = oss2.Bucket(auth, endpoint, 'examplebucket', region=region)
# If the image is stored in the root directory of the bucket, enter the image name. If the image is not stored in the root directory of the bucket, you must specify the full path of the image. Example: exampledir/example.jpg.
key = 'example.jpg'
# Create a processing instruction to detect vehicle information and license plate information in the image.
process = 'image/cars'
try:
# Use the get_object method and pass the processing instruction by using the process parameter.
result = bucket.get_object(key, process=process)
# Read and display the query results.
image_cars = result.read().decode('utf-8')
print("Image Cars:")
print(image_cars)
except oss2.exceptions.OssError as e:
print("Error:", e)
Go
OSS SDK for Go 3.0.2 veya sonraki bir sürüm gereklidir.
package main
import (
"fmt"
"io"
"os"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
)
func main() {
// Obtain the temporary access credentials from the environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
provider, err := oss.NewEnvironmentVariableCredentialsProvider()
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
// Create an OSSClient instance.
// Specify the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com. Specify your actual endpoint.
// Specify the ID of the Alibaba Cloud region in which the bucket is located. Example: cn-hangzhou.
client, err := oss.New("https://oss-cn-hangzhou.aliyuncs.com", "", "", oss.SetCredentialsProvider(&provider), oss.AuthVersion(oss.AuthV4), oss.Region("cn-hangzhou"))
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
// Specify the name of the bucket. Example: examplebucket.
bucketName := "examplebucket"
bucket, err := client.Bucket(bucketName)
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
// If the image is stored in the root directory of the bucket, enter the image name. If the image is not stored in the root directory of the bucket, you must specify the full path of the image. Example: exampledir/example.jpg.
// Use the oss.Process method to create a processing instruction to detect vehicle information and license plate information in the image.
body, err := bucket.GetObject("example.jpg", oss.Process("image/cars"))
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
defer body.Close()
data, err := io.ReadAll(body)
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
fmt.Println("data:", string(data))
}
PHP
OSS SDK for PHP 2.7.0 veya sonraki bir sürüm gereklidir.
<?php
if (is_file(__DIR__ . '/../autoload.php')) {
require_once __DIR__ . '/../autoload.php';
}
if (is_file(__DIR__ . '/../vendor/autoload.php')) {
require_once __DIR__ . '/../vendor/autoload.php';
}
use OSS\Credentials\EnvironmentVariableCredentialsProvider;
use OSS\OssClient;
try {
// Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
$provider = new EnvironmentVariableCredentialsProvider();
// Specify the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com.
$endpoint = 'https://oss-cn-hangzhou.aliyuncs.com';
// Specify the name of the bucket. Example: examplebucket.
$bucket = 'examplebucket';
// If the image is stored in the root directory of the bucket, enter the image name. If the image is not stored in the root directory of the bucket, you must specify the full path of the image. Example: exampledir/example.jpg.
$key = 'example.jpg';
$config = array(
"provider" => $provider,
"endpoint" => $endpoint,
"signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4,
// Specify the ID of the Alibaba Cloud region in which the bucket is located.
"region" => "cn-hangzhou"
);
$ossClient = new OssClient($config);
// Create a processing instruction to detect vehicle information and license plate information in the image.
$options[$ossClient::OSS_PROCESS] = "image/cars";
$result = $ossClient->getObject($bucket,$key,$options);
var_dump($result);
} catch (OssException $e) {
printf($e->getMessage() . "\n");
return;
}
Parametre açıklaması
Eylem: image/cars
Yanıt parametreleri hakkında daha fazla bilgi için bkz. DetectImageCars.
İlgili API
Örnek istek
GET /example.jpg?x-oss-process=image/cars HTTP/1.1
Host: image-demo.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 21 Jul 2023 08:57:28 GMT
Authorization: SignatureValue
Örnek başarılı yanıt
HTTP/1.1 200 OK
Server: AliyunOSS
Date: Fri, 21 Jul 2023 08:57:30 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 250
Connection: keep-alive
x-oss-request-id: 64BA487A5423BA333952334F
ETag: "2CE2EA370531B7CC1D23BE6015CF5DA5"
Last-Modified: Mon, 10 Jul 2023 13:07:30 GMT
x-oss-object-type: Normal
x-oss-hash-crc64ecma: 13420962247653419692
x-oss-storage-class: Standard
x-oss-ec: 0048-00000104
Content-Disposition: attachment
x-oss-force-download: true
x-oss-server-time: 552
{
"RequestId" : "0C299A82-5D32-57DE-B66B-5E2A814C60BA",
"Cars": [
{
"LicensePlates": [
{
"Content": "LuA8***8",
"Boundary": {
"Width": 200,
"Height": 300,
"Left": 10,
"Top": 30
},
"Confidence": 0.789
}
],
"CarType": "van",
"CarTypeConfidence": 0.516,
"CarColor": "white",
"CarColorConfidence": 0.604,
"Boundary": {
"Width": 200,
"Height": 300,
"Left": 10,
"Top": 30
},
"Confidence": 0.999
}
]
}
Faturalama
Araç algılama sırasında IMM hizmeti çağrıldığından hem OSS hem de IMM tarafında aşağıdaki faturalandırma öğeleri oluşur:
-
OSS tarafı: Ayrıntılı fiyatlandırma için bkz. OSS Fiyatlandırması
API
Faturalandırma öğesi
Açıklama
GetObject
GET istekleri
Başarılı istek sayısına göre istek ücreti ödersiniz.
İnternet üzerinden giden trafik
GetObject işlemini oss-cn-hangzhou.aliyuncs.com gibi bir genel uç nokta veya oss-accelerate.aliyuncs.com gibi bir hızlandırma uç noktası kullanarak çağırırsanız veri boyutuna göre internet üzerinden giden trafik ücreti ödersiniz.
IA nesnelerinin alınması
IA nesneleri alınırsa alınan IA verilerinin boyutuna göre IA veri alma ücreti ödersiniz.
Aktarma hızlandırma
Aktarma hızlandırmayı etkinleştirip paketinize erişmek için bir hızlandırma uç noktası kullanırsanız veri boyutuna göre aktarma hızlandırma ücreti ödersiniz.
HeadObject
GET istekleri
Başarılı istek sayısına göre istek ücreti ödersiniz.
-
IMM tarafı: Ayrıntılı fiyatlandırma için bkz. IMM faturalandırma öğeleri
Önemli28 Temmuz 2025 tarihinde saat 11:00 UTC+8'den itibaren IMM araç algılama hizmeti ücretsiz modelden ücretli modele geçecektir. İlgili faturalandırma öğesi ImageDetect'tir. Daha fazla bilgi için bkz. IMM faturalandırma değişikliği duyurusu.
API
Faturalandırma öğesi
Açıklama
DetectImageCars
ImageDetect
Başarılı istek sayısına göre istek ücreti ödersiniz.
Notlar
Araç algılama yalnızca eşzamanlı işlemeyi (x-oss-process) destekler.
Anonim erişim reddedilir.