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

opencv av stream #5

Closed
vtushevskiy opened this issue Jun 13, 2018 · 4 comments
Closed

opencv av stream #5

vtushevskiy opened this issue Jun 13, 2018 · 4 comments

Comments

@vtushevskiy
Copy link

vtushevskiy commented Jun 13, 2018

Hi!
Thanks for amazing SDK!
There is an issue in video_effect.py: the video by default has very big lag. It tries to work on every single frame with huge resolution and it has certain delay.
I guess we could use something like this but more sophisticated like adaptive frame skip:

        while True:
            i = 0
            for frame in container.decode(video=0):
                print i
                i=i+1
                if i>300: #skip first 300 frames
                    if i%4==0: #do only 1/4 frames
                        im = numpy.array(frame.to_image())
                        im = cv2.resize(im, (320,240)) #resize frame
                        image = cv2.cvtColor(im, cv2.COLOR_RGB2BGR)
                        cv2.imshow('Original', image)
                        cv2.imshow('Canny', cv2.Canny(image, 100, 200))
                        cv2.waitKey(1)
@hanyazou
Copy link
Owner

hanyazou commented Jun 16, 2018

Thank you for good suggestion.

I've been concerned about the delay. Skipping first frames seems to be enough on my Mac to fix the delay.

    i = 0
    while True:
        for frame in container.decode(video=0):
            # skip first 300 frames
            i = i + 1
            if i < 300:
                continue
            image = cv2.cvtColor(numpy.array(frame.to_image()), cv2.COLOR_RGB2BGR)
            cv2.imshow('Original', image)
            cv2.imshow('Canny', cv2.Canny(image, 100, 200))
            cv2.waitKey(1)

Do you really need skip 3/4 frames and resize?
My mac is iMac late 2012 3.4GHz Intel Core i7. Please tell me about your machine.

@hanyazou
Copy link
Owner

I modified video_effect.py at 8dacdf9

@vtushevskiy
Copy link
Author

Actually it works for me with every frame

@hanyazou
Copy link
Owner

so we can close this issue.

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