درخواست ثبت OCR کانتینرها

Author

تیم توسعه

Published

۴ شهریور ۱۴۰۴

توضیحات

سرویس ثبت اطلاعات استخراج شده توسط OCR. سرویس مربوطه در بستر وب و معماری REST پیاده‌سازی شده است.

جهت ارسال اطلاعات به این سرویس، باید کاربر و api-key احراز هویت شده را از تیم توسعه دریافت کنید و طبق نمونه کدهای ارائه شده در راهنمای زیر، اقدام به ارسال اطلاعات نمایید.

راهنما

نمونه پیاده‌سازی در زبان‌های برنامه‌نویسی مختلف

Note

بعد از دریافت api-key باید مقدار آن در header درخواست x-api-key قرار دهید.

هدر درخواست: x-api-key: api-key‍

نوع درخواست: POST

آدرس اصلی سامانه:

https://api.main.accessport.ir/api/v1/container-ocr/

اطلاعات

نمونه کدها

متن your-api-key را با api-key خودتان جایگزین کنید.

curl --request POST \
  --url https://api.main.accessport.ir/api/v1/container-ocr/ \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: your-api-key' \
  --data '{
  "event_id": "b4a13fc8-2663-4f69-9d1d-1c1a5bb8e9a3",
  "timestamp_utc": "2025-08-17T14:22:35Z",
  "source_system": "dideban-hazmat-ocr",
  "camera": {
    "id": "11111111-1111-1111-1111-111111111111",
    "name": "North Gate Camera 3",
    "group": "Gate Cameras",
    "location": {
      "latitude": 35.6892,
      "longitude": 51.3890,
      "description": "Tehran Port North Entrance"
    }
  },
  "image": {
    "id": "649ab03d-f633-4e19-8a9f-2f312d0f90e0",
    "url": "https://your-system.local/images/649ab03d-f633-4e19-8a9f-2f312d0f90e0.jpg",
    "local_path": "data/uploads/649ab03d-f633-4e19-8a9f-2f312d0f90e0.jpg",
    "sha256": "9b1c3ff3469dc70fbd5d7e6dc926fdf2b45a...",
    "resolution": {"width": 1920, "height": 1080}
  },
  "container": {
    "number": "MSCU1234567",
    "owner_code": "MSCU",
    "equipment_category": "U", 
    "serial_number": "123456",
    "check_digit": "7",
    "iso_code": "22G1",
    "size_type_code": "22G1",
    "read_confidence": 0.95
  },
  "hazmat_labels": [
    {
      "un_number": "1203",
      "class_code": "3",
      "subclass_code": null,
      "label_name": "Flammable Liquid",
      "confidence": 0.96,
      "bounding_box": {
        "x": 0.62,
        "y": 0.33,
        "width": 0.12,
        "height": 0.18
      }
    },
    {
      "un_number": "3082",
      "class_code": "9",
      "label_name": "Miscellaneous Dangerous Substances",
      "confidence": 0.88,
      "bounding_box": {
        "x": 0.21,
        "y": 0.55,
        "width": 0.10,
        "height": 0.16
      }
    }
  ],
  "processing_info": {
    "pipeline_version": "1.2.0",
    "validated": true,
    "corrected": false,
    "processing_duration_ms": 842
  }
}'
import axios from "axios";

const options = {
  method: 'POST',
  url: 'https://api.main.accessport.ir/api/v1/container-ocr/',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': 'your-api-key'
  },
  data: {
    event_id: 'b4a13fc8-2663-4f69-9d1d-1c1a5bb8e9a3',
    timestamp_utc: '2025-08-17T14:22:35Z',
    source_system: 'dideban-hazmat-ocr',
    camera: {
      id: '11111111-1111-1111-1111-111111111111',
      name: 'North Gate Camera 3',
      group: 'Gate Cameras',
      location: {
        latitude: 35.6892,
        longitude: 51.389,
        description: 'Tehran Port North Entrance'
      }
    },
    image: {
      id: '649ab03d-f633-4e19-8a9f-2f312d0f90e0',
      url: 'https://your-system.local/images/649ab03d-f633-4e19-8a9f-2f312d0f90e0.jpg',
      local_path: 'data/uploads/649ab03d-f633-4e19-8a9f-2f312d0f90e0.jpg',
      sha256: '9b1c3ff3469dc70fbd5d7e6dc926fdf2b45a...',
      resolution: {width: 1920, height: 1080}
    },
    container: {
      number: 'MSCU1234567',
      owner_code: 'MSCU',
      equipment_category: 'U',
      serial_number: '123456',
      check_digit: '7',
      iso_code: '22G1',
      size_type_code: '22G1',
      read_confidence: 0.95
    },
    hazmat_labels: [
      {
        un_number: '1203',
        class_code: '3',
        subclass_code: null,
        label_name: 'Flammable Liquid',
        confidence: 0.96,
        bounding_box: {x: 0.62, y: 0.33, width: 0.12, height: 0.18}
      },
      {
        un_number: '3082',
        class_code: '9',
        label_name: 'Miscellaneous Dangerous Substances',
        confidence: 0.88,
        bounding_box: {x: 0.21, y: 0.55, width: 0.1, height: 0.16}
      }
    ],
    processing_info: {
      pipeline_version: '1.2.0',
      validated: true,
      corrected: false,
      processing_duration_ms: 842
    }
  }
};

