NationalAssociationOfRealtors / VehicleCounting

using OpenCV to count vehicles
18 stars 9 forks source link

Attribute Error #1

Open baycemrak opened 8 years ago

baycemrak commented 8 years ago

I tried to run this code but I got an error. What is the reason of it?

Traceback (most recent call last): File "main_fei_dybg.py", line 25, in <module> height = frame.shape[0] AttributeError: 'NoneType' object has no attribute 'shape'

3011204077 commented 8 years ago

@baycemrak Did you change anything in this code? You may try the code again, I slightly updated it. BTW, do you have any suggestions for the filters?

baycemrak commented 8 years ago

Nope I didn't change anything. Actually I am newly interested with this opencv and python things. Now when I execute this code it gives me another error which is File "vehicle_counter_fei.py", line 130, in <module> for match in matches: NameError: name 'matches' is not defined I checked and searched, it looks defined to me but I couldn't convince the computer :)

3011204077 commented 8 years ago

@baycemrak The 'matches' is defined in "main.py", and then be imported into "vehicle_counter.py"(I changed the name). Also, you should keep "main.py" and "vehicle_counter.py" in the same folder.

baycemrak commented 8 years ago

Sir, hi again, I am newbie about python and opencv and I got a project that about counting the vehicles from camera on raspberry pi. I execute your code it works finally but there are somethings that I don't understand. Main thing is how it detects and counts the motion. And how can I implement these code for another video which has traffic flows come vertically?

3011204077 commented 8 years ago

@baycemrak You need to adjust the counting algorithm to count the vertical flow. For the motion detection, you could read the instruction.

baycemrak commented 8 years ago

Yes, I've read instruction and read a lot things about that. I am trying to implement these code till morning. I began to understand quietly but still didn't get how it counts the vehicle. I almost got the main.py but I need to know more what's happen vehicle_count.py

3011204077 commented 8 years ago

@baycemrak Hard to say through text, you could run the program step by step to find out more. Basically it finds the contours of each moving objects and calculate it's centroid.

baycemrak commented 8 years ago

Man I didn't get the whole idea. There are some part that I couldn't understand. Main concept and philosophy is okey, I got it but I still don't know what the some function does. I managed the code and changed somethings and read again and again but still it doesn't count when the cars cross the line. Sometimes the polylines' color may change, I guess it takes different id, idk. And in order to show the cars in a rectangle, I combined process_frame() and detect_vehicles() together but it doesn't work too rectangles may disappear. Really it would be perfect if you help me. I need to know how update_count() works and why we need get_vector(). Thank you a lot for now. If you don't have time for this, it's okay, you've helped a lot thank you very much.

baycemrak commented 8 years ago

Oh! Finally I configured the code and it's working. I got the idea of update_count and representation of vehicle position still I don't know what does the get_vector do and I have a few problems such as unclear background subtraction or counting every little motion on the line. Do you have any idea about more clean background or ignoring the little motion?

3011204077 commented 8 years ago

@baycemrak In my view there are two ways, use specific filters or change the thresholds in the code. I thin you could try other filters since I'm not sure the quality of the video stream you are using.

On Wed, Aug 24, 2016 at 7:58 AM, Cem Bayrak notifications@github.com wrote:

Oh! Finally I configured the code and it's working. I got the idea of update_count and representation of vehicle position still I don't know what does the get_vector do and I have a few problems such as unclear background subtraction or counting every little motion on the line. Do you have any idea about more clean background or ignoring the little motion?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NationalAssociationOfRealtors/VehicleCounting/issues/1#issuecomment-242053875, or mute the thread https://github.com/notifications/unsubscribe-auth/AP84Ok9DrvJgrDKIXcHlkoGFtXiia7V_ks5qjEATgaJpZM4JmhBA .

baycemrak commented 8 years ago

Thanks man, than you for everything. İt's done, it's very stabile. Now I am trying to improve like counting separately the cars, the buses or the trucks etc. I got a question, do you have any idea about changing the line's colour or make brighter suddenly when the count increse?

3011204077 commented 7 years ago

@baycemrak If you go into the code it should be easy to change the line's color or other features. BTW please let me know if you have ideas about detecting categories of cars separately.