CameraEvents Service - Dahua Events to mqtt

Discussion in 'Home Automation' started by psycik, Feb 25, 2019.

Share This Page

  1. Ole

    Ole n3wb

    Joined:
    Feb 5, 2018
    Messages:
    7
    Likes Received:
    0
    Hi,

    my Model is the Synology DS718+ ( LINK to Specs ).

    I am using the Synology Docker Package and for example this Image: Mosquitto and this Unifi Controller. Both are running without any Problem.

    Here is also a list of the architecture per Synology NAS: LINK
    There is stated that the Docker Package uses X64, afaik.

    Thanks for your help.

    Regards Sven
     
    Last edited: May 24, 2019
  2. kiwijunglist

    kiwijunglist n3wb

    Joined:
    Jul 14, 2018
    Messages:
    27
    Likes Received:
    7
    Location:
    New Zealand
    Hi Psyciknz.

    I'm also in New Zealand. I'm a bit stuck trying to use your github.

    Whats the command for building the docker image. I'm used to having a file called "dockerbuild" not "dockerbuild.cross". I can't figure out how to use it the .cross file. PS. I'm using linux.

    If i try and just run the script directly, i get the following error:

    mike@server:~/.docker/config/dahua-mqtt-script$ python3 CameraEvents.py
    File "CameraEvents.py", line 282
    except Exception,ivsExcept:
    ^
    SyntaxError: invalid syntax
     
    Last edited: Jun 23, 2019
  3. Ole

    Ole n3wb

    Joined:
    Feb 5, 2018
    Messages:
    7
    Likes Received:
    0
    Hi,

    I finally got it running in docker on my synology NAS.

    My camera is a IPC-HDW5231R-ZE. I created a rule on the camera for CrossLineDetection, which is detected by the script correctly. But there are not Details on the IVS data like e.g. crossingdirection. Is IVS data depending on the camera model or is there something more to define in the config?

    Here is the log for one event:
    Code:
    2019-06-23 13:11:54,254 - __main__ - DEBUG - [Carport]: --myboundary
    Content-Type: text/plain
    Content-Length:44
    Code=CrossLineDetection;action=Start;index=0
    
    2019-06-23 13:11:54,254 - __main__ - ERROR - Error getting IVS data: 'data'
    2019-06-23 13:11:54,306 - __main__ - INFO - Snapshot Url: http://172.17.2.20:80/cgi-bin/snapshot.cgi?channel=0
    2019-06-23 13:11:56,681 - __main__ - DEBUG - [Carport]: --myboundary
    Content-Type: text/plain
    Content-Length:43
    Code=CrossLineDetection;action=Stop;index=0
    Regards, Sven
     
    Last edited: Jun 23, 2019
  4. psycik

    psycik Getting the hang of it

    Joined:
    Dec 9, 2015
    Messages:
    149
    Likes Received:
    19
    Location:
    Wellington, New Zealand
    https://hub.docker.com/r/psyciknz/cameraevents

    Here’s a built and image. The dockerfile cross needs you to run the build.sh which creates a dockerfile per architecture by replacing some txt. But it also needs qemu on your build machine.
     
  5. psycik

    psycik Getting the hang of it

    Joined:
    Dec 9, 2015
    Messages:
    149
    Likes Received:
    19
    Location:
    Wellington, New Zealand
    The lack of details suggests your camera it not a high enough firmware, or just doesn’t post the json that I saw in mine.

    Do you get an event fired? As it should just end up like a video motion event which also has very little details.
     
  6. Ole

    Ole n3wb

    Joined:
    Feb 5, 2018
    Messages:
    7
    Likes Received:
    0
    Hi,

    yes I get an event. But the payload is just "CrossLineDetection". For MotionDetection there are two messages with payload "on" and "off".

    Details of my camera:
    Code:
    Device Type:      IPC-HDW5231R-ZE
    System Version:   2.622.0000000.18.R, Build Date: 2017-11-10
    WEB Version:      3.2.1.515090
    ONVIF Version:    16.12(V2.4.1.510971)
    
    Could you check with your camera what version you are running?
    Is there a way I can check if my camera provides a different json string?

    EDIT:
    Updated the Firmware:

    Code:
    Device Type:     IPC-HDW5231R-ZE
    System Version:   V2.800.0000005.0.R, Build Date: 2019-03-25
    WEB Version:   V3.2.1.709882
    ONVIF Version:   16.12(V2.4.3.651299)
    
    Now I get more Details :)
    "CrossLineDetection With Human in LeftToRight direction for Entrance Region"


    Regards Sven
     
    Last edited: Jun 23, 2019
  7. psycik

    psycik Getting the hang of it

    Joined:
    Dec 9, 2015
    Messages:
    149
    Likes Received:
    19
    Location:
    Wellington, New Zealand
    That's great. I might, cos it annoys me, make the detected "things" filterable. ie I get "smoke" when it's fuzziness on the camera, so I will exclude those. That will just leave Human and Vehicle.
     
  8. kiwijunglist

    kiwijunglist n3wb

    Joined:
    Jul 14, 2018
    Messages:
    27
    Likes Received:
    7
    Location:
    New Zealand
    Hi I still have not been able to get this going.

    This is my docker-compose.yaml

    Code:
      dahua_camera_events:
    
        container_name: dahua_camera_events
        image: psyciknz/cameraevents
        restart: always
    I was getting this error in the log:

    Code:
    2019-06-26 09:49:18,243 - __main__ - ERROR - Error starting:Failed to open/find all files,
    2019-06-26 09:49:18,242 - __main__ - INFO - Loading config,
    So i went and created a config.ini using config-master.ini and changed the docker-compose to:

    Code:
      dahua_camera_events:
        container_name: dahua_camera_events
        image: psyciknz/cameraevents
        restart: always
        volumes:
          - ${DOCKERCONFDIR}/dahua_camera_events/config.ini:/config.ini
    However I still get errors in the log for the dahua_camera_events container

    Code:
    2019-06-26 09:48:51,381 - __main__ - ERROR - Error starting:Failed to open/find all files,
    2019-06-26 09:48:51,381 - __main__ - INFO - Loading config
    Q: Is there a different settings file I need to use for the docker image vs the github page?

    Q: Can someone please post their compose.yaml ?
     
    Last edited: Jun 26, 2019
  9. kiwijunglist

    kiwijunglist n3wb

    Joined:
    Jul 14, 2018
    Messages:
    27
    Likes Received:
    7
    Location:
    New Zealand
    There is no build.sh included.
     
  10. psycik

    psycik Getting the hang of it

    Joined:
    Dec 9, 2015
    Messages:
    149
    Likes Received:
    19
    Location:
    Wellington, New Zealand
    1. cameraevents:
    2. container_name: cameraevents
    3. depends_on:
    4. - mosquitto
    5. environment:
    6. - ARCH=amd64
    7. - BASEPATH=/hdd/docker-data
    8. #env_file:
    9. # - /hdd/docker-data/env/arch.env
    10. image: psyciknz/cameraevents
    11. restart: always
    12. networks:
    13. - ha
    14. volumes:
    15. - ${BASEPATH}/ha-shared/cameraevents/:/opt/cameraevents/conf
    16. - "/etc/timezone:/etc/timezone:ro"
    17. - "/etc/localtime:/etc/localtime

    Sorry posted from phone. Volume command is just to the directory.

    The instructions are a little light as I wrote it for me then decided to publish. And I have have much feed back either way to the problems with it.
     
  11. kiwijunglist

    kiwijunglist n3wb

    Joined:
    Jul 14, 2018
    Messages:
    27
    Likes Received:
    7
    Location:
    New Zealand
    Thanks.

    What files should I put in
    ${BASEPATH}/ha-shared/cameraevents/

    Do I dump the files from the GitHub into that folder?
     
  12. psycik

    psycik Getting the hang of it

    Joined:
    Dec 9, 2015
    Messages:
    149
    Likes Received:
    19
    Location:
    Wellington, New Zealand
    Just the config.ini

    The problem with most docker containers is they can’t prepopulate the host volumes with a default config. So always have to revert to this sort of manual config to start with
     
  13. psycik

    psycik Getting the hang of it

    Joined:
    Dec 9, 2015
    Messages:
    149
    Likes Received:
    19
    Location:
    Wellington, New Zealand
    I've just updated the readme and added run instructions.

    I probably wouldn't use my entry of ${BASEPATH}/ha-shared/cameraevents/ since there's a variable in there and it defines a fixed path.
    But if you make a cameravents dir, put the config in there, then run the
    Code:
    docker run -v ${PWD}:/opt/cameraevents/conf psyciknz/cameraevents
    you should hopefully get something going.
     
    kiwijunglist likes this.
  14. kiwijunglist

    kiwijunglist n3wb

    Joined:
    Jul 14, 2018
    Messages:
    27
    Likes Received:
    7
    Location:
    New Zealand
    Thanks. Yea I recognised the $variable. I'll try this tonight and hopefully I'll get in going. Thanks for your help.
     
  15. psycik

    psycik Getting the hang of it

    Joined:
    Dec 9, 2015
    Messages:
    149
    Likes Received:
    19
    Location:
    Wellington, New Zealand
    How’d you get on?
     
    kiwijunglist likes this.
  16. kiwijunglist

    kiwijunglist n3wb

    Joined:
    Jul 14, 2018
    Messages:
    27
    Likes Received:
    7
    Location:
    New Zealand
    It's working.

    I haven't played around with all the events yet, so I'm not sure what's supported by the docker.

    Can the docker send different mqtt messages for different events so I can have a sensor for face detection in home assistant as well as for motion?
     
  17. psycik

    psycik Getting the hang of it

    Joined:
    Dec 9, 2015
    Messages:
    149
    Likes Received:
    19
    Location:
    Wellington, New Zealand
    Not sure. POSs not. They might all just get identified as Ivs. Can you filter on the content is they’re all in the same topic?

    My camera doesn’t tend to do face recognition so I haven’t played with it. I just use line detection and trip wire (and video motion)
     
  18. kiwijunglist

    kiwijunglist n3wb

    Joined:
    Jul 14, 2018
    Messages:
    27
    Likes Received:
    7
    Location:
    New Zealand
    I think everything just gets lumped together but I haven't spent much time looking into it.
     
  19. DDDRelic

    DDDRelic n3wb

    Joined:
    Nov 28, 2017
    Messages:
    8
    Likes Received:
    7
    @psycik Do you know what units the Center and Bounding Box values are?
    The values I receive appear to be too large to be pixels.
    I was hoping to use this information to locate where people/cars etc are and take actions accordingly.
     
  20. psycik

    psycik Getting the hang of it

    Joined:
    Dec 9, 2015
    Messages:
    149
    Likes Received:
    19
    Location:
    Wellington, New Zealand
    Not sure sorry.