People counting API - not getting any results

Trevor B

n3wb
Joined
Apr 23, 2024
Messages
6
Reaction score
6
Location
United Kingdom
Hi

I have a frustrating problem trying to get people counting results via ISAPI. I have tried Hikvision support but just end up going around in circles, so thought I would try here and see if anyone can spot anything that I am doing wrong.

We have a iDS-2CD7146G0-IZHSY camera (firmware V5.8.10 build 230220) with people counting enabled.

I can see the data on the camera ‘application’ webpage like this:

hik1.jpg

But no matter how I try, I cannot get the same data returned via ISAPI. I have looked online and as far as I can see all of my call is correct, yet it returns 0 for the counts for each time period and doesn’t reflect the counts on the camera webpage.

I am making the call to this endpoint:

/ISAPI/System/Video/inputs/channels/1/counting/search

With this payload via a POST:

<?xml version="1.0" encoding="UTF-8"?>
<countingStatisticsDescription version="2.0" xmlns="谢生服装">
<statisticType>all</statisticType>
<reportType>daily</reportType>
<timeSpanList>
<timeSpan>
<startTime>2024-04-22T00:00:00Z</startTime>
<endTime>2024-04-22T23:59:00Z</endTime>
</timeSpan>
</timeSpanList>
</countingStatisticsDescription>

Which should return the same results as the web page?

But this is a snippet of what I see:

<matchElement>
<timeSpan>
<startTime>2024-04-22T12:00:00</startTime>
<endTime>2024-04-22T12:59:59</endTime>
</timeSpan>
<enterCount>0</enterCount>
<exitCount>0</exitCount>
<peoplePassingCount>0</peoplePassingCount>
<duplicatePeopleCount>0</duplicatePeopleCount>
<RegionList>
</RegionList>
</matchElement>
<matchElement>
<timeSpan>
<startTime>2024-04-22T13:00:00</startTime>
<endTime>2024-04-22T13:59:59</endTime>
</timeSpan>
<enterCount>0</enterCount>
<exitCount>0</exitCount>
<peoplePassingCount>0</peoplePassingCount>
<duplicatePeopleCount>0</duplicatePeopleCount>
<RegionList>
</RegionList>
</matchElement>


I am using POSTMAN to test this. I would have thought there should be some +ve number counts in this result but thay are always zero?

Obviously I can talk to the API fine, credentials are correct etc. as it is returning something. But not the results I expected.

Can you see what I might be doing wrong here please? So I can get the API call working correctly. Is there something else I need to enable on the camera to get the results I require?

The curious thing is we also have people counting enabled on another Hikvision camera. And I have exactly the same issue. So it is either something wrong with the call I am making or something not enabled on both cameras.

Many thanks

Trevor
 

Trevor B

n3wb
Joined
Apr 23, 2024
Messages
6
Reaction score
6
Location
United Kingdom
Hi

I actually think I have found the answer to my own question.

So I will put my findings here in case anyone else has a similar issue.

I used 'Charles' to monitor what the actuall call was from the people counting 'application' page on the camera was and I could see there was an additional parameter in the XML that I wasn't sending and the was '<regionID>'. Once I included this in the call, I started to get results.

This was not in the documentation as far as I can remember or I would have used it previously.

So my full working call is now:

<?xml version="1.0" encoding="UTF-8"?>
<CountingStatisticsDescription>
<statisticType>all</statisticType>
<reportType>daily</reportType>
<timeSpanList>
<timeSpan>
<startTime>2024-04-22T00:00:00</startTime>
<endTime>2024-04-22T23:59:59</endTime>
</timeSpan>
</timeSpanList>
<regionID>1</regionID>
</CountingStatisticsDescription>

Hope this helps someone in the future.

Trevor
 

trempa92

Pulling my weight
Joined
Mar 26, 2020
Messages
762
Reaction score
233
Location
Croatia,Zagreb
It was not in documentation because this is not "real" people counting camera, its serie 7 firmware enabled people counting vca. Hence the changes. Its accuracy is way lower than people counting cameras that are mounted at 90 degree with 1 region only.

This can have multiple regions

Nice that you figured it out, dev tools are awesome.
 

trempa92

Pulling my weight
Joined
Mar 26, 2020
Messages
762
Reaction score
233
Location
Croatia,Zagreb
Here is body for multi target counting as your camera can handle

/ISAPI/Event/channels/1/SearchRegionTargetNumberCounting?format=json

{
"ReportCond":
{
"reportType": "monthly",
"ruleID": 1,
"statisticalDirection": "bothway",
"statisticalObjectives":
[
"human",
"nonMotor",
"vehicle"
],
"statisticalTime": "2024-24-04T00:00:00"
}
}
 

