This works for me
l_obj = frame_meta.obj_meta_list
while l_obj is not None:
try:
obj_meta = pyds.NvDsObjectMeta.cast(l_obj.data)
user_meta_list = obj_meta.obj_user_meta_list
while user_meta_list is not None:
user_meta = pyds.NvDsUserMeta.cast(user_meta_list.data)
user_meta_data = user_meta.user_meta_data
if user_meta.base_meta.meta_type == pyds.nvds_get_user_meta_type("NVIDIA.DSANALYTICSOBJ.USER_META"):
user_meta_analytics = pyds_analytics.NvDsAnalyticsObjInfo.cast(user_meta.user_meta_data)
print(user_meta_analytics.lcStatus)
for frame data
l_user = frame_meta.frame_user_meta_list
while l_user is not None:
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"):
continue
user_meta_analytics = pyds_analytics.NvDsAnalyticsFrameMeta.cast(user_meta.user_meta_data)
print(user_meta_analytics.objLCCumCnt)
3 Likes
@norrarat.s - Yes that works perfect, thanks!
Yes it seems to be working now
Thanks @manojy for the guiding us and @norrarat.s for adding last piece to puzzle.
Hi All,
I am still having issues accessing the metadata for individual objects. I can get all the properties for my frame no problem ie:
l_frame = batch_meta.frame_meta_list
while l_frame is not None:
try:
frame_meta = pyds.NvDsFrameMeta.cast(l_frame.data)
l_user = frame_meta.frame_user_meta_list
while l_user is not None:
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"):
continue
user_meta_analytics = pyds_analytics.NvDsAnalyticsFrameMeta.cast(user_meta.user_meta_data)
print('objCnt',user_meta_analytics.objCnt)
print('objInROIcnt',user_meta_analytics.objInROIcnt)
print('objLCCumCnt',user_meta_analytics.objLCCumCnt)
print('objLCCurrCnt',user_meta_analytics.objLCCurrCnt)
print('ocStatus',user_meta_analytics.ocStatus)
print('unique_id',user_meta_analytics.unique_id)
print(user_meta_analytics.objLCCumCnt)
except Exception as ex:
print('Exception', ex)
try:
l_user = l_user.next
except StopIteration:
break
But i cant get the other part the work, as per @norrarat.s methods
The program doesnt crash, but my user_meta_list = obj_meta.obj_user_meta_list is always None.
l_obj = frame_meta.obj_meta_list
while l_obj is not None:
try:
# Casting l_obj.data to pyds.NvDsObjectMeta
obj_meta = pyds.NvDsObjectMeta.cast(l_obj.data)
user_meta_list = obj_meta.obj_user_meta_list
# print('user_meta_list', user_meta_list)
# print('class id', obj_meta.class_id)
while user_meta_list is not None:
try:
print('user_meta_list', user_meta_list)
user_meta = pyds.NvDsUserMeta.cast(user_meta_list.data)
user_meta_data = user_meta.user_meta_data
print('user_meta.base_meta.meta_type', user_meta.base_meta.meta_type)
if user_meta.base_meta.meta_type == pyds.nvds_get_user_meta_type(
"NVIDIA.DSANALYTICSOBJ.USER_META"):
user_meta_analytics = pyds_analytics.NvDsAnalyticsObjInfo.cast(
user_meta.user_meta_data)
print(user_meta_analytics.lcStatus)
except StopIteration:
break
try:
print('Next Meta List')
user_meta_list = user_meta_list.next
except StopIteration:
break
except Exception as ex:
print('Exception', ex)
try:
l_obj = l_obj.next
except StopIteration:
break
I have added direction detection and in the OSD i can see the object being assigned a direction
@niels.kjaergaard.madsen @priyanshthakore if anyone has some help
Regards Andrew
try this
if user_meta.base_meta.meta_type != pyds.nvds_get_user_meta_type("NVIDIA.DSANALYTICSOBJ.USER_META"):
continue
user_meta_analytics = pyds_analytics.NvDsAnalyticsObjInfo.cast(user_meta.user_meta_data)
print(user_meta_analytics.lcStatus)
Hello guys,
thanks for you efforts to get metadata for NvDsAnalytics. Everything works perfect!
I’ve create repo in GitHub pyds_analytics_meta, followed this one pyds_tracker_meta to simplify installation of python bindings for NvDsAnalyticsFrameMeta and NvDsAnalyticsObjInfo.
1 Like
@rostislav.etc
Thanks for the github repo I’ve just tried it.
I still have the same problem where print(“----NvDsAnalytics Object Info----”) contains no details
again this is because the line below is None.
user_meta_list = obj_meta.obj_user_meta_list
am I missing something in my pipeline/config ? I know for the tracker you need to enable past frame
Yes, I’ve update the source of example. It should be under first while
.
There’s no any addition options you need to enable. NvDsAnalytics*Meta have information only in frames, where according events appears: direction, crossing line or inside ROI, therefore, after check base_meta.meta_type you might not see info.
So the frame meta concept I understand, it will give you information about the analytics applied to a frame, ie for a line crossing you can read how many cars have crossed that line, this all works perfectly with:
frame_meta = pyds.NvDsFrameMeta.cast(l_frame.data)
The Part I am still not getting is the NvDsAnalyticsObjInfo, from what I understand, this is the AnalyticsMeta applied to objects in the scene? I thought the NvDsAnalyticsObjInfo would contain the direction a car is traveling, or if its within the bounds of an ROI filter.
But in my case I can only access the ROI and the line crossing, so i can see there is 1 object in the ROI or 8 cars have crossed a line, but I cant loop through my objects and read their NvDsAnalyticsObjInfo to discover which car is in the ROI.
I can clearly see an object has a Direction applied to their tag in the OSD, but i cant access that metadata
Hi, Were you able to solve this issue? I am also getting none for user_meta_list = obj_meta.obj_user_meta_list
How did you solve it?
@lakshay.chhabra Use deepstream 5.1 they have fixed the issue and added sample app for the same
could you post a link to this sample app, please?