OpenVisualCloud / Smart-City-Sample

The smart city reference pipeline shows how to integrate various media building blocks, with analytics powered by the OpenVINO™ Toolkit, for traffic or stadium sensing, analytics and management tasks.
BSD 3-Clause "New" or "Revised" License
186 stars 80 forks source link

How can I receive metaconvert and jpegenc in one class? #814

Open dhaval-zala-aivid opened 2 years ago

dhaval-zala-aivid commented 2 years ago

Hii @nnshah1

{ "name": "staff-engm-det", "version": 2, "type": "GStreamer", "template": [ "rtspsrc udp-buffer-size=212992 name=\"source\" ", " ! queue ! rtph264depay ! h264parse ! video/x-h264 ", " ! tee name=t ! queue ! decodebin ! queue leaky=upstream ", " ! gvadetect ie-config=CPU_BIND_THREAD=NO model=\"{models[{{ input_model_0 }}][1][network]}\" model-proc=\"{models[{{ input_model_0 }}][1][proc]}\" name=\"detection\" threshold=0.40 ", " ! queue ! gvametaconvert add-empty-results=true name=\"metaconvert\" ! gvapython name=\"peoplecounting\" module=\"custom_transforms/staffEngmDet\" class=\"StaffEngagementTime\" ! queue ! gvametapublish name=\"destination\" ", " ! tee name = tt ! queue ! gvawatermark ! videoconvert ! jpegenc ! gvapython name=\"ImageCapture\" module=\"custom_transforms/staffEngmDet\" class=\"ImageCapture\" ", " ! queue ! appsink name=appsink t. ! queue ! splitmuxsink mux=\"mp4mux fragment-duration=1000\" max-size-time=300000000000 name=\"splitmuxsink\""], "description": "staff-engm-det Pipeline", "parameters": { "type": "object", "properties": { "inference-interval": { "element": "detection", "type": "integer", "minimum": 0, "maximum": 4294967295 }, "cpu-throughput-streams": { "element": "detection", "type": "string" }, "n-threads": { "element": "videoconvert", "type": "integer" }, "nireq": { "element": "detection", "type": "integer", "minimum": 1, "maximum": 64 }, "recording_prefix": { "type": "string", "element": { "name": "splitmuxsink", "property": "location" }, "default": "recording" } } } }

here is the pipeline that we are using where there are two python classes one which is StaffEngagementTime receives metaconvert and another class that is ImageCapture receives jpegenc to capture the image. How can I receive metaconvert and jpegenc in one class?

divdaisymuffin commented 2 years ago

@nnshah1 Any help in this will be great. Actually this is causing us problem that sometimes a frame passes through metaconvert and do post-processing via gvapython, and then the same frame miss to go to the jpegenc and hence the event metadata generates but image being not captured.

dhaval-zala-aivid commented 1 year ago

As per our discussion in the last meet we have done this implementation with the same pipeline Here is the code:

class PeopleCount:    

    def __init__(self):
        self.object_id_list = []

    def process_frame(self, frame):
        print("frame1",(frame.data()))
        messages = list(frame.messages())
        try:

            with frame.data() as mat:
                print(mat)
        except Exception as error:
            print("Error",error)

        return True

class ImageCapture(object):
    def __init__(self):
        self.timestamp=0
        print("running")

    def process_frame(self,frame):

        print("frame2",(frame.video_meta()))
        messages = list(frame.messages())
        print("messages2",messages)

the mat variable in the PeopleCount class should be the image. But it shows an error.

Right now we get the analytics/metadata in PeopleCount and image in ImageCapture class. However, we want the image and analytics/metadata both in PeopleCount class only.

Error:

{"levelname": "INFO", "asctime": "2022-07-22 09:59:51,413", "message": "Loading Pipeline: algorithmName version: 1 type: GStreamer from /home/pipelines/algorithmName/1/pipeline.json", "module": "pipeline_manager"}
{"levelname": "INFO", "asctime": "2022-07-22 09:59:51,413", "message": "===========================", "module": "pipeline_manager"}
{"levelname": "INFO", "asctime": "2022-07-22 09:59:51,413", "message": "Completed Loading Pipelines", "module": "pipeline_manager"}
{"levelname": "INFO", "asctime": "2022-07-22 09:59:51,413", "message": "===========================", "module": "pipeline_manager"}
{"levelname": "INFO", "asctime": "2022-07-22 09:59:51,414", "message": "Creating Instance of Pipeline algorithmName/1", "module": "pipeline_manager"}
0:00:04.919655819     1      0x12c6850 ERROR                  libav :0:: SEI type 5 size 2216 truncated at 1928
dhaval-zala-aivid commented 1 year ago

Pipeline and the yolov4 model with the proc-file are here