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

[Bug]: Zero(0) index device bug in StreamGear #289

Closed
3 tasks done
abhiTronix opened this issue Feb 17, 2022 · 4 comments · Fixed by #290 or #321
Closed
3 tasks done

[Bug]: Zero(0) index device bug in StreamGear #289

abhiTronix opened this issue Feb 17, 2022 · 4 comments · Fixed by #290 or #321
Assignees
Labels
BUG 🐛 Vidgear api's error, flaw or fault SOLVED 🏁 This issue/PR is resolved now. Goal Achieved!
Milestone

Comments

@abhiTronix
Copy link
Owner

abhiTronix commented Feb 17, 2022

Brief Description

There's a hidden bug in StreamGear which incorrectly infers -video_source attribute of stream_params dictionary parameter as empty when a Zero(0) index camera device is used as input, and thereby even if logging=False StreamGear API outputs debug logs.

Acknowledgment

Environment

  • VidGear version: v0.2.6
  • Branch: testing
  • Python version: 3.7+
  • PiP version: latest
  • Operating System and version: all

Actual Behavior

If we use -video_source attribute in stream_params dictionary parameter 0(or use zero index camera device), it makes self.__video_source in StreamGear True, since string("0") is not false or "0"!=False in python language.

Expected Behavior

Must able to handle -video_source attribute value properly.

Steps to reproduce

# import required libraries
from vidgear.gears import CamGear
from vidgear.gears import StreamGear
import cv2

# open any valid video stream
stream = CamGear(source="foo.mp4").start() 
# define `-video_source` value to `0`
stream_params = {"-video_source": 0}
# describe a suitable master playlist location/name and assign params
streamer = StreamGear(output="./New folder/hls_out.m3u8", format = "hls", **stream_params)
# loop over
while True:

    # read frames from stream
    frame = stream.read()

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


    # {do something with the frame here}


    # send frame to streamer
    streamer.stream(frame)

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

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

# close output window
cv2.destroyAllWindows()

# safely close video stream
stream.stop()

# safely close streamer
streamer.terminate()

Credits

This bug was discovered by @enarche-ahn

@abhiTronix abhiTronix added BUG 🐛 Vidgear api's error, flaw or fault BUG CONFIRMED ✅ Bug is confirmed! WORK IN PROGRESS 🚧 currently been worked on. labels Feb 17, 2022
@abhiTronix abhiTronix added this to the 0.2.6 milestone Feb 17, 2022
@abhiTronix abhiTronix added this to To do in VidGear v0.2.6 via automation Feb 17, 2022
@abhiTronix abhiTronix self-assigned this Feb 17, 2022
@abhiTronix abhiTronix changed the title [Bug]: Zero(0) index device bug in StreamGear's Single-Source Mode [Bug]: Zero(0) index device bug in StreamGear Feb 17, 2022
abhiTronix added a commit that referenced this issue Feb 17, 2022
- 🐛 Fixed debug logs even when `logging=False` in StreamGear's Real-time Mode. (patch suggested by @enarche-ahn)
- 🎨 Added length check to `"-video_source"` attribute to correctly infers it as empty(or invalid).
- 💡 Updated code comments.

✏️ Docs: Fixed typos in formatting.
@abhiTronix
Copy link
Owner Author

abhiTronix commented Feb 17, 2022

Hi @enarche-ahn, can you test if logging problem is fixed in StreamGear by installing development branch as follows:

 # clone the repository and get inside
  git clone https://github.com/abhiTronix/vidgear.git && cd vidgear

  # checkout the latest development branch
  git checkout development

  # install normally
  pip install .[core]

  # OR install with asyncio support
  pip install .[asyncio]

After installing, run your test example again. Kindly test it as soon as possible and share your results here. Goodluck!

@enarche-ahn
Copy link
Contributor

Just now I finished testing with the development branch, and it worked fine in both case, 'logging=True' and 'logging=False' option.

streamer = StreamGear(
output="./New folder/hls_out.m3u8",
format="hls",
logging=False,
**stream_params)

streamer = StreamGear(
output="./New folder/hls_out.m3u8",
format="hls",
logging=True,
**stream_params)

@abhiTronix
Copy link
Owner Author

@enarche-ahn Thanks. 👍🏽

@abhiTronix abhiTronix removed the BUG CONFIRMED ✅ Bug is confirmed! label Feb 17, 2022
@abhiTronix abhiTronix moved this from To do to In progress in VidGear v0.2.6 Feb 17, 2022
@abhiTronix
Copy link
Owner Author

Successfully resolved and merged in commit 1b9b413

VidGear v0.2.6 automation moved this from In progress to Done Feb 18, 2022
@abhiTronix abhiTronix added SOLVED 🏁 This issue/PR is resolved now. Goal Achieved! and removed WORK IN PROGRESS 🚧 currently been worked on. labels Feb 18, 2022
@abhiTronix abhiTronix linked a pull request Jul 5, 2022 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BUG 🐛 Vidgear api's error, flaw or fault SOLVED 🏁 This issue/PR is resolved now. Goal Achieved!
Projects
No open projects
2 participants