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

Comments

@vtushevskiy
Copy link

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

This comment has been minimized.

Copy link
Owner

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

This comment has been minimized.

Copy link
Owner

commented Jun 16, 2018

I modified video_effect.py at 8dacdf9

@vtushevskiy

This comment has been minimized.

Copy link
Author

commented Jun 19, 2018

Actually it works for me with every frame

@hanyazou

This comment has been minimized.

Copy link
Owner

commented Jun 23, 2018

so we can close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.