API Reference — PPE Analytics
Endpoint REST API untuk membuat, mengelola, dan memantau pipeline PPE Analytics (NFV4-PPE).
← Kembali ke PPE Analytics
Penjelasan kemampuan, cara kerja, konfigurasi, dan best practice PPE Analytics.
People Analytics
Counting, dwelling, density, dan atribut demografis untuk orang.
Semua endpoint pada halaman ini menggunakan basis URL dari variabel VISIONAIRE_API_URL yang dikonfigurasi pada instalasi Visionaire (default: http://localhost:4004). Tidak ada autentikasi tambahan yang diperlukan selain akses jaringan ke host tersebut — pastikan port sudah dapat dijangkau dari klien Anda. Lihat Developer Guide untuk panduan lebih lanjut.
Manajemen Pipeline
Endpoint untuk membuat, memantau, dan menghapus pipeline PPE Analytics. Setiap pipeline diidentifikasi oleh kombinasi node_num, stream_id, dan analytic_id (NFV4-PPE).
Buat Pipeline PPE
POST /pipeline/{node_num}/{stream_id}/NFV4-PPE
Membuat pipeline PPE Analytics baru pada stream yang ditentukan.
Parameter Path
| Parameter | Tipe | Deskripsi |
|---|---|---|
node_num | integer | Nomor node tempat pipeline akan berjalan (0 = master) |
stream_id | string | ID stream yang akan dianalisis |
Contoh Request
curl -X POST "http://localhost:4004/pipeline/0/stream_001/NFV4-PPE" \
-H "Content-Type: application/json" \
-d '{
"config": {
"object_confidence_threshold": 0.53,
"colordet_crop_w": 0.4,
"colordet_crop_h": 0.4,
"head_protection_confidence_threshold": 0.7,
"helmet_color_confidence_threshold": 0.5,
"safety_glasses_confidence_threshold": 0.5,
"face_shield_confidence_threshold": 0.5,
"face_mask_confidence_threshold": 0.5,
"gloves_confidence_threshold": 0.5,
"safety_harness_confidence_threshold": 0.7,
"protective_clothing_confidence_threshold": 0.5,
"protective_clothing_color_confidence_threshold": 0.5,
"footwear_type_confidence_threshold": 0.5,
"work_context_confidence_threshold": 0.5
},
"logics": [
{
"type": "counting",
"is_active": true,
"dumping_sampling_time": 500,
"dump_ignore_iou_threshold": 0.8,
"enable_group_tracking": false,
"minimum_tracking_height": 0.05,
"maximum_tracking_objects": 30,
"enable_visual_label": false,
"areas": [
{
"name": "Site Entrance",
"coordinates": [[0, 540], [1920, 540]]
}
]
},
{
"type": "roi_counting",
"is_active": false
},
{
"type": "dwelling",
"is_active": false,
"dwelling_treshold_alert_sec": 0,
"minimum_dwelling_sec": 2,
"idle_time_sec": 1,
"object_intersect_threshold": 0.85,
"minimum_object_area_size": 2000,
"sharpness_filter_threshold": 0,
"only_dump_exit": false
},
{
"type": "density",
"is_active": false,
"interval": 5,
"inside": true,
"dump_attributes": true
}
]
}'Update Konfigurasi Pipeline
PATCH /pipeline/{node_num}/{stream_id}/NFV4-PPE/config
Memperbarui parameter pipeline yang sedang berjalan tanpa perlu me-restart. Berguna untuk menyesuaikan threshold atau mengubah konfigurasi area secara dinamis.
Parameter Path
| Parameter | Tipe | Deskripsi |
|---|---|---|
node_num | integer | Nomor node tempat pipeline berjalan |
stream_id | string | ID stream yang sedang dianalisis |
Contoh Request
curl -X PATCH "http://localhost:4004/pipeline/0/stream_001/NFV4-PPE/config" \
-H "Content-Type: application/json" \
-d '{
"config": {
"head_protection_confidence_threshold": 0.8,
"safety_harness_confidence_threshold": 0.8
}
}'Hapus Pipeline
DELETE /pipeline/{node_num}/{stream_id}/NFV4-PPE
Menghentikan dan menghapus pipeline PPE Analytics yang berjalan pada stream yang ditentukan.
Contoh Request
curl -X DELETE "http://localhost:4004/pipeline/0/stream_001/NFV4-PPE"Status Pipeline
GET /pipeline/{node_num}/{stream_id}/NFV4-PPE
Mengambil status dan konfigurasi pipeline yang sedang berjalan.
Contoh Request
curl "http://localhost:4004/pipeline/0/stream_001/NFV4-PPE"Contoh Response
{
"analytic_id": "NFV4-PPE",
"stream_id": "stream_001",
"node_num": 0,
"status": "running",
"config": {
"object_confidence_threshold": 0.53,
"head_protection_confidence_threshold": 0.7,
"safety_harness_confidence_threshold": 0.7
}
}Parameter Konfigurasi
Parameter Global
| Parameter | Deskripsi | Default |
|---|---|---|
object_confidence_threshold | Confidence minimum untuk deteksi orang | 0.53 |
colordet_crop_w | Rasio lebar crop untuk klasifikasi atribut warna | 0.4 |
colordet_crop_h | Rasio tinggi crop untuk klasifikasi atribut warna | 0.4 |
Parameter Counting Logic
| Parameter | Deskripsi | Default |
|---|---|---|
dumping_sampling_time | Interval agregasi event saat orang melewati garis (ms) | 500 |
dump_ignore_iou_threshold | Threshold IoU untuk deduplication crossing | 0.8 |
enable_group_tracking | Aktifkan group/crowd tracking | false |
minimum_tracking_height | Tinggi minimum bbox (rasio terhadap frame) | 0.05 |
maximum_tracking_objects | Jumlah maksimum objek yang di-track | 30 |
enable_visual_label | Tampilkan label pada visualisasi | false |
Parameter Dwelling Logic
| Parameter | Deskripsi | Default |
|---|---|---|
dwelling_treshold_alert_sec | Durasi (detik) sebelum alert dikirim (0 = nonaktif) | 0 |
minimum_dwelling_sec | Durasi minimum dwelling untuk generate event | 2 |
idle_time_sec | Grace period setelah keluar ROI sebelum timer direset | 1 |
object_intersect_threshold | Threshold interseksi orang dengan ROI | 0.85 |
minimum_object_area_size | Area minimum bbox dalam piksel² | 2000 |
sharpness_filter_threshold | Threshold sharpness untuk dump dwelling | 0 |
only_dump_exit | Hanya dump saat orang keluar ROI | false |
Penulisan dwelling_treshold_alert_sec mengikuti kunci konfigurasi yang diterima oleh source code (typo treshold adalah disengaja sesuai source).
Parameter Density Logic
| Parameter | Deskripsi | Default |
|---|---|---|
interval | Interval pelaporan kepadatan (detik) | 5 |
inside | Hitung orang di dalam ROI (true) atau di luar (false) | true |
dump_attributes | Sertakan atribut PPE per orang dalam event density | true |
Threshold Atribut PPE
Setiap atribut PPE memiliki threshold confidence-nya sendiri. Bila confidence di bawah threshold, label atribut tersebut diset menjadi Unknown.
| Parameter | Deskripsi | Default |
|---|---|---|
head_protection_confidence_threshold | Threshold deteksi pelindung kepala | 0.5 |
helmet_color_confidence_threshold | Threshold deteksi warna helmet | 0.5 |
safety_glasses_confidence_threshold | Threshold deteksi safety glasses | 0.5 |
face_shield_confidence_threshold | Threshold deteksi face shield | 0.5 |
face_mask_confidence_threshold | Threshold deteksi face mask | 0.5 |
gloves_confidence_threshold | Threshold deteksi gloves | 0.5 |
safety_harness_confidence_threshold | Threshold deteksi safety harness | 0.5 |
protective_clothing_confidence_threshold | Threshold deteksi protective clothing | 0.5 |
protective_clothing_color_confidence_threshold | Threshold warna protective clothing | 0.5 |
footwear_type_confidence_threshold | Threshold jenis alas kaki | 0.5 |
work_context_confidence_threshold | Threshold konteks lingkungan kerja | 0.5 |
Format Event
Setiap event memiliki struktur top-level berikut:
| Field | Tipe | Deskripsi |
|---|---|---|
analytic_id | string | Selalu NFV4-PPE |
stream_id | string | ID stream yang diproses |
stream_name | string | Nama stream |
node_num | integer | Nomor node yang memproses |
timestamp | integer (ms) | Unix timestamp event (millisecond) |
primary_text | string | Teks utama event |
secondary_text | string | Teks pelengkap |
image_jpeg | string (base64) | Cuplikan frame saat event terjadi |
pipeline_data | object | Payload utama hasil sub-analytic |
Field pipeline_data
| Field | Tipe | Tersedia Pada |
|---|---|---|
logic | string | semua (counting, roi_counting, dwelling, density) |
label | string | counting, roi_counting, dwelling (selalu "person") |
confidence | float | counting, roi_counting, dwelling |
tracker_id | integer | counting, roi_counting, dwelling |
group_id | integer | counting, roi_counting, dwelling |
area_name | string | counting, roi_counting, dwelling |
direction | string | counting, roi_counting ("in" / "out") |
time_in / time_out / time_alert | integer (ms) | dwelling |
duration | float (detik) | dwelling |
attributes | object | counting, roi_counting, dwelling |
area | string | density (nama ROI) |
estimation | integer | density (jumlah orang dalam ROI) |
interval | integer (detik) | density |
detected | array | density (rincian per orang) |
event_id | string | semua (hash unik per event) |
Field attributes berisi map atribut PPE yang aktif. Setiap atribut adalah objek { "label": "...", "confidence": 0.0–1.0 }. Atribut dengan confidence di bawah threshold akan memiliki label: "Unknown".
Contoh Event
{
"analytic_id": "NFV4-PPE",
"stream_id": "stream_001",
"timestamp": 1705314600000,
"primary_text": "person",
"secondary_text": "in",
"pipeline_data": {
"logic": "counting",
"label": "person",
"confidence": 0.86,
"tracker_id": 5,
"group_id": 0,
"area_name": "Site Entrance",
"direction": "in",
"attributes": {
"head_protection": { "label": "Helmet", "confidence": 0.91 },
"helmet_color": { "label": "Yellow", "confidence": 0.83 },
"safety_glasses": { "label": "Unknown", "confidence": 0.42 },
"face_shield": { "label": "No Face Shield", "confidence": 0.88 },
"face_mask": { "label": "No Face Mask", "confidence": 0.81 },
"gloves": { "label": "Gloves", "confidence": 0.74 },
"safety_harness": { "label": "No Safety Harness", "confidence": 0.79 },
"protective_clothing": { "label": "Vest", "confidence": 0.87 },
"protective_clothing_color": { "label": "Orange", "confidence": 0.84 },
"footwear_type": { "label": "Safety Boots", "confidence": 0.71 },
"work_context": { "label": "Construction", "confidence": 0.66 }
},
"event_id": "1705314600000-3a1f9d4c"
}
}Subscribe Event Channel (WebSocket)
WS /event_channel/{node_num}/{stream_id}/NFV4-PPE
Visionaire4 mengirim setiap event hasil deteksi/inferensi melalui WebSocket. Untuk berlangganan event yang dihasilkan oleh pipeline PPE Analytics pada stream tertentu, buka koneksi WebSocket ke endpoint berikut:
ws://<host>:4004/event_channel/{node_num}/{stream_id}/NFV4-PPESetelah koneksi terbuka, server akan langsung mendorong (push) setiap event ke client tanpa perlu handshake atau pesan subscribe. Tutup koneksi untuk berhenti menerima event.
Parameter Path
| Parameter | Tipe | Deskripsi |
|---|---|---|
node_num | integer | Nomor node tempat stream berjalan (0 = master) |
stream_id | string | ID stream yang akan dipantau |
Query Parameter (Opsional)
| Parameter | Tipe | Deskripsi |
|---|---|---|
logic | string | Filter event berdasarkan nama logic rule yang aktif pada pipeline. Tanpa parameter ini, semua event dari analitik akan dikirim. |
Contoh Koneksi
const ws = new WebSocket(
'ws://localhost:4004/event_channel/0/<stream_id>/NFV4-PPE'
);
ws.onmessage = (msg) => {
const event = JSON.parse(msg.data);
console.log(event.primary_text, event.pipeline_data);
};
ws.onerror = (err) => console.error('WebSocket error', err);
ws.onclose = () => console.log('Disconnected');import asyncio
import json
import websockets
async def listen():
url = "ws://localhost:4004/event_channel/0/<stream_id>/NFV4-PPE"
async with websockets.connect(url) as ws:
async for msg in ws:
event = json.loads(msg)
print(event["primary_text"], event["pipeline_data"])
asyncio.run(listen())curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Sec-WebSocket-Key: $(openssl rand -base64 16)" \
--header "Sec-WebSocket-Version: 13" \
"http://localhost:4004/event_channel/0/<stream_id>/NFV4-PPE"Visualisasi (MJPEG)
GET /mjpeg/{node_num}/{stream_id}/NFV4-PPE
Mengambil stream MJPEG dengan overlay deteksi dari pipeline yang berjalan. Berguna untuk verifikasi konfigurasi area dan validasi hasil deteksi secara visual.
Parameter Query (Opsional)
| Parameter | Tipe | Deskripsi | Default |
|---|---|---|---|
fps | integer | Frame rate output MJPEG | 15 |
height | integer | Tinggi frame output dalam piksel | 480 |
Contoh
# Buka di browser untuk preview langsung
http://localhost:4004/mjpeg/0/stream_001/NFV4-PPE?fps=15&height=480