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

double frame read #134

Closed
carterw opened this issue Aug 1, 2023 · 5 comments
Closed

double frame read #134

carterw opened this issue Aug 1, 2023 · 5 comments

Comments

@carterw
Copy link

carterw commented Aug 1, 2023

It looks like two image frames are being acquired for every cycle through the scanning loop and the first one is not used.

On line 1326 there is the scanning loop;
while still_scanning: # process camera thread images and calculate speed

Then there's a frame read;
image2 = vs.read() # Read image data from video steam thread instance
And then speed_get_contours() is called, passing in the frame that was read;
grayimage1, contours = speed_get_contours(image2, grayimage1)

But then speed_get_contours() ignores the frame that was passed in and does another read in the while not image_ok: loop.

Was this intentional? It seems like that second frame read could be eliminated.

@pageauc
Copy link
Owner

pageauc commented Aug 2, 2023 via email

@carterw
Copy link
Author

carterw commented Aug 2, 2023

Yes I understand what the method does. I was pointing out that speed_get_contours() ignores the incoming frame and performs a second frame read in a loop before a crop is attempted. Maybe the vs.read() could be moved to the bottom of that loop? But if you are happy with it as-is that's fine with me.

@pageauc
Copy link
Owner

pageauc commented Aug 5, 2023

Thanks for your correct explanation.
See speed-cam.py ver 12.01 for updated logic
Claude ...

@carterw
Copy link
Author

carterw commented Aug 5, 2023

Thanks for the helpful fix!

@carterw carterw closed this as completed Aug 5, 2023
@pageauc
Copy link
Owner

pageauc commented Aug 5, 2023

Note 12.02 replaces np.std with np.median for calculating ave speed.

Speed camera is written as an object tracker. I will look at adding an option to use vehicle recognition (opencv haarcascade) that can improve speed calculation.

Claude.

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

2 participants