Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QTQuick, OpenCv and Gstreamer frame capturing
Forum Updated to NodeBB v4.3 + New Features

QTQuick, OpenCv and Gstreamer frame capturing

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
gstreamer1.0opencv
1 Posts 1 Posters 512 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ElifOzkan
    wrote on 25 Aug 2022, 12:50 last edited by
    #1

    I am new and using the QT for streaming gstreamer video (now from webcam) to QML using QMediaPlayer. It works when I only run the video stream part but I want to take these video frames and process it to find some objects using openCV. How can I capture these frames using VideoCapture and gstreamer pipeline as it is. Or could you suggest another qt way to garb a frame?

    My main.cpp is below;

    QMediaPlayer* player = new QMediaPlayer();
    
    auto qmlPlayer = engine.rootObjects()[0]->findChild<QObject*>("player");
    player = qvariant_cast<QMediaPlayer*>(qmlPlayer->property("mediaObject"));
    
    player->setMedia(QUrl("gst-pipeline: v4l2src device=/dev/video0 ! videoconvert ! videoscale ! video/x-raw,width=1280,height=720 ! qtvideosink"));
    
    player->play();
    
    cv::VideoCapture* cap;
    cv::Mat img;
    
    cap =  new VideoCapture(CAP_GSTREAMER);
    
    bool deneme = cap->isOpened();
    if (!deneme){
        qInfo() << "false";
    }
    

    Above code works when there is no videoCapture but if I run it like this I get errors below.

    libv4l2: error setting pixformat: Device or resource busy [ WARN:0] global /home/elif/opencv-4.5.4/source/modules/videoio/src/cap_gstreamer.cpp (2076) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src1 reported: Device '/dev/video0' is busy [ WARN:0] global /home/elif/opencv-4.5.4/source/modules/videoio/src/cap_gstreamer.cpp (1053) open OpenCV | GStreamer warning: unable to start pipeline [ WARN:0] global /home/elif/opencv-4.5.4/source/modules/videoio/src/cap_gstreamer.cpp (616) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created false libv4l2: error got 4 consecutive frame decode errors, last error: v4l-convert: error unexpected width / height in JPEG header: expected: 1280x720, header: 160x120 Error: "Failed to allocate a buffer"

    My versions:
    QT: 5.15.2 OpenCV: 4.5.4 Gstreamer: 1.0

    1 Reply Last reply
    0

    1/1

    25 Aug 2022, 12:50

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved