Nodeflux Central
Face Recognition

API Reference — Face Recognition

Endpoint REST API untuk membuat pipeline Face Recognition pada stream Visionaire4 dan event streaming hasil recognition via WebSocket.

Endpoint pipeline (/pipeline/...) memanggil Visionaire4 API — basis URL dikonfigurasi melalui variabel VISIONAIRE_API_URL (default: http://localhost:4004). Untuk endpoint enrollment, pencarian, dan manajemen keyspace pada layanan FREMIS-N, lihat API Reference FREMIS-N.

Autentikasi mengikuti konfigurasi deployment Visionaire4 Anda. Untuk detail instalasi dan konfigurasi layanan, lihat halaman Instalasi Dependensi.


Manajemen Pipeline

Endpoint untuk membuat dan menghapus pipeline Face Recognition pada stream video. Pipeline NFV4-FR menjalankan deteksi dan recognition standar; NFV4-FRA menambahkan analisis atribut demografis (gender, estimasi usia, pakaian) secara paralel.

POST
/pipeline/{node_num}/{stream_id}/NFV4-FR

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

node_num*integer

Nomor node dalam cluster. Gunakan 0 untuk deployment single node.

stream_id*string

Identifier unik untuk stream video. Digunakan sebagai referensi pada event output.

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:4004/pipeline/0/5136c6c0916cd30c/NFV4-FR" \  -H "Content-Type: application/json" \  -d '{    "fr_primary_threshold": 0.8,    "fr_secondary_threshold": 0.4,    "mode": 0,    "similarity_threshold": 0.85,    "fr_min_face_size": 48,    "frontal_only": true,    "sampling_time_ms": 50,    "fr_timeout_dump": 1500,    "fr_sampling_size": 8,    "static_object_sensitivity": 5,    "fr_blur_filter_threshold": 4  }'
{  "analytic_id": "NFV4-FR",  "code": 200,  "message": "pipeline successfully created",  "node_num": 0,  "stream_id": "5136c6c0916cd30c"}
{  "code": 400,  "message": "Invalid request"}
{  "code": 409,  "message": "Pipeline already exists"}
{  "code": 500,  "message": "Internal server error"}
DELETE
/pipeline/{node_num}/{stream_id}/NFV4-FR

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

node_num*integer

Nomor node dalam cluster. Gunakan 0 untuk deployment single node.

stream_id*string

Identifier unik untuk stream video. Digunakan sebagai referensi pada event output.

Response Body

application/json

application/json

curl -X DELETE "http://localhost:4004/pipeline/0/5136c6c0916cd30c/NFV4-FR"
{  "analytic_id": "NFV4-FR",  "code": 200,  "message": "pipeline successfully deleted",  "node_num": 0,  "stream_id": "5136c6c0916cd30c"}
{  "code": 404,  "message": "Stream not found"}
POST
/pipeline/{node_num}/{stream_id}/NFV4-FRA

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

node_num*integer

Nomor node dalam cluster. Gunakan 0 untuk deployment single node.

stream_id*string

Identifier unik untuk stream video.

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

curl -X POST "http://localhost:4004/pipeline/0/5136c6c0916cd30c/NFV4-FRA" \  -H "Content-Type: application/json" \  -d '{    "mode": 1,    "similarity_threshold": 0.75,    "fr_primary_threshold": 0.7,    "frontal_only": false,    "fr_min_face_size": 48,    "fr_max_fps": 5,    "fr_sampling_size": 5  }'
{  "analytic_id": "NFV4-FRA",  "code": 200,  "message": "pipeline successfully created",  "node_num": 0,  "stream_id": "5136c6c0916cd30c"}
{  "code": 400,  "message": "Invalid request: missing required field 'keyspace'"}
{  "code": 400,  "message": "Invalid request: missing required field 'keyspace'"}
DELETE
/pipeline/{node_num}/{stream_id}/NFV4-FRA

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

node_num*integer

Nomor node dalam cluster. Gunakan 0 untuk deployment single node.

stream_id*string

Identifier unik untuk stream video.

Response Body

application/json

application/json

curl -X DELETE "http://localhost:4004/pipeline/0/5136c6c0916cd30c/NFV4-FRA"
{  "analytic_id": "NFV4-FRA",  "code": 200,  "message": "pipeline successfully deleted"}
{  "code": 400,  "message": "Invalid request: missing required field 'keyspace'"}

Enrollment & Pencarian Wajah

Operasi enrollment, recognition, dan pencarian embedding kini didokumentasikan secara penuh di section FREMIS-N. Visionaire4 meneruskan request ke service FREMIS-N — gunakan basis URL FREMIS-N (FREMIS_N_API_URL) untuk memanggil endpoint berikut secara langsung:


Event Streaming (WebSocket)

Visionaire4 mengirim setiap event hasil deteksi/inferensi melalui WebSocket. Untuk berlangganan event yang dihasilkan oleh pipeline Face Recognition pada stream tertentu, buka koneksi WebSocket ke endpoint berikut:

Pipeline NFV4-FR (face recognition standar):

ws://<host>:4004/event_channel/{node_num}/{stream_id}/NFV4-FR

Pipeline NFV4-FRA (face recognition + atribut demografis):

ws://<host>:4004/event_channel/{node_num}/{stream_id}/NFV4-FRA

Gunakan NFV4-FR jika Anda hanya membutuhkan event identitas wajah. Gunakan NFV4-FRA jika pipeline juga menjalankan analisis atribut (gender, estimasi usia, pakaian) dan Anda ingin menerima field atribut dalam pipeline_data.

Setelah 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

ParameterTipeDeskripsi
node_numintegerNomor node tempat stream berjalan (0 = master)
stream_idstringID stream yang akan dipantau

Query Parameter (Opsional)

ParameterTipeDeskripsi
logicstringFilter event berdasarkan nama logic rule yang aktif pada pipeline. Tanpa parameter ini, semua event dari analitik akan dikirim.

Format Pesan

Setiap event yang diterima berbentuk JSON dengan struktur berikut:

{
  "event_id": "evt_123456",
  "stream_id": "<stream_id>",
  "analytic_id": "NFV4-FR",
  "node_num": 0,
  "timestamp_ms": 1674123456789,
  "primary_text": "John Doe",
  "secondary_text": "Employee",
  "pipeline_data": {
    /* field spesifik module — lihat "Output yang Dihasilkan" pada index.mdx */
  },
  "image_jpeg": "base64-encoded JPEG..."
}

Detail field pipeline_data untuk Face Recognition dijelaskan pada Output yang Dihasilkan di halaman utama.

Contoh Koneksi

const ws = new WebSocket(
  'ws://localhost:4004/event_channel/0/<stream_id>/NFV4-FR'
);

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-FR"
    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())

Filter Berdasarkan Logic

Jika pipeline menjalankan beberapa logic rule, Anda dapat memfilter event hanya untuk satu logic dengan menambahkan query parameter:

ws://<host>:4004/event_channel/{node_num}/{stream_id}/NFV4-FR?logic=<logic_name>

Endpoint Channel Lainnya

Untuk mendengarkan event yang lebih luas (lintas analitik atau lintas stream), gunakan endpoint berikut yang dijelaskan pada Developer Guide:

EndpointCakupan
WS /event_channel/Semua event dari seluruh node
WS /event_channel/{node_num}/Semua event dari satu node
WS /event_channel/{node_num}/{stream_id}Semua event dari satu stream (semua analitik)

On this page