I have a problem, I cannot access the line count data of stream 2.
In flow 1, I have the counting lines output_Izq, input_Izq, output_IDI and input_IDI, they work correctly and in flow 2 I have output_Der and input_Der and between them they don’t work.
I mean the count data of stream 1 cannot access the count data of stream 2. And I don’t know how to differentiate when the loop is executed for one stream or for the other.
I attach my output and my code:
##################################################
Linecrossing Cumulative: {‘salidaIzq’: 0, ‘entradaIzq’: 0, ‘salidaIDI’: 1, ‘entradaIDI’: 0}
Traceback (most recent call last):
File “deepstream_nvdsanalytics.py”, line 134, in nvanalytics_src_pad_buffer_probe
salida_der = data[‘salidaDer’]
KeyError: ‘salidaDer’
##################################################
Linecrossing Cumulative: {‘salidaDer’: 1, ‘entradaDer’: 1}
Traceback (most recent call last):
File “deepstream_nvdsanalytics.py”, line 136, in nvanalytics_src_pad_buffer_probe
salida_izq = data[‘salidaIzq’]
KeyError: ‘salidaIzq’
l_user = frame_meta.frame_user_meta_list
while l_user:
try:
user_meta = pyds.NvDsUserMeta.cast(l_user.data)
if user_meta.base_meta.meta_type == pyds.nvds_get_user_meta_type("NVIDIA.DSANALYTICSFRAME.USER_META"):
user_meta_data = pyds.NvDsAnalyticsFrameMeta.cast(user_meta.user_meta_data)
if user_meta_data.objInROIcnt: print("Objs in ROI: {0}".format(user_meta_data.objInROIcnt))
if user_meta_data.objLCCumCnt:
print("Linecrossing Cumulative: {0}".format(user_meta_data.objLCCumCnt))
data = user_meta_data.objLCCumCnt
salida_der = data['salidaDer']
entrada_der = data['entradaDer']
salida_izq = data['salidaIzq']
entrada_izq = data['entradaIzq']
salida_idi = data['salidaIDI']
entrada_idi = data['entradaIDI']
aforoTI= salida_idi+ entrada_izq + entrada_der - salida_izq - salida_der - entrada_idi
aforoIDI= entrada_idi-salida_idi
text = "Aforo en TI: " + str(aforoTI) + " Aforo en IDI: " + str(aforoIDI)
print(text)
#Código de NVOSD Printer
display_meta=pyds.nvds_acquire_display_meta_from_pool(batch_meta) #Retrieve NvDsDisplayMeta object from given NvDsBatchMeta object. See NvDsMeta docs for more details.
display_meta.num_labels = 1
py_nvosd_text_params = display_meta.text_params[0] #Retrieve NvOSD_TextParams object from list in display meta.
# Setting display text to be shown on screen
# Note that the pyds module allocates a buffer for the string, and the
# memory will not be claimed by the garbage collector.
# Reading the display_text field here will return the C address of the
# allocated string. Use pyds.get_string() to get the string content.
py_nvosd_text_params.display_text = "Aforo TI {} \nAforo IDI {}".format(aforoTI, aforoIDI)
# Now set the offsets where the string should appear
py_nvosd_text_params.x_offset = 18
py_nvosd_text_params.y_offset = 12
# Font , font-color and font-size
py_nvosd_text_params.font_params.font_name = "Serif" #Set attributes of our NvOSD_TextParams object's NvOSD_FontParams member
py_nvosd_text_params.font_params.font_size = 16
# set(red, green, blue, alpha); set to White
py_nvosd_text_params.font_params.font_color.set(1.0, 1.0, 1.0, 1.0) #See NvOSD_ColorParams for more details.
# Text background color
py_nvosd_text_params.set_bg_clr = 1 #Set boolean indicating that text has bg color to true.
# set(red, green, blue, alpha); set to Black
py_nvosd_text_params.text_bg_clr.set(0.1294, 0.447, 0.725, 1.0)
# Using pyds.get_string() to get display_text as string
print(pyds.get_string(py_nvosd_text_params.display_text))
pyds.nvds_add_display_meta_to_frame(frame_meta, display_meta) #Add display meta to frame after setting text params attributes.
#if user_meta_data.objLCCurrCnt: print("Linecrossing Current Frame: {0}".format(user_meta_data.objLCCurrCnt))
if user_meta_data.ocStatus: print("Overcrowding status: {0}".format(user_meta_data.ocStatus))
except StopIteration:
break
try:
l_user = l_user.next
except StopIteration:
break