mirror of
https://github.com/azaion/detections.git
synced 2026-04-22 12:16:32 +00:00
[AZ-178] Implement streaming video detection endpoint
- Added `/detect/video` endpoint for true streaming video detection, allowing inference to start as upload bytes arrive. - Introduced `run_detect_video_stream` method in the inference module to handle video processing from a file-like object. - Updated media hashing to include a new function for computing hashes directly from files with minimal I/O. - Enhanced documentation to reflect changes in video processing and API behavior. Made-with: Cursor
This commit is contained in:
@@ -199,6 +199,25 @@ cdef class Inference:
|
||||
writer_done.wait()
|
||||
wt.join(timeout=3600)
|
||||
|
||||
cpdef run_detect_video_stream(self, object readable, AIRecognitionConfig ai_config, str media_name,
|
||||
object annotation_callback, object status_callback=None):
|
||||
cdef str original_media_name
|
||||
self._annotation_callback = annotation_callback
|
||||
self._status_callback = status_callback
|
||||
self.stop_signal = <bint>False
|
||||
self.init_ai()
|
||||
if self.engine is None:
|
||||
constants_inf.log(<str> "AI engine not available. Conversion may be in progress. Skipping inference.")
|
||||
return
|
||||
original_media_name = media_name.replace(" ", "")
|
||||
self.detection_counts = {}
|
||||
self.detection_counts[original_media_name] = 0
|
||||
container = av.open(readable)
|
||||
try:
|
||||
self._process_video_pyav(ai_config, original_media_name, container)
|
||||
finally:
|
||||
container.close()
|
||||
|
||||
cdef _process_video_pyav(self, AIRecognitionConfig ai_config, str original_media_name, object container):
|
||||
cdef int frame_count = 0
|
||||
cdef int batch_count = 0
|
||||
|
||||
Reference in New Issue
Block a user