Code Monkey home page Code Monkey logo

Comments (6)

vbartels avatar vbartels commented on May 23, 2024

Okay - I figured out the Test script is calling the VideoCapture() method with just the index of the video device while the script itself gives the parameter cv2.CAP_GSTREAMER.

vc = cv2.VideoCapture(0)
vc = cv2.VideoCapture(0,cv2.CAP_GSTREAMER)

by removing the parameter the script seems to run - I can see that sync is active in the hue app. Unfortunately im not at home atm so I cant see if the lights are actually changing 🤣

I checked with videotest.py that the resolution is 640x360:

print("width: ")
print(vc.get(cv2.CAP_PROP_FRAME_WIDTH))
print("height: ")
print(vc.get(cv2.CAP_PROP_FRAME_HEIGHT))

I dont know if calling with cv2.CAP_GSTREAMER changes the resolution... I am to dumb to find a proper documentation I understand..

If found this:

def __gstreamer_pipeline(
        camera_id,
        capture_width=1920,
        capture_height=1080,
        display_width=1920,
        display_height=1080,
        framerate=30,
        flip_method=0,
    ):
    return (
            "nvarguscamerasrc sensor-id=%d ! "
            "video/x-raw(memory:NVMM), "
            "width=(int)%d, height=(int)%d, "
            "format=(string)NV12, framerate=(fraction)%d/1 ! "
            "nvvidconv flip-method=%d ! "
            "video/x-raw, width=(int)%d, height=(int)%d, format=(string)BGRx ! "
            "videoconvert ! "
            "video/x-raw, format=(string)BGR ! appsink max-buffers=1 drop=True"
            % (
                    camera_id,
                    capture_width,
                    capture_height,
                    framerate,
                    flip_method,
                    display_width,
                    display_height,
            )
    )
   
stream = cv2.VideoCapture(__gstreamer_pipeline(camera_id=0, flip_method=2), cv2.CAP_GSTREAMER)

Adding the define and changing the call of VideoCapture seems not to provoke the warnings/errors.. however, I dont get any video shown. I am a bit lost now.. I will try again when I have local access and dont have to fiddle with VPN.

from harmonizeproject.

vbartels avatar vbartels commented on May 23, 2024

At home.. changing
vc = cv2.VideoCapture(0,cv2.CAP_GSTREAMER)
to
vc = cv2.VideoCapture(0)
seems to have it solved for me. Lights are running back again - Yay! I cant see a difference to before.

Adding the last codesnippet above seems not to open the videodevice - just nothing happens. Seems like gstreamer is waiting for something.

Maybe somebody is able to explain ^^

from harmonizeproject.

bradleydworak avatar bradleydworak commented on May 23, 2024

from harmonizeproject.

vbartels avatar vbartels commented on May 23, 2024

I tried that at first, because the line is still in the code. Unfortunately it results in:

./harmonize.py
--- Starting Harmonize Project ---
INFO: Single Hue bridge detected on network via mDNS.
Querying hue bridge for entertainment areas on local network.
groupid =  7
Using Entertainment area with group_id: 7
Starting computer vision engine...
--- INFO: Detected video capture card on /dev/video0 ---
Disabling streaming on Entertainment area...
ERROR: Unable to open capture device.

from harmonizeproject.

bradleydworak avatar bradleydworak commented on May 23, 2024

from harmonizeproject.

vbartels avatar vbartels commented on May 23, 2024

Not knowing much about python I fiddled around half the day.
my OpenCV has definetely ffmpeg support builtin:

>>> import cv2
>>> cv2.__version__
>>> info = cv2.getBuildInformation()
>>> video, parallel = info.index('Video'), info.index('Parallel')
>>> print(info[video:parallel])

results in:

'4.5.4'

Video I/O:
    DC1394:                      YES (2.2.6)
    FFMPEG:                      YES
      avcodec:                   YES (58.134.100)
      avformat:                  YES (58.76.100)
      avutil:                    YES (56.70.100)
      swscale:                   YES (5.9.100)
      avresample:                NO
    GStreamer:                   YES (1.19.90)
    PvAPI:                       NO
    v4l/v4l2:                    YES (linux/videodev2.h)
    gPhoto2:                     YES

But I didnt get any further. I also took a look into: ffmpegcv but was not able to get it reading from /dev/video0 . Sadly all the documentations are terrible....

from harmonizeproject.

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.