Note : the location of this repository will be downloaded on the folder that you are currently on, so you should put it in the place where you can run import the package easily.
2. Create a new virtual environment to avoid package conflict
macos or linux:
python3 -m venv __your virtual environment name__
windows:
python -m venv __your virtual environment name__
3. Activate the virtual environment
the " " are not included
macos or linux:
source"your virtual environment"/bin/activate
windows:
"your virtual environment"/Scripts/activate
4. Install necessary dependencies for this package to the virtual environment.
Once you have created the virtual environment, you should run this command.
pip install -r requirements.txt
5. Finally: If there is no any error, that is mean that you have successfully installed the package.
Next are some examples:
1. People detection
In this example, I only test with detecting only people.
You can try other objects if there is any error:
Tell me :) and fix it together.
importcv2ascvfromLaoODetectionimportObjectDetector#import the packagedefmain():
# Input source: webcamvideo_capture=cv.VideoCapture(0)
# chose object targetdetector=ObjectDetector(target_object="person")
# run the object detection algorithmdetector.object_detection(video_capture)
# getting data from the algorithmprint("Detected: {0} people.".format(detector.number_of_detected_objects))
if__name__=="__main__":
main()
2. Counting specific object on a specific area:
In this example we need the region of interest in order to detect only specific location in the frame
The target_object can be other objects such as person, cat, dog
importcv2ascvfromLaoODetectionimportObjectDetectorCOUNTER_line1= [80, 400, 700, 400] # this should be changed to fit your needregion_of_interest=cv.imread("RegionOfInterest/roi_people.png")
defmain():
# Note you can change the input source to be a webcam# Input source: Videovideo_location='testing_video/cars.mp4'video_capture=cv.VideoCapture(video_location)
# Running the object detection algorithmtarget= ["car", "bus", "truck", "motorbike"]
detector=ObjectDetector(target_object=target)
detector.object_line_counter(video_capture=video_capture, region_of_interest=region_of_interest,
counter_line1=COUNTER_line1, detecting_range=(15, 30))
# getting the result to command screenprint("Detected: {0} people.".format(detector.number_of_detected_objects))
if__name__=="__main__":
main()