axios.request(options).then(function (response) {
  console.log(response.data);
}).catch(function (error) {
  console.error(error);
});
import requests

url = "https://api.main.accessport.ir/api/v1/container-ocr/"

payload = {
    "event_id": "b4a13fc8-2663-4f69-9d1d-1c1a5bb8e9a3",
    "timestamp_utc": "2025-08-17T14:22:35Z",
    "source_system": "dideban-hazmat-ocr",
    "camera": {
        "id": "11111111-1111-1111-1111-111111111111",
        "name": "North Gate Camera 3",
        "group": "Gate Cameras",
        "location": {
            "latitude": 35.6892,
            "longitude": 51.389,
            "description": "Tehran Port North Entrance"
        }
    },
    "image": {
        "id": "649ab03d-f633-4e19-8a9f-2f312d0f90e0",
        "url": "https://your-system.local/images/649ab03d-f633-4e19-8a9f-2f312d0f90e0.jpg",
        "local_path": "data/uploads/649ab03d-f633-4e19-8a9f-2f312d0f90e0.jpg",
        "sha256": "9b1c3ff3469dc70fbd5d7e6dc926fdf2b45a...",
        "resolution": {
            "width": 1920,
            "height": 1080
        }
    },
    "container": {
        "number": "MSCU1234567",
        "owner_code": "MSCU",
        "equipment_category": "U",
        "serial_number": "123456",
        "check_digit": "7",
        "iso_code": "22G1",
        "size_type_code": "22G1",
        "read_confidence": 0.95
    },
    "hazmat_labels": [
        {
            "un_number": "1203",
            "class_code": "3",
            "subclass_code": None,
            "label_name": "Flammable Liquid",
            "confidence": 0.96,
            "bounding_box": {
                "x": 0.62,
                "y": 0.33,
                "width": 0.12,
                "height": 0.18
            }
        },
        {
            "un_number": "3082",
            "class_code": "9",
            "label_name": "Miscellaneous Dangerous Substances",
            "confidence": 0.88,
            "bounding_box": {
                "x": 0.21,
                "y": 0.55,
                "width": 0.1,
                "height": 0.16
            }
        }
    ],
    "processing_info": {
        "pipeline_version": "1.2.0",
        "validated": True,
        "corrected": False,
        "processing_duration_ms": 842
    }
}
headers = {
    "Content-Type": "application/json",
    "x-api-key": "your-api-key"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
var client = new HttpClient();
var request = new HttpRequestMessage
{
    Method = HttpMethod.Post,
    RequestUri = new Uri("https://api.main.accessport.ir/api/v1/container-ocr/"),
    Headers =
    {
        { "x-api-key", "your-api-key" },
    },
    Content = new StringContent("{\n  \"event_id\": \"b4a13fc8-2663-4f69-9d1d-1c1a5bb8e9a3\",\n  \"timestamp_utc\": \"2025-08-17T14:22:35Z\",\n  \"source_system\": \"dideban-hazmat-ocr\",\n  \"camera\": {\n    \"id\": \"11111111-1111-1111-1111-111111111111\",\n    \"name\": \"North Gate Camera 3\",\n    \"group\": \"Gate Cameras\",\n    \"location\": {\n      \"latitude\": 35.6892,\n      \"longitude\": 51.3890,\n      \"description\": \"Tehran Port North Entrance\"\n    }\n  },\n  \"image\": {\n    \"id\": \"649ab03d-f633-4e19-8a9f-2f312d0f90e0\",\n    \"url\": \"https://your-system.local/images/649ab03d-f633-4e19-8a9f-2f312d0f90e0.jpg\",\n    \"local_path\": \"data/uploads/649ab03d-f633-4e19-8a9f-2f312d0f90e0.jpg\",\n    \"sha256\": \"9b1c3ff3469dc70fbd5d7e6dc926fdf2b45a...\",\n    \"resolution\": {\"width\": 1920, \"height\": 1080}\n  },\n  \"container\": {\n    \"number\": \"MSCU1234567\",\n    \"owner_code\": \"MSCU\",\n    \"equipment_category\": \"U\", \n    \"serial_number\": \"123456\",\n    \"check_digit\": \"7\",\n    \"iso_code\": \"22G1\",\n    \"size_type_code\": \"22G1\",\n    \"read_confidence\": 0.95\n  },\n  \"hazmat_labels\": [\n    {\n      \"un_number\": \"1203\",\n      \"class_code\": \"3\",\n      \"subclass_code\": null,\n      \"label_name\": \"Flammable Liquid\",\n      \"confidence\": 0.96,\n      \"bounding_box\": {\n        \"x\": 0.62,\n        \"y\": 0.33,\n        \"width\": 0.12,\n        \"height\": 0.18\n      }\n    },\n    {\n      \"un_number\": \"3082\",\n      \"class_code\": \"9\",\n      \"label_name\": \"Miscellaneous Dangerous Substances\",\n      \"confidence\": 0.88,\n      \"bounding_box\": {\n        \"x\": 0.21,\n        \"y\": 0.55,\n        \"width\": 0.10,\n        \"height\": 0.16\n      }\n    }\n  ],\n  \"processing_info\": {\n    \"pipeline_version\": \"1.2.0\",\n    \"validated\": true,\n    \"corrected\": false,\n    \"processing_duration_ms\": 842\n  }\n}")
    {
        Headers =
        {
            ContentType = new MediaTypeHeaderValue("application/json")
        }
    }
};
using (var response = await client.SendAsync(request))
{
    response.EnsureSuccessStatusCode();
    var body = await response.Content.ReadAsStringAsync();
    Console.WriteLine(body);
}
<?php

$request = new HttpRequest();
$request->setUrl('https://api.main.accessport.ir/api/v1/container-ocr/');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders([
  'Content-Type' => 'application/json',
  'x-api-key' => 'your-api-key'
]);

$request->setBody('{
  "event_id": "b4a13fc8-2663-4f69-9d1d-1c1a5bb8e9a3",
  "timestamp_utc": "2025-08-17T14:22:35Z",
  "source_system": "dideban-hazmat-ocr",
  "camera": {
    "id": "11111111-1111-1111-1111-111111111111",
    "name": "North Gate Camera 3",
    "group": "Gate Cameras",
    "location": {
      "latitude": 35.6892,
      "longitude": 51.3890,
      "description": "Tehran Port North Entrance"
    }
  },
  "image": {
    "id": "649ab03d-f633-4e19-8a9f-2f312d0f90e0",
    "url": "https://your-system.local/images/649ab03d-f633-4e19-8a9f-2f312d0f90e0.jpg",
    "local_path": "data/uploads/649ab03d-f633-4e19-8a9f-2f312d0f90e0.jpg",
    "sha256": "9b1c3ff3469dc70fbd5d7e6dc926fdf2b45a...",
    "resolution": {"width": 1920, "height": 1080}
  },
  "container": {
    "number": "MSCU1234567",
    "owner_code": "MSCU",
    "equipment_category": "U", 
    "serial_number": "123456",
    "check_digit": "7",
    "iso_code": "22G1",
    "size_type_code": "22G1",
    "read_confidence": 0.95
  },
  "hazmat_labels": [
    {
      "un_number": "1203",
      "class_code": "3",
      "subclass_code": null,
      "label_name": "Flammable Liquid",
      "confidence": 0.96,
      "bounding_box": {
        "x": 0.62,
        "y": 0.33,
        "width": 0.12,
        "height": 0.18
      }
    },
    {
      "un_number": "3082",
      "class_code": "9",
      "label_name": "Miscellaneous Dangerous Substances",
      "confidence": 0.88,
      "bounding_box": {
        "x": 0.21,
        "y": 0.55,
        "width": 0.10,
        "height": 0.16
      }
    }
  ],
  "processing_info": {
    "pipeline_version": "1.2.0",
    "validated": true,
    "corrected": false,
    "processing_duration_ms": 842
  }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "https://api.main.accessport.ir/api/v1/container-ocr/")
  .setHeader("Content-Type", "application/json")
  .setHeader("x-api-key", "your-api-key")
  .setBody("{\n  \"event_id\": \"b4a13fc8-2663-4f69-9d1d-1c1a5bb8e9a3\",\n  \"timestamp_utc\": \"2025-08-17T14:22:35Z\",\n  \"source_system\": \"dideban-hazmat-ocr\",\n  \"camera\": {\n    \"id\": \"11111111-1111-1111-1111-111111111111\",\n    \"name\": \"North Gate Camera 3\",\n    \"group\": \"Gate Cameras\",\n    \"location\": {\n      \"latitude\": 35.6892,\n      \"longitude\": 51.3890,\n      \"description\": \"Tehran Port North Entrance\"\n    }\n  },\n  \"image\": {\n    \"id\": \"649ab03d-f633-4e19-8a9f-2f312d0f90e0\",\n    \"url\": \"https://your-system.local/images/649ab03d-f633-4e19-8a9f-2f312d0f90e0.jpg\",\n    \"local_path\": \"data/uploads/649ab03d-f633-4e19-8a9f-2f312d0f90e0.jpg\",\n    \"sha256\": \"9b1c3ff3469dc70fbd5d7e6dc926fdf2b45a...\",\n    \"resolution\": {\"width\": 1920, \"height\": 1080}\n  },\n  \"container\": {\n    \"number\": \"MSCU1234567\",\n    \"owner_code\": \"MSCU\",\n    \"equipment_category\": \"U\", \n    \"serial_number\": \"123456\",\n    \"check_digit\": \"7\",\n    \"iso_code\": \"22G1\",\n    \"size_type_code\": \"22G1\",\n    \"read_confidence\": 0.95\n  },\n  \"hazmat_labels\": [\n    {\n      \"un_number\": \"1203\",\n      \"class_code\": \"3\",\n      \"subclass_code\": null,\n      \"label_name\": \"Flammable Liquid\",\n      \"confidence\": 0.96,\n      \"bounding_box\": {\n        \"x\": 0.62,\n        \"y\": 0.33,\n        \"width\": 0.12,\n        \"height\": 0.18\n      }\n    },\n    {\n      \"un_number\": \"3082\",\n      \"class_code\": \"9\",\n      \"label_name\": \"Miscellaneous Dangerous Substances\",\n      \"confidence\": 0.88,\n      \"bounding_box\": {\n        \"x\": 0.21,\n        \"y\": 0.55,\n        \"width\": 0.10,\n        \"height\": 0.16\n      }\n    }\n  ],\n  \"processing_info\": {\n    \"pipeline_version\": \"1.2.0\",\n    \"validated\": true,\n    \"corrected\": false,\n    \"processing_duration_ms\": 842\n  }\n}")
  .execute()
  .toCompletableFuture()
  .thenAccept(System.out::println)
  .join();

client.close();
package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://api.main.accessport.ir/api/v1/container-ocr/"

    payload := strings.NewReader("{\n  \"event_id\": \"b4a13fc8-2663-4f69-9d1d-1c1a5bb8e9a3\",\n  \"timestamp_utc\": \"2025-08-17T14:22:35Z\",\n  \"source_system\": \"dideban-hazmat-ocr\",\n  \"camera\": {\n    \"id\": \"11111111-1111-1111-1111-111111111111\",\n    \"name\": \"North Gate Camera 3\",\n    \"group\": \"Gate Cameras\",\n    \"location\": {\n      \"latitude\": 35.6892,\n      \"longitude\": 51.3890,\n      \"description\": \"Tehran Port North Entrance\"\n    }\n  },\n  \"image\": {\n    \"id\": \"649ab03d-f633-4e19-8a9f-2f312d0f90e0\",\n    \"url\": \"https://your-system.local/images/649ab03d-f633-4e19-8a9f-2f312d0f90e0.jpg\",\n    \"local_path\": \"data/uploads/649ab03d-f633-4e19-8a9f-2f312d0f90e0.jpg\",\n    \"sha256\": \"9b1c3ff3469dc70fbd5d7e6dc926fdf2b45a...\",\n    \"resolution\": {\"width\": 1920, \"height\": 1080}\n  },\n  \"container\": {\n    \"number\": \"MSCU1234567\",\n    \"owner_code\": \"MSCU\",\n    \"equipment_category\": \"U\", \n    \"serial_number\": \"123456\",\n    \"check_digit\": \"7\",\n    \"iso_code\": \"22G1\",\n    \"size_type_code\": \"22G1\",\n    \"read_confidence\": 0.95\n  },\n  \"hazmat_labels\": [\n    {\n      \"un_number\": \"1203\",\n      \"class_code\": \"3\",\n      \"subclass_code\": null,\n      \"label_name\": \"Flammable Liquid\",\n      \"confidence\": 0.96,\n      \"bounding_box\": {\n        \"x\": 0.62,\n        \"y\": 0.33,\n        \"width\": 0.12,\n        \"height\": 0.18\n      }\n    },\n    {\n      \"un_number\": \"3082\",\n      \"class_code\": \"9\",\n      \"label_name\": \"Miscellaneous Dangerous Substances\",\n      \"confidence\": 0.88,\n      \"bounding_box\": {\n        \"x\": 0.21,\n        \"y\": 0.55,\n        \"width\": 0.10,\n        \"height\": 0.16\n      }\n    }\n  ],\n  \"processing_info\": {\n    \"pipeline_version\": \"1.2.0\",\n    \"validated\": true,\n    \"corrected\": false,\n    \"processing_duration_ms\": 842\n  }\n}")

    req, _ := http.NewRequest("POST", url, payload)

    req.Header.Add("Content-Type", "application/json")
    req.Header.Add("x-api-key", "your-api-key")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}