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]: Stabilization not good on linux environment #416

Closed
3 tasks done
ronfromhp opened this issue Jul 29, 2024 · 6 comments
Closed
3 tasks done

[Bug]: Stabilization not good on linux environment #416

ronfromhp opened this issue Jul 29, 2024 · 6 comments
Labels
INVALID 🛑 This doesn't seem right or non-applicable or missing information
Milestone

Comments

@ronfromhp
Copy link

ronfromhp commented Jul 29, 2024

Description

Video gets even more unstable after stabilizing it on linux, while the same stabilized video looks fine on windows

Issue Checklist

  • I have searched open or closed issues for my problem and found nothing related or helpful.
  • I have read the Documentation and found nothing related to my problem.
  • I've read the Issue Guidelines and wholeheartedly agree.

Expected behaviour

i expected the stabilized video coming out like this on linux, which is what it does on windows

Avi0130.Mov.Stab.mp4

Actual behaviour

the actual stabilized video looks like this

D3cd022e8f0e289a99d44a2776be9b1a.Mov.Stab.mp4

Steps to reproduce

I used the below python code to process the files

Terminal log output

No response

Python Code(Optional)

from vidgear.gears.stabilizer import Stabilizer
import cv2
import time
import logging

logger = logging.getLogger(__name__)
logger.setLevel(level=3)
stab = Stabilizer(border_size=10, crop_n_zoom=True, logging=True)

def stabilize_video(input_path, output_path):
    start_time = time.time()
    stream = cv2.VideoCapture(input_path)
    
    # Get video properties
    fps = int(stream.get(cv2.CAP_PROP_FPS))
    width = int(stream.get(cv2.CAP_PROP_FRAME_WIDTH))
    height = int(stream.get(cv2.CAP_PROP_FRAME_HEIGHT))
    
    # Define the codec and create VideoWriter object
    fourcc = cv2.VideoWriter_fourcc(*'mp4v')
    out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
    
    while True:
        # read frames from stream
        (grabbed, frame) = stream.read()
        
        if not grabbed:
            break
        # send current frame to stabilizer for processing
        stabilized_frame = stab.stabilize(frame)

        # wait for stabilizer which still be initializing
        if stabilized_frame is None:
            continue
        
        out.write(stabilized_frame)

    # clear stabilizer resources
    stab.clean()

    # safely close video stream
    stream.release()
    out.release()
    logger.info(f"Stabilization completed in {time.time() - start_time} seconds.")
    return True

VidGear Version

0.3.3

Python version

3.11.9

OpenCV version

opencv-python-headless-4.8.0.74

Operating System version

wsl Ubuntu-22.04

Any other Relevant Information?

No response

@ronfromhp ronfromhp added the BUG 🐛 Vidgear api's error, flaw or fault label Jul 29, 2024
Copy link

welcome bot commented Jul 29, 2024

Thanks for opening this issue, a maintainer will get back to you shortly!

In the meantime:

  • Read our Issue Guidelines, and update your issue accordingly. Please note that your issue will be fixed much faster if you spend about half an hour preparing it, including the exact reproduction steps and a demo.
  • Go comprehensively through our dedicated FAQ & Troubleshooting section.
  • For any quick questions and typos, please refrain from opening an issue, as you can reach us on Gitter community channel.

@abhiTronix
Copy link
Owner

@ronfromhp This is weird. There are platform-specific changes in the Stabilizer API that I know of. I'll test it on my system and let you know. This issue mostly arises from a small error in code you write in a script, so if you could double-check, that would be great.

@abhiTronix abhiTronix added WORK IN PROGRESS 🚧 currently been worked on. BUG UNCONFIRMED 🙅 Bug is still uncomfirmed! labels Jul 30, 2024
@ronfromhp
Copy link
Author

I've double checked it and it shows no error on the logs or in the output, only issue is that the quality of the stabilization is worse on the Ubuntu enviornment

@abhiTronix abhiTronix added BUG CONFIRMED ✅ Bug is confirmed! and removed BUG UNCONFIRMED 🙅 Bug is still uncomfirmed! labels Aug 11, 2024
@abhiTronix abhiTronix added this to the v0.3.4 milestone Aug 11, 2024
@abhiTronix abhiTronix added MISSING : INFORMATION 🔍 Requested proper information/evidence about the Issue/PR in context. BUG UNCONFIRMED 🙅 Bug is still uncomfirmed! and removed BUG CONFIRMED ✅ Bug is confirmed! labels Aug 11, 2024
@abhiTronix
Copy link
Owner

@ronfromhp This error is not reproducible on any Linux distro:

  • Tested on Linux Mint
  • Tested on Ubuntu (separate machine)
  • Tested on Ubuntu 22.04 WSL (as per your environment)
  • Tested on Raspberry Pi
    All tests worked perfectly.

Closing this issue as it is not reproducible.

@abhiTronix abhiTronix added INVALID 🛑 This doesn't seem right or non-applicable or missing information and removed BUG 🐛 Vidgear api's error, flaw or fault WORK IN PROGRESS 🚧 currently been worked on. MISSING : INFORMATION 🔍 Requested proper information/evidence about the Issue/PR in context. BUG UNCONFIRMED 🙅 Bug is still uncomfirmed! labels Oct 8, 2024
@abhiTronix abhiTronix removed their assignment Oct 8, 2024
@abhiTronix
Copy link
Owner

Try to use different version of OpenCV it might possible something broken there.

@ronfromhp
Copy link
Author

ronfromhp commented Oct 11, 2024

Sorry, forgot to update you on this bug for a long time, actually i made a mistake while specifying the platform, the bug only exists on this debian docker image which im using like this

# syntax=docker/dockerfile:1

ARG PYTHON_VERSION=3.11
ARG DEBIAN_VERSION=bullseye

FROM public.ecr.aws/docker/library/python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} AS base

WORKDIR /code

ARG TARGETPLATFORM
RUN echo "Building for $TARGETPLATFORM"

within that i install this version of opencv: opencv-python-headless==4.8.0.74
the bug can be recreated with this configuration.

Also i assume you have tested using the opencv version that i mentioned and it works so i dont think the problem is with opencv here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
INVALID 🛑 This doesn't seem right or non-applicable or missing information
Projects
None yet
Development

No branches or pull requests

2 participants