Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pedestrian counting #12

Open
LESRQ opened this issue Oct 26, 2018 · 4 comments
Open

Pedestrian counting #12

LESRQ opened this issue Oct 26, 2018 · 4 comments

Comments

@LESRQ
Copy link

LESRQ commented Oct 26, 2018

Hi,
I'm a somewhat newbie to deep-learning and therefore I would be pleased if you have time to answer my questions.

Situation
Now I'm doing research on how the pedestrian traffic influences the traffic of bank's offices located nearby. So my goal at this stage is to count correctly the number of people passing by the office. I was intended to use DVR(or another camera) located near the window inside the bank office. Consequently, the camera will be located on the side.

So, my questions:

  1. Are there any ready-to-go packages on python which would help to count pedestrians accurately (in my situation described above)? Is it possible?
  2. If it's possible, can you recommend some python solution (besides yours) for my purposes? As I already mentioned, I'm respectively new in this area and your solution is the best one I've googled.
  3. I used your code (https://github.com/ahmetozlu/tensorflow_object_counting_api/blob/master/pedestrian_counting.py) for your sample video, and didn't count pedestrians right. Specifically, I obtained the figure of 6 people passed through the line (while the real amount is 13). Are your results the same? Or maybe I'm doing something wrong?

I would be very grateful if you have time to answer.

@wiwengweng
Copy link

I would like to share my exp here. Hi, @LESRQ , I am Andes and nice to see you are intersted with this too. I am trying to make this counting more accurate.

You can check the object_counter.py or object_counter_x_axis.py. They show the counting algorithm here. if the deviation is too small, abs(((left+right) / 2) - roi_position) is not less than roi_position, and the algorithm just ignore that person. So maybe you can just increase the deviation to check if it works. Keep in touch.

Andes.

@daktirr
Copy link

daktirr commented Mar 11, 2019

Hi.

I would like to use this code and modify it for a counting project to experiment with Tensorflow and machine learning but I'm having an problem at the get-go. How do I change the input video to use the Pi-Camera or another source instead of a file? So far I've tried:

import tensorflow as tf
import cv

# Object detection imports
from utils import backbone
from api import object_counting_api

if tf.__version__ < '1.4.0':
  raise ImportError('Please upgrade your tensorflow installation to v1.4.* or later!')

cap = cv2.VideoCapture(0)

detection_graph, category_index = backbone.set_model('ssd_mobilenet_v1_coco_2017_11_17')

fps = 30 # change it with your input video fps
width = 626 # change it with your input video width
height = 360 # change it with your input vide height
is_color_recognition_enabled = 0 # set it to 1 for enabling the color prediction for the detected objects
roi = 385 # roi line position
deviation = 1 # the constant that represents the object counting area

object_counting_api.cumulative_object_counting_x_axis(cap, detection_graph, category_index, is_color_recognition_enabled, fps, width, height, roi, deviation) # counting all the objects

Also, with the DVR method, did you use a raspberry or another device to process the counting? What was your set up like @LESRQ. Also, how is your project coming along?

@ahmetozlu
Copy link
Owner

@ahmetozlu
Copy link
Owner

Hi @LESRQ ,

1.) I have not found any chances to deploy tensorflow_object_counting_api to pip environment. However, I am planning to do it when I find the chance asap!

2.) You can use tensorflow_object_counting_api functions to count the objects accurately but you need to fine-tune the function parameters considering your input cases to reach the high accuracy. The built-in parameters are just set for general cases and if you use them as is, your accuracy will not be high most probably. You need to fine-tune the parameters.

3.) It depends the object detector, when the object detector could not detect the object then the object counting algorithm can not work properly. I suggest you try a different object detector (YOLO, RCNN, etc.) thus there must not be any false positive or true negative counted objects.
The SSD MobileNet detector in this repository is a general purpose one (not optimized specifically for vehicle/pedestrian detection) thus there can be some missed detection so it effects the counting algorithm performance directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants