cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L1X for people counting algorithm

LNGUY.1
Associate

I'm trying to use VL53L1X for counting algorithm in the link: https://www.youtube.com/watch?v=c91Ve-g0J2U but I'm having a problem with accuracy.

Thanks to SparkFun_VL53L1X, I can set ROI centers to separate front/back zones. By measuring and analyzing the distances of targets within field of views of these zones, the main idea for counting algorithm is described in this link: https://www.st.com/resource/en/user_manual/dm00626942-counting-people-with-the-vl53l1x-longdistance-ranging-timeofflight-sensor-stmicroelectronics.pdf 

However, I am facing to a big problem according to the accuracy of distances. Even when I fixed the distances from sensor to ground, the received distances is fluctuating. Currently, I set sensor's position 2.3 m from the ground as well as ROI centers in (159, 231), 50ms for each loop but the result obtained while having someone cross the door isn't as expected(should be like the image below).

0693W000001sizFQAQ.pngThe normal case: obtained the same distances to front/back zones even when having someone in front zone or back zone. 

Have you ever faced this problem and can you please suggest a way to improve this case?

I'm also planning to test with 1 more sensor, it should be better but I'm not sure that it can work well. 

Thank you and best regards,

L-T-P NGUYEN

22 REPLIES 22
Yle.1
Associate II

My application is people counting too.Because when I test the STSW-IMG010's setting,it didn't work fine.I think maybe my door frame is too narrow to affect the validity of the data,so I decrease the ROI size. As I expected,using two ROIs 5x5 is work fine.I don't konw why does ROI center affect signal rate.As you said, 33ms is enough to get samples. So why change to 175 will be better?

My application is people counting too.Because when I test the STSW-IMG010's setting,it didn't work fine.I think maybe my door frame is too narrow to affect the validity of the data,so I decrease the ROI size. As I expected,using two ROIs 5x5 is work fine.I don't konw why does ROI center affect signal rate.As you said, 33ms is enough to get samples. So why change to 175 will be better?

Hi Julien,

I am with Yle here in that I also set my two people counting detection zones to a smaller size. I found that the default (8,16) zones provided poor accuracy (lots of variation in the distance measurement) when used in a normal doorway width (about 2,7m height). I use an "auto calibration" feature where I adjust the ROI sizes and capture data after each adjustment. The ROI size that provides the best repeatable accuracy is then chosen. Currently I have chosen (4,10) for the use case.

I have set timing budget and inter measurement to 50ms because the Lite driver only provides 20ms and 50ms setting, not 33ms.

I will try the new centers.

Yle, I also do something that one of the app notes described (maybe I did not understand it correctly and maybe Julien can comment?):

I keep a rolling window of X distance samples. X is currently set to 5 in my case. In other words I capture 5 distance readings and keep it in memory. As soon as a new reading is done, the oldest reading is forgotten (pushed out of the buffer).

I take the smallest distance reading of the 5 readings in memory and pass that value to the people counting algorithm. I found that this provided some stability...albeit minor. Julien, did I misunderstand the intention here?

Helgard

Julien NGUYEN
ST Employee

​Hi Helgard and Yle,

I think we have three main sensor parameters two adjust according to his own use case (ROI size, ROI Center, Timing Budget).

In your use case, it seems that you have narrow width door, and to avoid to sense on the door frame you need to reduce the ROI size (FoV). In my case, I have a large door (2.3 m Height and 1.3 m large) so I need to have the best sensitivity to detect even a small person or child 1.5 m.

Another factor, It seems that the center could be different from part to part so adding a kind of center calibration as you did is very smart. Last comment on what Helgard said about the last 5 reading in a buffer, it is similar to the algo implemented by a colleague in the new people counting release we are preparing.

So different ideas seem to converge. Concerning the timing budget don't forget to set the Inter-measurement period consequently otherwise you will not get as much as samples you think . Inter-measurement period = timing budget. You may probe the interrupt signal from the PIN3 of the Arduino connector CN8 on the expansion board to check the inter-measurement period. With the VL53L1X ULD driver you should be able to set the Timing budget at 33 ms (see api.c) . Thanks, Julien


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
HMull.1
Associate II

Hi Julien,

Thanks for your reply. I see that 33ms is an option in the ULD.

I actually meant that I adjust the two ROI and not the centers. But I see here now that the centers actually can make quite a difference so I will try to make that part of my calibration process.

If I want to adjust the center values for a typical doorway people counting application, is there a range in which I can adjust? For example...you suggested 175,231 as a good value. I'm struggling to understand what exactly those values mean in practice....but anyway, so if I want to test and calibrate the center values, I assume I will test values around those "ideal" values. My question is, where do I stop? In what range around those values do I test?

Helgard

Maybe as julien said you should use status = VL53L1X_GetSignalRate(dev, &SignalRate) to get the signal rate and test the different center’s signal rate?

I'm very interested in your auto calibration function. How does it work?

When a new version of code is released, is there any way I can get informed in the first place?

HMull.1
Associate II

Hi Yle,

I take a series of distance measurements and try to minimize the variance in the data. In other words: If I take 5 measurements and the distance readings are 2000, 2100, 2500, 1800, 2700 I know that there is too much variance. You should probably take more readings but this was just to serve as an example.

After determining that I need improved accuracy, I start to adjust the ROI. Based on the info above, I have also started to adjust the center variables in conjunction with the ROI. All just to get accurate, repeatable distance readings. These adjustments can be made quite quickly and you could code a small algorithm to settle on the best combination; Check distance reading variance, adjust, check again, adjust, etc.

Note that I do believe it will be best to keep the timing budget constant as Julien mentioned.

You will also have to be smart in your ROI and center variable choices. Keep in mind height and width of a door entry ways and the way it affects distance readings. Also keep in mind things like light/dark environments. Keep in mind that your centers should not deviate too much from what ST provides because the state machine relies on detecting objects in both ROIs (at the same time) as shown in the first post above.

You could probably determine accuracy with the GetSignalRate function as well (instead of relying on the distance measurements)

Hi Julien, have you guys released the new update yet? Thanks, James

Julien NGUYEN
ST Employee

Hi JPres.1

Sorry for the delay, the code is ready but the documentation is being updated ! I hope this week or the week after we will get the doc to upload the whole content on st.com

Thanks, Julien


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.