abhiTronix / deffcode

A cross-platform High-performance FFmpeg based Real-time Video Frames Decoder in Pure Python 🎞️⚡
https://abhitronix.github.io/deffcode
Apache License 2.0
178 stars 3 forks source link

[v0.2.4] New Index based Camera Device Capturing (Fixes #27) #29

Closed abhiTronix closed 1 year ago

abhiTronix commented 2 years ago

Brief Description

Implemented a new Index based Camera Device Capturing feature (Similar to OpenCV), where the user just have to assign device index as integer number in source parameter of DeFFcode APIs to directly access the given input device in few seconds.

Requirements / Checklist

Related Issue

27

Context

Currently deffcode users have to manually Identify and Specify each Video Capture Device Name/Path and suitable Demuxer on different OS platforms. This PR bring the Index based Camera Device Capturing feature that implements Device Indexing (similar to OpenCV) for all currently supported OS platforms, where the user just have to assign device index as integer (-n to n-1th) in source parameter of DeFFcode APIs to directly access the given input device in few seconds, thus minimizing perceived complexity of decoding Live Feed Devices.

Types of changes

Miscellaneous (if available):

Bare-minimum Code to test this PR feature on your computer:

# import the necessary packages
from deffcode import FFdecoder
import cv2

# initialize and formulate the decoder for BGR24 pixel format output
decoder = FFdecoder(0, frame_format="bgr24", verbose=True).formulate()

# grab the BGR24 frames from decoder
for frame in decoder.generateFrame():

    # check if frame is None
    if frame is None:
        break

    # {do something with the frame here}

    # Show output window
    cv2.imshow("Output", frame)

    # check for 'q' key if pressed
    key = cv2.waitKey(1) & 0xFF
    if key == ord("q"):
        break

# close output window
cv2.destroyAllWindows()

# terminate the decoder
decoder.terminate()
codecov[bot] commented 2 years ago

Codecov Report

Base: 97.57% // Head: 96.61% // Decreases project coverage by -0.95% :warning:

Coverage data is based on head (f82ae29) compared to base (f833f25). Patch coverage: 93.06% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #29 +/- ## ========================================== - Coverage 97.57% 96.61% -0.96% ========================================== Files 6 6 Lines 618 768 +150 ========================================== + Hits 603 742 +139 - Misses 15 26 +11 ``` | [Impacted Files](https://codecov.io/gh/abhiTronix/deffcode/pull/29?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhishek+Thakur) | Coverage Δ | | |---|---|---| | [deffcode/ffhelper.py](https://codecov.io/gh/abhiTronix/deffcode/pull/29/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhishek+Thakur#diff-ZGVmZmNvZGUvZmZoZWxwZXIucHk=) | `96.66% <85.96%> (-3.34%)` | :arrow_down: | | [deffcode/utils.py](https://codecov.io/gh/abhiTronix/deffcode/pull/29/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhishek+Thakur#diff-ZGVmZmNvZGUvdXRpbHMucHk=) | `97.87% <87.50%> (+2.87%)` | :arrow_up: | | [deffcode/sourcer.py](https://codecov.io/gh/abhiTronix/deffcode/pull/29/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhishek+Thakur#diff-ZGVmZmNvZGUvc291cmNlci5weQ==) | `97.33% <94.11%> (-0.89%)` | :arrow_down: | | [deffcode/ffdecoder.py](https://codecov.io/gh/abhiTronix/deffcode/pull/29/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhishek+Thakur#diff-ZGVmZmNvZGUvZmZkZWNvZGVyLnB5) | `95.61% <96.80%> (+0.16%)` | :arrow_up: | | [deffcode/version.py](https://codecov.io/gh/abhiTronix/deffcode/pull/29/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhishek+Thakur#diff-ZGVmZmNvZGUvdmVyc2lvbi5weQ==) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhishek+Thakur). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhishek+Thakur)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.