Trevor B

n3wb
Joined
Apr 23, 2024
Messages
6
Reaction score
6
Location
United Kingdom
Thank you for taking the time to post the additional comments regarding the poeple counting, that is very interesting to know.

The camera was sold to us as a 'people counting' camera and also a 'facial recognition' camera, although I appreciate we cannot have both running at the same time.

I have never been able to get the facial recognition to work as expected via the API either and this could also be a consequence of what you have mentioned above.

We utilise the APIs on the Hikvision cameras and boxes here a fair bit. For example, we have our own software for alerting across the site as soon as a known number plate of a shop lifter is detected and this works very well. But we wanted to extend the alerting to facial recognition because it is possible known shop lifters could potentially come in a different vehicle, so the facial recognition would be better. But, again, following what I thought was the correct documentation I have never got it to work correctly.

But I can see now that this documentation may not be applicable for this camera either, as you metioned above, if it is not a 'true' camera for these purposes.

Thanks for your help and pointing this out, it makes more sense now why the people counting didn't work as expected!

And, yes, dev tools are amazing, make life as a developer so much easier, Postman and Charles are 2 of my 'go to' tools :)
 

trempa92

Pulling my weight
Joined
Mar 26, 2020
Messages
762
Reaction score
233
Location
Croatia,Zagreb
Facial recognition can work but VCA needs to be turned on for it. Then you have groups and you can set notify surrveillance center for each group trigger.

Make a TCP server listener and realtime data will be sent there. Server ip you add to camera settings under Alarm server or HTTP Listener server. Name depends on firmware

Data you receive will be multipart data containing either json or xml as text and binary image of trigger moment, and optionally the image that was compared to from library
 

Trevor B

n3wb
Joined
Apr 23, 2024
Messages
6
Reaction score
6
Location
United Kingdom
Thank you again for your help and pointers. I will go back and revisit this. At the time I was trying to analyse the alert stream, but it just wasn't working consistently. I will go back and have another look at this.

Thank you :)
 

trempa92

Pulling my weight
Joined
Mar 26, 2020
Messages
762
Reaction score
233
Location
Croatia,Zagreb
Its quite simple to be honest, only options that will have differences is ANR . If you enable ANR for each event you get you need to return OK() otherwise it will loop same event. It is good for bad conectivity so you dont lose events.
 

Trevor B

n3wb
Joined
Apr 23, 2024
Messages
6
Reaction score
6
Location
United Kingdom
Its quite simple to be honest, only options that will have differences is ANR . If you enable ANR for each event you get you need to return OK() otherwise it will loop same event. It is good for bad conectivity so you dont lose events.
Thank you - I will look out for this. I use quite a good library for HTTP development, so this should not be a problem (I develop in Delphi/Pascal using the Securebridge library from Devart for the final release software).

Thanks again for the advice, any little thing always helps!
 

trempa92

Pulling my weight
Joined
Mar 26, 2020
Messages
762
Reaction score
233
Location
Croatia,Zagreb
If you were to say asp.net then i could've shared examples :)

I made myself an asp.net core API that fetch/parse/prepare all i need and then i utilize this API server with flutter application which is multi platform (web/android/windows/linux/mac/ios).

So far, LPR, Peoplecounting, hikvision alarms, access controll have been done. I will be expanding to multitarget counting statictics, and facial recognition via library from camera's/nvr's (altho i already have face recognition in ACS for FR terminals, but its different)
 

Trevor B

n3wb
Joined
Apr 23, 2024
Messages
6
Reaction score
6
Location
United Kingdom
We have discussed this this morning and we are going to order a new camera for the facial recognition as we need the people counting on the other camera, albeit if it is not so accurate it gives us some results. Once the new camera is here then I have something I can play with and spend a bit more time on to get the facial recognition working. My aim is to combine the ANPR and Facial Recognition alerts. At the moment we have software on all PCs on site that pops up a warning when a 'bad' plate is detected on the ANPR camera. So my plan is to extend this to also pop up when a face is matched.

Sadly I am not an ASP.NET person! But I do know Securebridge pretty well now and what it is capable of and I should be able to get this to work following your advice about the listener. I use APIs extensively and one of those is a listener for our eCommerce site, so I should be able to get something working.

It is good to know that someone has already done this. If I get really stuck, I might pop back here with the odd question. But I promise not to bother you too much! I do like to make sure I have exhasuted all my knowledge before having to ask.

Many thanks again.
 
Top