psyciknz / CameraEvents

Dahua NVR/Camera Alerting to MQTT. Fairly specific to my needs, but also an attempt at starting to use travis.
Eclipse Public License 2.0
58 stars 19 forks source link

Question: Names of the IVS configurations #7

Closed goermezer closed 4 years ago

goermezer commented 4 years ago

Hi,

very cool script. It runs very stable for me in a docker container and sends the events from my Dahua IPC cameras to HomeAssistant. Is it possible to get the names for the configured lines and regions through MQTT? I would like to know, from which configured region or line the detected events come.

image

goermezer commented 4 years ago

Ok, I had to read a bit better:

CameraEvents/IVS/Garage CrossLineDetection With Human in RightToLeft direction for Gate region

It seems, that the region should be delivered. But I never got a message like this. I only find CrossLineDetection in the payload. I miss the part "With Human in RightToLeft direction for Gate region".

This is what the logs write:

Code=CrossRegionDetection;action=Start;index=0 2020-02-13 06:31:42,875 - main - ERROR - Error getting IVS data: 'data' 2020-02-13 06:31:42,876 - main - INFO - Snapshot Url: http://192.168.178.90:80/cgi-bin/snapshot.cgi?channel=1 2020-02-13 06:31:43,402 - main - ERROR - Error sending image: ('Connection aborted.', BadStatusLine("''",)) 2020-02-13 06:31:45,192 - main - DEBUG - [Dahua3]: --myboundary

psyciknz commented 4 years ago

Ok, I had to read a bit better:

CameraEvents/IVS/Garage CrossLineDetection With Human in RightToLeft direction for Gate region

It seems, that the region should be delivered. But I never got a message like this. I only find CrossLineDetection in the payload. I miss the part "With Human in RightToLeft direction for Gate region"

Some of this depends on the device doimg the sending. If you pull the logs and look for the detection event, I believe I dump the entire json string to the log. If its not json, your device might only trigger the alert, but not post the metadara.

psyciknz commented 4 years ago

Here is a full json alert where the rule is posted:

--myboundary
Content-Type: text/plain
Content-Length:1078

Code=CrossRegionDetection;action=Stop;index=1;data={
   "Action" : "Appear",
   "Class" : "Normal",
   "CountInGroup" : 1,
   "DetectRegion" : [
      [ 780, 3835 ],
      [ 780, 3857 ],
      [ 2129, 2644 ],
      [ 3137, 2752 ],
      [ 3705, 2189 ],
      [ 6371, 3879 ],
      [ 7768, 5222 ],
      [ 7427, 8104 ],
      [ 1983, 8126 ]
   ],
   "EventSeq" : 41,
   "FrameSequence" : 276649,
   "GroupID" : 0,
   "IndexInGroup" : 0,
   "LocaleTime" : "2020-02-13 14:05:25",
   "Mark" : 0,
   "Name" : "Courtyard",
   "Object" : {
      "Action" : "Appear",
      "BoundingBox" : [ 1448, 1584, 2808, 5984 ],
      "Center" : [ 2128, 3784 ],
      "Confidence" : 0,
      "FrameSequence" : 0,
      "LowerBodyColor" : [ 0, 0, 0, 0 ],
      "MainColor" : [ 0, 0, 0, 0 ],
      "ObjectID" : 3015,
      "ObjectType" : "Human",
      "RelativeID" : 0,
      "Source" : 0.0,
      "Speed" : 0,
      "SpeedTypeInternal" : 0
   },
   "PTS" : 43165676340.0,
   "RuleId" : 1,
   "Sequence" : 0,
   "Source" : 36048432.0,
   "Track" : null,
   "UTC" : 1581573925.0,
   "UTCMS" : 189
}

If you don't get this out and only see:

--myboundary
Content-Type: text/plain
Content-Length:1078

Code=CrossRegionDetection;action=Stop;index=1

Then I can't gather the rule area.

goermezer commented 4 years ago

I`m not sure whether my cams support that events, but I find a lot of information in /cgi-bin/configManager.cgi?action=getConfig&name=VideoAnalyseRule.

And I changed VideoAnalyseRule[0][0].Enable and VideoAnalyseRule[0][0].AlarmOutEnable to true by HTTP request.

When running CameraEvents, it shows:

Code=CrossRegionDetection;action=Start;index=0 2020-02-14 17:30:00,338 - main - ERROR - Error getting IVS data: 'data' 2020-02-14 17:30:00,340 - main - INFO - Snapshot Url: http://192.168.178.90:80/cgi-bin/snapshot.cgi?channel=0 2020-02-14 17:30:00,542 - main - ERROR - Error sending image: ('Connection aborted.', BadStatusLine("''",)) 2020-02-14 17:30:00,642 - main - DEBUG - [Dahua3]: --myboundary Content-Type: text/plain Content-Length:46

The image sometimes can not be downloaded because of timeouts. I live with it for the moment. But do you have an idea how I can find out if this should be supported?

psyciknz commented 4 years ago

It doesn’t look like you get the json data like my example. I don’t know from what firmware version that started.

Does http://192.168.178.90/cgi-bin/snapshot.cgi?channel=0. Work from a browser?

If this a camera or nvr? As in is there a channel=1?

goermezer commented 4 years ago

It is a camera, IPC-HDW4631C-A with System Version 2.460.GP01.16.R, Build Date: 2017-09-04.

http://192.168.178.90/cgi-bin/snapshot.cgi?channel=0 delivers an image as well as with channel=1.

goermezer commented 4 years ago

It seems that IPC-HDW4631C-A doesn`t provide these information. Closing the issue...