简体   繁体   English

没有 sudo 无法运行 python gstreamer 脚本

[英]Unable to run python gstreamer script without sudo

I would like to know if someone can answer why I cant seem to get a python gstreamer pipline to work without sudo in linux.我想知道是否有人可以回答为什么我似乎无法让 python gstreamer 管道在没有 sudo 的情况下在 linux 中工作。 I have a very small gstreamer pipline and it fails to open the gstreamer if I dont run with sudo infront of python.我有一个非常小的 gstreamer 管道,如果我不在 python 前面使用 sudo 运行,它无法打开 gstreamer。 I have soon depleted my options, any help would be appriciated.我很快就耗尽了我的选择,任何帮助都会得到帮助。 (Using Jetson Orin and ubuntu 20.05) (使用 Jetson Orin 和 ubuntu 20.05)

import sys
import cv2

def read_cam():
    G_STREAM_TO_SCREEN = "videotestsrc num-buffers=50 ! videoconvert ! appsink"
    cap = cv2.VideoCapture(G_STREAM_TO_SCREEN, cv2.CAP_GSTREAMER)
    if cap.isOpened():
        cv2.namedWindow("demo", cv2.WINDOW_AUTOSIZE)
        while True:
            ret_val, img = cap.read()
            cv2.imshow('demo',img)
            cv2.waitKey(1)
    else:
     print ("camera open failed")

    cv2.destroyAllWindows()


if __name__ == '__main__':
    read_cam()

This is absolutely OK, since vp devices owned by root user.这绝对没问题,因为 root 用户拥有的 vp 设备。

What you can do is to create new group, add current user to it, change group of vp devices to the new one & grant rw permissions.您可以做的是创建新组,将当前用户添加到其中,将 vp 设备组更改为新组并授予 rw 权限。

重新安装您的计算机并彻底安装...。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM