• Community
  • Motion detection & trigger generation from OAK Device

I am working on motion detection project. If motion is detected, then hardware pin should generate interrupt or it should send string on serial. Is there any examples for this? I have OAK-D-Pro-POE kit.

    Hi SwapnilBhole
    M8 has two pins that i believe are programmable.
    https://docs.luxonis.com/projects/hardware/en/latest/pages/NG9097pro/#connectors
    PIN1 - aux, script on how to read write -alex-luxonis/depthai-python400b6e0
    PIN5 - GPIO9

    Additionally the VBUSIN pin (M8 pin 5) can be programmed to output 5V (the feature of providing power to the connected accessory device), by driving GPIO 9 as output high. Depending on the application, this may serve as an output indicator by toggling it output high/low (but for low you may need to add a pull-down resistor to GND to discharge the residual voltage).
    Added some code here:
    alex-luxonis/depthai-python0434a97
    VBUS_OUT_GPIO_CTRL = 9
    GPIO.setup(VBUS_OUT_GPIO_CTRL, GPIO.OUT, GPIO.PULL_NONE)
    GPIO.write(VBUS_OUT_GPIO_CTRL, 1) # Enable 5V output

    UART example: https://docs.luxonis.com/projects/api/en/latest/samples/Script/script_uart/ - out of the box for 4P only

    Thanks,
    Jaka

      I have downloaded latest repo & trying to run code. I have attached error

        Hi SwapnilBhole
        Works fine on my side. Make sure to also update the depthai_sdk python package.

        Thanks,
        Jaka

        Hi SwapnilBhole ,
        I don't think the SDK is actually the best path to take for this. For motion detection - is that motion of some object in the view, or camera motion?

        For object motion, you could look into:

        For camera motion:

        • IMU, look at accelerometer, demo here
        • Feature tracker (same as above), if camera is moving, all/most features on the frame should move around.

        Thoughts on these approaches?

        Hi @erik is that motion of some object in the view, or camera motion? =? : Object

        I will try above links & will update

        Hi @jakaskerl : I have run example code & recordings are getting save.

        I am new in programming. once person is detected, I have to make GPIO high for few millisecond or print "capture" string on console. Can you guide for this?

        @SwapnilBhole Motion of some object in the view of the camera. Please use chatGpt (gpt4) for general programming questions, as it's much much faster and more accurate.
        Thanks, Erik