Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion controller/config/reid-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"stale_feature_check_interval_secs": 1.0,
"feature_accumulation_threshold": 12,
"feature_slice_size": 10,
"similarity_threshold": 60
"similarity_threshold": 60,
"vector_dimensions": 256
}
Comment on lines 5 to 8
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new vector_dimensions option is added to reid-config.json, but the controller documentation that describes this config file (e.g. docs/user-guide/microservices/controller/Extended-ReID.md) does not mention this setting yet. Please document what this value controls (VDMS schema dimensions + expected embedding length) and any compatibility constraints with the embedding producer/decoder.

Copilot uses AI. Check for mistakes.
10 changes: 6 additions & 4 deletions controller/src/controller/uuid_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import time
from unittest import result

from controller.vdms_adapter import VDMSDatabase
from controller.vdms_adapter import VDMSDatabase, DIMENSIONS
from scene_common import log
from scene_common.timestamp import get_epoch_time

Expand All @@ -35,15 +35,17 @@ def __init__(self, database=DEFAULT_DATABASE, reid_config_data=None):
self.features_for_database_timestamps = {} # Track when features were added
self.quality_features = {}
self.unique_id_count = 0
self.reid_database = available_databases[database]()
# Extract vector dimensions from reid config, pass to database
if reid_config_data is None:
reid_config_data = {}
vector_dimensions = reid_config_data.get('vector_dimensions', DIMENSIONS)
self.reid_database = available_databases[database](dimensions=vector_dimensions)
self.pool = concurrent.futures.ThreadPoolExecutor()
Comment on lines +38 to 43
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vector_dimensions is now read from reid_config_data and passed into VDMSDatabase(dimensions=...), but the existing UUIDManager unit tests don’t verify that this configuration value is actually applied. Adding a test that initializes UUIDManager(reid_config_data={"vector_dimensions": <non-default>}) and asserts VDMSDatabase is constructed with that dimensions argument would prevent regressions.

Copilot uses AI. Check for mistakes.
self.similarity_query_times = collections.deque(
maxlen=DEFAULT_MAX_SIMILARITY_QUERIES_TRACKED)
self.similarity_query_times_lock = threading.Lock()
self.reid_enabled = True
# Extract stale feature timeout from reid config, use default if not provided
if reid_config_data is None:
reid_config_data = {}
self.stale_feature_timeout_secs = reid_config_data.get('stale_feature_timeout_secs', DEFAULT_STALE_FEATURE_TIMEOUT_SECS)
self.stale_feature_check_interval_secs = reid_config_data.get('stale_feature_check_interval_secs', DEFAULT_STALE_FEATURE_CHECK_INTERVAL_SECS)
self.stale_feature_timer = None
Expand Down
6 changes: 3 additions & 3 deletions controller/src/controller/vdms_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ def addEntry(self, uuid, rvid, object_type, reid_vectors, set_name=SCHEMA_NAME,
add_query = []
for reid_vector in reid_vectors:
# Ensure vector is properly formatted as 1D array of float32
# reid_vector might be shape (1, 256) from moving_object, need to flatten to (256,)
# reid_vector might be shape (N,) from moving_object, need to flatten to (N,)
vec_array = np.asarray(reid_vector, dtype="float32").flatten()
if vec_array.shape[0] != 256:
log.warning(f"addEntry: Expected vector shape (256,) but got {vec_array.shape}, skipping this vector")
if vec_array.shape[0] != self.dimensions:
log.warning(f"addEntry: Expected vector shape ({self.dimensions},) but got {vec_array.shape}, skipping this vector")
continue
Comment on lines 146 to 152
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all vectors are skipped due to a dimension mismatch, add_query and descriptor_blobs can be empty but sendQuery(add_query, descriptor_blobs) is still called. This can produce misleading errors ("No response" for 0 vectors) or potentially trigger errors in the VDMS client when querying with an empty command list. Consider short-circuiting when no valid vectors remain (log at debug/warn and return) before calling sendQuery.

Copilot uses AI. Check for mistakes.
descriptor_blobs.append(vec_array.tobytes())
# Create query dict for each vector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,18 @@ def reidPolicy(pobj, item, fw, fh):
name = tensor.get('name','')
if name and ('reid' in name or 'embedding' in name):
reid_vector = tensor.get('data', [])
v = struct.pack("256f",*reid_vector)
# Handle variable-length re-id vectors from different models
if not reid_vector:
continue
vector_len = len(reid_vector)
# Pack vector with its actual dimensions
format_string = f"{vector_len}f"
try:
v = struct.pack(format_string, *reid_vector)
Comment on lines +40 to +47
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pipeline now packs the ReID embedding using its runtime length, but the Scene Controller currently decodes base64 embeddings with a fixed struct.unpack("256f", ...) (e.g., controller/src/controller/moving_object.py). With vector_dimensions configurable on the controller side, this change will make non-256 embeddings fail to decode or be silently dropped later due to dimension checks. Consider emitting the vector length/dimensions alongside the embedding (or keeping the packing size aligned to the configured dimensions) so producer/consumer stay compatible.

Copilot uses AI. Check for mistakes.
except struct.error as e:
import sys
print(f"Failed to pack reid vector of length {vector_len}: {e}", file=sys.stderr)
continue
# Move reid under metadata key
if 'metadata' not in pobj:
pobj['metadata'] = {}
Expand Down
Loading