How did I Make Large Crowd Analytics and Tracking with AI? Using YOLO V3, SORT, OPENCV AND PYTHON
HTML-код
- Опубликовано: 11 сен 2024
- By OpenRemote we where tasked to create a real time crowd detection and tracking module which would extract data like speed and direction and show this data inside the OpenRemote manager.
How did we manage to do this? Watch the video above!
Links:
CODE: github.com/ope...
Make sure to use the exact link above. This is because currently work is done on the project. When recording this video I used the project version with commit "d343e883cc0056acb6b37cde644eca06128a8a44". This version can be accesses using the link above! You could also try the newer version but because I am not working on the newer version I don't know how it will work.
For instruction to install the manager check the readme.md file in the github!
Credits:
Api communication: / adlnc
Gui implementation: Rezhep
Video detection and analytics: / sieuwe-elferink-a193a9157
Are you interested to see automated event recognition? Like for example a person is running or a fight is happening between persons? Let me know!
Might be interesting to apply this for sports - basketball, soccer, ...
Would def want to see this!
@@donhsi You mean anlysing how a team plays football using a camera? like what positions players are often standing, What speed players are running, How often players get close to each other?
@@terblanchedaniel5241 I am now working on a project where i am making a autonomous vehicle drive over public roads with ai for road detection and a drive model which uses ai for steering an throttle. After that project I will focus on making this!
Sieuwe Elferink yeap, think basketball or scoccer, automatically track each player for video_on_demand, or player analysis combing their position and speed...
Interesting project, imagine this method can implement in car to avoid collision😊
Please do a video on event/anomaly detection, I can't explain how helpful this is, thanks so much
I am now working on a new drone project. Will work on this after that!
@@sieuweelferink6852 Thanks :D looking forward to it
you saved my graduation project!! THX!!!!
😎 Thank you, Sir!!
great work and thanks for open sourcing it :)
Would love to get connected with you professionally. I also graduated from TUe. Have sent you connection request in linkedIn
Thanks for your request. I am still on fontys in eindhoven for some time but will accept your request.
Great work. Thank you for sharing code.
how to store the results over cloud or google drive ?
Very Helpful!
Hi Sieuwe , what i have noticed that when person cross each other or overlap their identity changes , so how to keep their identity constant.
Magnificent
nice work.. keep up the good work.
Good stuff sir!
Great work sir! I want to count the number of people entering a room using raspberry pi camera module. How can I achieve that?
hola esther. has logrado encontrar solucion para tu necesidad de contar personas en una sala?
Hi Sieuwe. Nice work indeed. Do you mind sharing which libraries were used and which version please because I'm trying to built up this project and I'm encountering multiple issues. Thank you and well done.
what are the exact infra requirements to run this code ?
Thanks for sharing this! Will it also work on Windows 10?
Did some more digging through my jetson nano.. now terminal throws up "Illegal instruction (core dumped)"
Nice video!
thanks this was very helpful. Keep up the good work
can u explain how to social distance detecton using visual ? i need for my project
Iam still having problem cropping the detected object im working with my own code can u figure out my problem?
if not track.is_confirmed() or track.time_since_update > 1:
continue
bbox = track.to_tlbr()
i can draw a rectangle around the detected object with cv2.rectangle(img, (int(bbox[0]), int(bbox[1])), (int(bbox[2]), int(bbox[3])), color, 2) but i cant crop it
hi, can u help me out to fix the issues? am in windows 10 - i can stream webcam vid and green line but object/person are not detected ! can tel what may be the issue?
Sir...I did the same but its telling the same errors
Is it possible to use Yolo for peron detection when persons are far from the camera? I mean they are small part of the frame
Yes if you look at the demo you can see that even people far away are detected. But this will be depended on resolution off course. Higher resolution means more details means better detections. Yolo performs best with large objects in the view so best to make sure people are large in the camera view.
Great Lecture and well educative.
Please can u get in touch because there are many problems along after installing all requirements with CUDA and Torch , its still telling they are not Compatible ..
raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled
Please kindly get in touch in response
how to train on custom data?
Hi , Thanks you first. How about the AGV project you mentioned? Anything could be shared with?
Hi sorry for late reply but here is the repo github.com/sieuwe1/Advanced-Real-Time-Self-Driving
Thanks for sharing this very impressive software! I came across your video while trying to learn more about OpenCV and Yolo. I am looking for a way to process video from a security camera to look for object movement. I use a Raspberry Pi for motion detection but it picks up the shadows from moving trees. Do you know where I might find software that will take an existing video and only keep the parts where there is object motion such as cars and people? I was able to get OpenCV and Yolo running with object but not the motion detection. I was expecting to find a lot with a Google search but could not find what I was looking for. If nothing is available what software would you suggest using to build something like this?
Hi so you want to make a alarm go off once there is movement in the camera image?
@@sieuweelferink6852 With my setup I have several Raspberry Pi cameras in a window running motion detection software. The software is good at blocking on areas where there are trees moving but picks up shadows as movement. I download the videos to my Linux server every hour for archiving. If I want to review the video and it is a windy day outside I have to go through a lot of moving shadows from the trees. My assumption is it is not possible to do true object detection on a Raspberry Pi due to limited processing power. I would like to use the downloaded video on my Linux system as input to something that will look for people, cars and animals and then copy only the video that contains objects of interest. Is this possible?
Tom Dedula i suggest you use my code and changes some parts. First change that all classes you want are detected. We only detect the class person but yolo is trained on much more! Then use the list of centerpoints to calculate for each defected id if the total delta between the centerpoints from that id is larger than a threshold. If this is the case then do a opencv write or use a videowriter which gets assigned to each id to save the object. Using an ai network to perform detection will make you able to perform much more accurate and reliable detection of objects but will cost processing power. Maybe look at a jetson nano.
Great work. I wanna ask do we run this without having gpu?
That won’t be possible. Yolo is a very computational intensive neural network. This means it needs a lot of parallel processing power from a GPU. If you are looking to run this in a small form factor envoirement look at the jetson nano. Can run yolo tiny at around 23fps if you get the 4gb version. Fps for this project will be lower since the calculations are done in the video loop. Probably close to 15/20fps on jetson nano.
we would like to use this for our capstone project and add a person distance alarm for social distancing, is there any way we can contact you and ask for your help?
You can ask questions here in the comments !
great work ! will I be ablle to deploy the model on windows 10 using cmd or should i use ubuntu on a virtual machine ?
I would not reccomend any of those options. I have not tested it on windows so I am not sure how it would work there. And secondly for the vm I would not reccomend that either because of overhead and I am not sure how well the Cuda support for vm is right now. I suggest you install Ubuntu alongside windows 10. there is a easy automatic installer which can do that for You. Good luck
@@sieuweelferink6852 so mister this program won't work on Windows 10?
Agil Calfarera you could try it. I believe there are some that made it work. But I know it works on Ubuntu so best to use that.
@@sieuweelferink6852 I have try to use it in my laptop that using windows, but I don't know if there some requirements that I have to complete before using it because its run on windows. Is the way to use it on windows is the same as on your video? Thanks
@@agilcalfarera have you run this on windows?
python3 gui.py
File "gui.py", line 208
print(classlist)
getting error: TabError: inconsistent use of tabs and spaces in indentation
on Windows
Could be a windows only error. I have not tested it on windows. Try removing the code at line 208 and try again. If it does not work you could also launch using start.py
@@sieuweelferink6852 will do and report- cheers
Hello, how to show up the detection accuracy of object?
Yolo returns a array/ tuple with all the information from its detections. Go to line 56 in tracker.py. Here is a tuple called detection where also the accuracy is in. Just go to the yolo website what format the tuple is in and then use that information to get the accuracy.
man thats really awesome. do you have some small projects that i can participate and learn with you ? (like some kind of inteership ?)
Thanks! I am just a student doing some fun projects in my freetime. So I dont have a internship possibility like a company. Just search online for ideas and try to create them.
@@sieuweelferink6852 Goodmorning, i tried the code, got partial output - can u please help me out with my doubts it will very helpful.
Hi, i tried this coding in windows 10, actually am getting partial output. i can stream the live video through web cam, and green color line in the middle of the frame is also coming. but person is not detected with bounding boxes and also parameters are displaying but count is not changing.
hello, have you tested it on pre-recorded videos?
@@hariskkk7106 Yes, do u have any solutions for this? i tried with recorded videos also .. vid is streaming, green line is also coming. but object is not detected yet...
@@akilamariappan9507 run it through main program.
@@hariskkk7106 object is not detecting, can u please share the procedure for the set up and code?i have spent a lot of time in this.
Is there a way to use this on windows?
Hey, is it possible to run this project on a raspberry pi 4 with 4gb RAM?
Definitely not. A fast gpu is needed to run yolo.
3:47 hoe vind je nou het juiste mapje ooit nog terug dan😂😂
pure chaos
Can you please help me save only the image of the detected object in the video i use cv2.imrite but it takes a picture of all the frame i want just whats inside the bounding boxes of the object
yes that is correct that is why I gave you that link in my previous comment. You need to create a roi with the location of the bounding box. The x y width and height . Then save this roi with imwrite. You can get the x y wift and height at line 166 of tracker.py.
Sieuwe Elferink can you please pass me the link i lost the previous comment
@@justdrinkcoca answers.opencv.org/question/29260/how-to-save-a-rectangular-roi/?sort=votes
@@sieuweelferink6852 thank you so much
Hi, can u please help to fix the issues.. , i can stream video and green line is also coming in both the pre recorded vid and even web cam live vid - but object is not detecting.what may be the problem?
I am running it on windows, the program is not detecting anything
Have you solved this problem?
Can we run it on video? or is it only work from camera live video? Sorry, I am new in python
You can run it also from prerecorded video. Then change the line at cv2.videoCapture() to cv2.videoCapture('path to video file' )
@@sieuweelferink6852 Thanks a lot for the reply. One more question please. How to crop each object detected inside of the bounding box into the image file? Thanks is advance
@@jokosusilo303 use this answers.opencv.org/question/29260/how-to-save-a-rectangular-roi/?sort=votes
@@sieuweelferink6852 Hello, I also want run it from prerecorded video. And gui.py file running is ok. But after I run start.py, the terminal just no results. Thank you in advance.
@@shaopengcui6909 can you make a small video regarding how you install all the dependcies on ubuntu and how you run this project it would be reallly benefecial..
did u use cuda 10 or cuda 11?
We used Cuda 10.1
Amazing job! How fast did you get in fps in real time video?
Got around 20/30 fps on gtx2070 super with max 60% gpu usage. fps depends on how many people are in the view
will this work on windows 10 ?
It has been shown to work. Will however take some debugging.
First!
Awesome work.
I am facing some problem figuring out dependencies. I would be very grateful if you share requirement file or a docker image so that it would be easy to setup.
I am trying to run this code on Windows.
Thank you in advance
hi
requirements are in the github Readme. What errors do you have?
@@sieuweelferink6852 sorry for the late reply I am facing some runtime error. I am new to all this stuff
Traceback (most recent call last):
File "C:\Users\De\AppData\Local\Continuum\anaconda3\envs\gpu\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Users\De\AppData\Local\Continuum\anaconda3\envs\gpu\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "Z:\DEEP_Learning\original files\Yolo based model\using GPU\or-objectdetection\YOLO_DETECTION\tracker.py", line 155, in yoloWorker
tracked_objects = mot_tracker.update(detections.cpu())
File "Z:\DEEP_Learning\original files\Yolo based model\using GPU\or-objectdetection\YOLO_DETECTION\sort.py", line 208, in update
matched, unmatched_dets, unmatched_trks = associate_detections_to_trackers(dets,trks)
File "Z:\DEEP_Learning\original files\Yolo based model\using GPU\or-objectdetection\YOLO_DETECTION\sort.py", line 147, in associate_detections_to_trackers
iou_matrix[d,t] = iou(det,trk)
RuntimeError: Expected object of type torch.FloatTensor but found type torch.DoubleTensor for argument #3 'other'
Thank you in advance
Hello, the problem is solved by updating the pytroch version. but still detected bounding boxes are not aligning with the object.
@@deveshdashore5918 sorry for late reply is it already fixed? may be that the resolution is not correct. then the bounding boxes are not aligned.
hey
devesh , can you please tell me how did you run the program on windows ? (the steps)
Can i have your email
Interesting project, imagine this method can implement in car to avoid collision😊
very good work! thanks for sharing this!
how to train custom data?