简体   繁体   中英

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. I have a very small gstreamer pipline and it fails to open the gstreamer if I dont run with sudo infront of python. I have soon depleted my options, any help would be appriciated. (Using Jetson Orin and 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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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