hailo-ai / hailo-rpi5-examples

MIT License
387 stars 59 forks source link

Adding example for unix domain events-based integration #50

Open OriNachum opened 1 month ago

OriNachum commented 1 month ago

Currently, in order to integrate Hailo in my app, I need to take an example, and bring my code to it. It means I need to use the customized setup, etc.

This example allows for setting up Hailo as a separate app, then listen on its events stream and react.

This is an initial, working example

(Copying disclaimer from another PR) Disclaimer: I am not the owner or maintainer of this project. I'm open to feedback and further modifications if needed. This PR comes to address growing need by developers for a clean and smooth integration between their existing app and Hailo.

OriNachum commented 1 month ago

Should I revert the events on changes, or keep the new library? (DeepDiff)

OriNachum commented 1 month ago

Steps to set up integration from hailo side:

  1. Import event emitter and define event location:
    
    from unix_domain_socket_server import UnixDomainSocketServer

Path for the Unix Domain Socket

SOCKET_PATH = "/tmp/gst_detection.sock"


2. Set up event emitter:
socket_server = UnixDomainSocketServer(SOCKET_PATH)
socket_server.start()
user_data.socket_server = socket_server
  1. Fire events on app_callback end:
    # Call events server to fire event of a new detection
    user_data.socket_server.send_event(labels)
giladnah commented 3 weeks ago

Hi @OriNachum, I very much appreciate your contribution, and want to get contributions from the community. I want, however, to make sure that we do have some stable and simple examples and installation flows which are tested and verified.

I will add a new "community examples" directory in which you will be able to add your code. This way it will be much simple for me to approve your PR without worrying that it breaks something else. Give me some time to define the flow. I think it should include a simple README with installation instruction and a seperate requirements.txt file to handle your specific dependencies. I would be very happy to integrate your example as the first Community example and to get you inputs and thoughts about the flow. Thanks, Gilad

OriNachum commented 3 weeks ago

Thank you!

I appreciate the time and thought put into this. I think that's a great solution, and I am looking forward to test the "community examples" flow.