Code Monkey home page Code Monkey logo

Comments (5)

TomasTrnkaPLC avatar TomasTrnkaPLC commented on May 18, 2024

I want to use vidgear with for webcam and also the file loading.
For webcam or youtube run everything well problem is when I load the video.
My program is based on frame position so I use code like this:

video_pos =int(cap.get(cv2.CAP_PROP_POS_FRAMES))

but I get error
AttributeError: 'CamGear' object has no attribute 'get' how I can fix it?

Some question is how I can jump to specific frame.

Thanks for the answer

from vidgear.

abhiTronix avatar abhiTronix commented on May 18, 2024

My program is based on frame position so I use code like this:

video_pos =int(cap.get(cv2.CAP_PROP_POS_FRAMES))

but I get error
AttributeError: 'CamGear' object has no attribute 'get' how I can fix it?

Some question is how I can jump to specific frame.

@TomasTrnkaPLC This is not a bug or issue with vidgear, you can easily access frame position with vidgear as follows:

from vidgear.gears import CamGear
import cv2

cap =  CamGear(source='test.mp4').start()
video_pos =int(cap.stream.get(cv2.CAP_PROP_POS_FRAMES))

⚠️ But it is not advisable nor it is guaranteed that it will work and here are some reasons for this conclusion:

Why it is not advisable to use VidGear for jumping/seeking specific frame?

VidGear provides a high-level Threaded wrapper around OpenCV's API that targets only specific methods and classes related to Video Processing. It is possible to access other methods too but not advisable with VidGear as it uses Threads and Queue structure for capturing frame, which can result in undesired effects with those methods. Therefore you should refrain yourself from using frame jumping/seeking in VidGear but rather use OpenCV directly for this purpose.

Why it is not advisable to use Frame Jumping/Seeking in OpenCV at all?

OpenCV is still in beta stage, with many bugs that remain unsolved. The VideoCapture::set (CAP_PROP_POS_FRAMES, frameNumber) method itself is not exact or reliable in OpenCV and can lead to wrong frame seeking at any instance. You can see this famous issue in OpenCV github repository related to this bug: opencv/opencv#9053 which is still unsolved.

Here is the comment from Alexander Alekhin(Lead developer at OpenCV):

OpenCV highly uses FFmpeg (in case of FFmpeg backend).
But FFmpeg itself doesn't work well with seeking on non "key" frames. There are many workarounds, but they are not very reliable. Sometimes seeking code works, sometimes doesn't.
If your have worked FFmpeg's code with accurate seeking, then we could try to integrate it into OpenCV.

Hence, Kindly refrain from using Frame Jumping/Seeking with OpenCV at all. Hope this helps good luck.

from vidgear.

TomasTrnkaPLC avatar TomasTrnkaPLC commented on May 18, 2024

from vidgear.

abhiTronix avatar abhiTronix commented on May 18, 2024

I have one more question
when I try run = cap.stream.set(cv2.CAP_PROP_POS_FRAMES,trackbarValue) I
get reply True but stream never jump there. I talking about the jump when
is file loaded.

@TomasTrnkaPLC I already told you that OpenCV is still buggy and cannot reliably seek/jump frame due to a inherit bug. You can see this issue in OpenCV Github repository related to this bug: opencv/opencv#9053 which is still unsolved.

on Windows 10 scripts only create
an empty .mp4 file and never record anything. Why?

@TomasTrnkaPLC Wrong, I tested all my VidGear scripts on Windows 10 x64 machine, There must a problem at your end. Kindly paste the terminal log here for further debugging the error which is causing this problem.

from vidgear.

TomasTrnkaPLC avatar TomasTrnkaPLC commented on May 18, 2024

from vidgear.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.